line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# RDF::Trine::Iterator::Graph::Materialized |
2
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
RDF::Trine::Iterator::Graph::Materialized - Materialized graph class |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes RDF::Trine::Iterator::Graph::Materialized version 1.018 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use RDF::Trine::Iterator; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $iterator = RDF::Trine::Iterator::Graph::Materialized->new( \@data ); |
17
|
|
|
|
|
|
|
while (my $statement = $iterator->next) { |
18
|
|
|
|
|
|
|
# do something with $statement |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $iterator = RDF::Trine::Iterator::Graph->new( \&code ); |
22
|
|
|
|
|
|
|
my $miter = $iterator->materialize; |
23
|
|
|
|
|
|
|
while (my $statement = $miter->next) { |
24
|
|
|
|
|
|
|
# do something with $statement |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
$miter->reset; # start the iteration again |
27
|
|
|
|
|
|
|
while (my $statement = $miter->next) { |
28
|
|
|
|
|
|
|
# ... |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
34
|
|
|
|
|
|
|
L<RDF::Trine::Iterator::Graph> class. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=over 4 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package RDF::Trine::Iterator::Graph::Materialized; |
41
|
|
|
|
|
|
|
|
42
|
68
|
|
|
68
|
|
391
|
use strict; |
|
68
|
|
|
|
|
143
|
|
|
68
|
|
|
|
|
1661
|
|
43
|
68
|
|
|
68
|
|
310
|
use warnings; |
|
68
|
|
|
|
|
135
|
|
|
68
|
|
|
|
|
1458
|
|
44
|
68
|
|
|
68
|
|
313
|
no warnings 'redefine'; |
|
68
|
|
|
|
|
158
|
|
|
68
|
|
|
|
|
1705
|
|
45
|
68
|
|
|
68
|
|
342
|
use Data::Dumper; |
|
68
|
|
|
|
|
147
|
|
|
68
|
|
|
|
|
2875
|
|
46
|
68
|
|
|
68
|
|
365
|
use Scalar::Util qw(reftype); |
|
68
|
|
|
|
|
155
|
|
|
68
|
|
|
|
|
2475
|
|
47
|
68
|
|
|
68
|
|
361
|
use base qw(RDF::Trine::Iterator::Graph); |
|
68
|
|
|
|
|
158
|
|
|
68
|
|
|
|
|
5315
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our ($VERSION); |
50
|
|
|
|
|
|
|
BEGIN { |
51
|
68
|
|
|
68
|
|
18299
|
$VERSION = '1.018'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item C<< new ( \@results, %args ) >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns a new materialized graph interator. Results must be a reference to an |
57
|
|
|
|
|
|
|
array containing individual results. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
62
|
3
|
|
|
3
|
1
|
9
|
my $class = shift; |
63
|
3
|
|
50
|
|
|
12
|
my $data = shift || []; |
64
|
3
|
50
|
|
|
|
13
|
Carp::confess unless (scalar(@_) % 2 == 0); |
65
|
3
|
|
|
|
|
9
|
my %args = @_; |
66
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
16
|
if (reftype($data) eq 'CODE') { |
68
|
1
|
|
|
|
|
3
|
my @data; |
69
|
1
|
|
|
|
|
4
|
while (my $d = $data->()) { |
70
|
3
|
|
|
|
|
11
|
push(@data,$d); |
71
|
|
|
|
|
|
|
} |
72
|
1
|
|
|
|
|
3
|
$data = \@data; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
3
|
50
|
|
|
|
14
|
Carp::confess unless (reftype($data) eq 'ARRAY'); |
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
7
|
my $type = 'graph'; |
78
|
3
|
|
|
|
|
6
|
my $index = 0; |
79
|
|
|
|
|
|
|
my $stream = sub { |
80
|
6
|
|
|
6
|
|
14
|
my $data = $data->[ $index++ ]; |
81
|
6
|
100
|
|
|
|
17
|
unless (defined($data)) { |
82
|
1
|
|
|
|
|
3
|
$index = 0; |
83
|
|
|
|
|
|
|
} |
84
|
6
|
|
|
|
|
13
|
return $data; |
85
|
3
|
|
|
|
|
15
|
}; |
86
|
3
|
|
|
|
|
26
|
my $self = $class->SUPER::new( $stream, %args ); |
87
|
3
|
|
|
|
|
81
|
$self->{_data} = $data; |
88
|
3
|
|
|
|
|
10
|
$self->{_index} = \$index; |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
12
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item C<< reset >> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns the iterator to its starting position. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub reset { |
100
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
101
|
2
|
|
|
|
|
4
|
${ $self->{_index} } = 0; |
|
2
|
|
|
|
|
8
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item C<< next >> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the next item in the iterator. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub next { |
111
|
6
|
|
|
6
|
1
|
24
|
my $self = shift; |
112
|
6
|
|
|
|
|
24
|
my $data = $self->SUPER::next; |
113
|
6
|
100
|
|
|
|
28
|
unless (defined($data)) { |
114
|
1
|
|
|
|
|
3
|
$self->{_finished} = 0; |
115
|
|
|
|
|
|
|
} |
116
|
6
|
|
|
|
|
14
|
return $data; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item C<< length >> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the number of elements in the iterator. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub length { |
126
|
3
|
|
|
3
|
1
|
712
|
my $self = shift; |
127
|
3
|
|
|
|
|
5
|
return scalar(@{ $self->{ _data } }); |
|
3
|
|
|
|
|
14
|
|
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 BUGS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
137
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 AUTHOR |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 COPYRIGHT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Copyright (c) 2006-2012 Gregory Todd Williams. This |
146
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
147
|
|
|
|
|
|
|
the same terms as Perl itself. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |