| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
AtteanX::Store::SimpleTripleStore - SimpleTripleStore, unindexed, in-memory RDF store |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This document describes AtteanX::Store::SimpleTripleStore version 0.033 |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use AtteanX::Store::SimpleTripleStore; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
AtteanX::Store::SimpleTripleStore provides an in-memory triple-store. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
5140
|
use v5.14; |
|
|
2
|
|
|
|
|
11
|
|
|
20
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
62
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Moo; |
|
23
|
2
|
|
|
2
|
|
10
|
use Type::Tiny::Role; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
11
|
|
|
24
|
2
|
|
|
2
|
|
618
|
use Types::Standard qw(Int ArrayRef HashRef ConsumerOf InstanceOf); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
66
|
|
|
25
|
2
|
|
|
2
|
|
8
|
use Encode; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
20
|
|
|
26
|
2
|
|
|
2
|
|
1719
|
use Set::Scalar; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
132
|
|
|
27
|
2
|
|
|
2
|
|
11
|
use Digest::SHA; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
79
|
|
|
28
|
2
|
|
|
2
|
|
12
|
use List::Util qw(first); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
61
|
|
|
29
|
2
|
|
|
2
|
|
9
|
use Scalar::Util qw(refaddr reftype blessed); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
118
|
|
|
30
|
2
|
|
|
2
|
|
12
|
use namespace::clean; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
80
|
|
|
31
|
2
|
|
|
2
|
|
10
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
14
|
|
|
32
|
|
|
|
|
|
|
with 'Attean::API::MutableTripleStore'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my @pos_names = Attean::API::Quad->variables; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Beyond the methods documented below, this class inherits methods from the |
|
39
|
|
|
|
|
|
|
L<Attean::API::QuadStore> class. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item C<< new ( triples => \@triples ) >> |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Returns a new memory-backed storage object. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has triples => (is => 'rw', isa => ArrayRef[ConsumerOf['Attean::API::Triple']], default => sub { [] }); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item C<< get_triples ( $subject, $predicate, $object ) >> |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns a stream object of all statements matching the specified subject, |
|
54
|
|
|
|
|
|
|
predicate and objects. Any of the arguments may be undef to match any value. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
my @nodes = @_; |
|
60
|
|
|
|
|
|
|
my %bound; |
|
61
|
|
|
|
|
|
|
foreach my $pos (0 .. 2) { |
|
62
|
|
|
|
|
|
|
my $n = $nodes[ $pos ]; |
|
63
|
|
|
|
|
|
|
if (blessed($n) and $n->does('Attean::API::Variable')) { |
|
64
|
|
|
|
|
|
|
$n = undef; |
|
65
|
|
|
|
|
|
|
$nodes[$pos] = undef; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
if (blessed($n)) { |
|
68
|
|
|
|
|
|
|
$bound{ $pos_names[$pos] } = $n; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $triples = $self->triples; |
|
73
|
|
|
|
|
|
|
my $iter = Attean::ListIterator->new( values => $triples, item_type => 'Attean::API::Triple' ); |
|
74
|
|
|
|
|
|
|
return $iter->grep(sub { |
|
75
|
|
|
|
|
|
|
my $q = shift; |
|
76
|
|
|
|
|
|
|
foreach my $key (keys %bound) { |
|
77
|
|
|
|
|
|
|
my $term = $q->$key(); |
|
78
|
|
|
|
|
|
|
unless ($term->equals( $bound{$key} )) { |
|
79
|
|
|
|
|
|
|
return 0; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
return 1; |
|
83
|
|
|
|
|
|
|
}); |
|
84
|
|
|
|
|
|
|
return $iter; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C<< add_triple( $t ) >> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $self = shift; |
|
92
|
|
|
|
|
|
|
my $t = shift; |
|
93
|
|
|
|
|
|
|
push(@{ $self->triples }, $t); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<< remove_triple( $t ) >> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $self = shift; |
|
101
|
|
|
|
|
|
|
my $t = shift; |
|
102
|
|
|
|
|
|
|
my @remove; |
|
103
|
|
|
|
|
|
|
my $triples = $self->triples; |
|
104
|
1
|
|
|
1
|
1
|
25
|
foreach my $i (0 .. $#{ $triples }) { |
|
105
|
1
|
|
|
|
|
2
|
my $u = $triples->[$i]; |
|
106
|
1
|
|
|
|
|
2
|
if ($u->as_string eq $t->as_string) { |
|
107
|
1
|
|
|
|
|
18
|
push(@remove, $i); |
|
108
|
1
|
|
|
|
|
7
|
} |
|
|
1
|
|
|
|
|
5
|
|
|
109
|
4
|
|
|
|
|
7
|
} |
|
110
|
4
|
100
|
|
|
|
10
|
while (scalar(@remove)) { |
|
111
|
1
|
|
|
|
|
3
|
my $i = pop(@remove); |
|
112
|
|
|
|
|
|
|
splice(@$triples, $i, 1, ()); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
1
|
|
|
|
|
15
|
} |
|
115
|
1
|
|
|
|
|
4
|
} |
|
116
|
1
|
|
|
|
|
14
|
|
|
117
|
|
|
|
|
|
|
1; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 BUGS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
|
125
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf2/issues>. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. This |
|
134
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
|
135
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |