~ubuntu-branches/ubuntu/oneiric/librdf-query-perl/oneiric

« back to all changes in this revision

Viewing changes to lib/RDF/Query/Algebra/TimeGraph.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2011-03-05 17:57:31 UTC
  • Revision ID: james.westby@ubuntu.com-20110305175731-rpdd1euwhz03au01
Tags: upstream-2.905
ImportĀ upstreamĀ versionĀ 2.905

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# RDF::Query::Algebra::TimeGraph
 
2
# -----------------------------------------------------------------------------
 
3
 
 
4
=head1 NAME
 
5
 
 
6
RDF::Query::Algebra::TimeGraph - Algebra class for temporal patterns
 
7
 
 
8
=head1 VERSION
 
9
 
 
10
This document describes RDF::Query::Algebra::TimeGraph version 2.905.
 
11
 
 
12
=cut
 
13
 
 
14
package RDF::Query::Algebra::TimeGraph;
 
15
 
 
16
use strict;
 
17
use warnings;
 
18
no warnings 'redefine';
 
19
use base qw(RDF::Query::Algebra);
 
20
 
 
21
use Data::Dumper;
 
22
use Carp qw(carp croak confess);
 
23
 
 
24
######################################################################
 
25
 
 
26
our ($VERSION);
 
27
BEGIN {
 
28
        $VERSION        = '2.905';
 
29
}
 
30
 
 
31
######################################################################
 
32
 
 
33
=head1 METHODS
 
34
 
 
35
Beyond the methods documented below, this class inherits methods from the
 
36
L<RDF::Query::Algebra> class.
 
37
 
 
38
=over 4
 
39
 
 
40
=cut
 
41
 
 
42
=item C<new ( $interval, $pattern, $time_triples )>
 
43
 
 
44
Returns a new TimeGraph structure.
 
45
 
 
46
=cut
 
47
 
 
48
sub new {
 
49
        my $class               = shift;
 
50
        my @data                = @_;   # $interval, $pattern, $triples
 
51
        return bless( [ 'TIME', @data ], $class );
 
52
}
 
53
 
 
54
=item C<< construct_args >>
 
55
 
 
56
Returns a list of arguments that, passed to this class' constructor,
 
57
will produce a clone of this algebra pattern.
 
58
 
 
59
=cut
 
60
 
 
61
sub construct_args {
 
62
        my $self        = shift;
 
63
        return ($self->interval, $self->pattern, $self->time_triples);
 
64
}
 
65
 
 
66
=item C<< interval >>
 
67
 
 
68
Returns the time interval node of the temporal graph expression.
 
69
 
 
70
=cut
 
71
 
 
72
sub interval {
 
73
        my $self        = shift;
 
74
        if (@_) {
 
75
                my $interval    = shift;
 
76
                $self->[1]              = $interval;
 
77
        }
 
78
        return $self->[1];
 
79
}
 
80
 
 
81
=item C<< pattern >>
 
82
 
 
83
Returns the graph pattern of the temporal graph expression.
 
84
 
 
85
=cut
 
86
 
 
87
sub pattern {
 
88
        my $self        = shift;
 
89
        return $self->[2];
 
90
}
 
91
 
 
92
=item C<< time_triples >>
 
93
 
 
94
Returns the triples describing the time interval of the temporal graph.
 
95
 
 
96
=cut
 
97
 
 
98
sub time_triples {
 
99
        my $self        = shift;
 
100
        return $self->[3];
 
101
}
 
102
 
 
103
=item C<< sse >>
 
104
 
 
105
Returns the SSE string for this algebra expression.
 
106
 
 
107
=cut
 
108
 
 
109
sub sse {
 
110
        my $self        = shift;
 
111
        my $context     = shift;
 
112
        my $prefix      = shift || '';
 
113
        my $indent      = $context->{indent};
 
114
        
 
115
        return sprintf(
 
116
                '(time\n${prefix}${indent}%s\n${prefix}${indent}%s\n${prefix}${indent}%s)',
 
117
                $self->interval->sse( $context, "${prefix}${indent}" ),
 
118
                $self->pattern->sse( $context, "${prefix}${indent}" ),
 
119
                $self->time_triples->sse( $context, "${prefix}${indent}" ),
 
120
        );
 
121
}
 
122
 
 
123
=item C<< as_sparql >>
 
124
 
 
125
Returns the SPARQL string for this algebra expression.
 
126
 
 
127
=cut
 
128
 
 
129
sub as_sparql {
 
130
        my $self        = shift;
 
131
        my $context     = shift;
 
132
        my $indent      = shift;
 
133
        my $nindent     = $indent . "\t";
 
134
        my $string      = sprintf(
 
135
                "TIME %s %s",
 
136
                $self->interval->as_sparql( $context, $indent ),
 
137
                $self->pattern->as_sparql( $context, $indent ),
 
138
        );
 
139
        return $string;
 
140
}
 
141
 
 
142
=item C<< type >>
 
143
 
 
144
Returns the type of this algebra expression.
 
145
 
 
146
=cut
 
147
 
 
148
sub type {
 
149
        return 'TIME';
 
150
}
 
151
 
 
152
=item C<< referenced_variables >>
 
153
 
 
154
Returns a list of the variable names used in this algebra expression.
 
155
 
 
156
=cut
 
157
 
 
158
sub referenced_variables {
 
159
        my $self        = shift;
 
160
        return RDF::Query::_uniq(
 
161
                map { $_->name } grep { $_->isa('RDF::Query::Node::Variable') } ($self->graph),
 
162
                $self->pattern->referenced_variables,
 
163
                $self->time_triples->referenced_variables,
 
164
        );
 
165
}
 
166
 
 
167
=item C<< potentially_bound >>
 
168
 
 
169
Returns a list of the variable names used in this algebra expression that will
 
170
bind values during execution.
 
171
 
 
172
=cut
 
173
 
 
174
sub potentially_bound {
 
175
        my $self        = shift;
 
176
        return RDF::Query::_uniq(
 
177
                map { $_->name } grep { $_->isa('RDF::Query::Node::Variable') } ($self->graph),
 
178
                $self->pattern->potentially_bound,
 
179
                $self->time_triples->potentially_bound,
 
180
        );
 
181
}
 
182
 
 
183
=item C<< definite_variables >>
 
184
 
 
185
Returns a list of the variable names that will be bound after evaluating this algebra expression.
 
186
 
 
187
=cut
 
188
 
 
189
sub definite_variables {
 
190
        my $self        = shift;
 
191
        return RDF::Query::_uniq(
 
192
                map { $_->name } grep { $_->isa('RDF::Query::Node::Variable') } ($self->graph),
 
193
                $self->pattern->definite_variables,
 
194
                $self->time_triples->definite_variables,
 
195
        );
 
196
}
 
197
 
 
198
1;
 
199
 
 
200
__END__
 
201
 
 
202
=back
 
203
 
 
204
=head1 AUTHOR
 
205
 
 
206
 Gregory Todd Williams <gwilliams@cpan.org>
 
207
 
 
208
=cut