/usr/share/perl5/Attean/API/Store.pm is in libattean-perl 0.017-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | use v5.14;
use warnings;
=head1 NAME
Attean::API::Store - Triple/quad store role
=head1 VERSION
This document describes Attean::Store version 0.017
=head1 DESCRIPTION
The Attean::Store role is an empty role that more specialized roles conform to:
=over 4
=item * L<Attean::API::TripleStore>
=item * L<Attean::API::MutableTripleStore>
=item * L<Attean::API::ETagCacheableTripleStore>
=item * L<Attean::API::TimeCacheableTripleStore>
=item * L<Attean::API::QuadStore>
=item * L<Attean::API::MutableQuadStore>
=item * L<Attean::API::ETagCacheableQuadStore>
=item * L<Attean::API::TimeCacheableQuadStore>
=back
=cut
package Attean::API::Store 0.017 {
use Moo::Role;
}
package Attean::API::TripleStore 0.017 {
use Moo::Role;
use Scalar::Util qw(blessed);
use namespace::clean;
with 'Attean::API::Store';
requires 'get_triples';
before 'get_triples' => sub {
if (scalar(@_) == 2 and blessed($_[1]) and not($_[1]->does('Attean::API::TermOrVariable'))) {
my $type = ref($_[0]);
die "get_triples called with a single $type argument, but expecting a list of terms/variables";
}
};
sub count_triples {
my $self = shift;
my $iter = $self->get_triples(@_);
my $count = 0;
while (my $r = $iter->next) {
$count++;
}
return $count;
}
sub count_triples_estimate {
my $self = shift;
return $self->count_triples(@_);
}
sub size {
my $self = shift;
return $self->count_triples();
}
}
package Attean::API::MutableTripleStore 0.017 {
use Moo::Role;
with 'Attean::API::TripleStore';
requires 'add_triple';
requires 'remove_triple';
before 'add_triple' => sub {
my $self = shift;
my $quad = shift;
unless ($quad->is_ground) {
die "Cannot add a non-ground triple (with variables) to a model";
}
};
}
package Attean::API::ETagCacheableTripleStore 0.017 {
use Moo::Role;
with 'Attean::API::TripleStore';
requires 'etag_value_for_triples';
}
package Attean::API::TimeCacheableTripleStore 0.017 {
use Moo::Role;
with 'Attean::API::TripleStore';
requires 'mtime_for_triples';
}
package Attean::API::QuadStore 0.017 {
use Moo::Role;
use Scalar::Util qw(blessed);
use namespace::clean;
with 'Attean::API::Store';
requires 'get_quads';
before 'get_quads' => sub {
if (scalar(@_) == 2 and blessed($_[1]) and not($_[1]->does('Attean::API::TermOrVariable'))) {
my $type = ref($_[0]);
die "get_quads called with a single $type argument, but expecting a list of terms/variables";
}
};
sub count_quads {
my $self = shift;
my $iter = $self->get_quads(@_);
my $count = 0;
while (my $r = $iter->next) {
$count++;
}
return $count;
}
sub count_quads_estimate {
my $self = shift;
return $self->count_quads(@_);
}
sub get_graphs {
my $self = shift;
my $iter = $self->get_quads(@_);
my %graphs;
while (my $r = $iter->next) {
my $g = $r->graph;
$graphs{ $g->as_string }++;
}
return Attean::ListIterator->new( values => [map { Attean::IRI->new($_) } keys %graphs], item_type => 'Attean::API::Term' );
}
sub size {
my $self = shift;
return $self->count_quads();
}
}
package Attean::API::MutableQuadStore 0.017 {
use Moo::Role;
use Type::Tiny::Role;
with 'Attean::API::QuadStore';
requires 'add_quad';
requires 'remove_quad';
requires 'create_graph';
requires 'drop_graph';
requires 'clear_graph';
before 'add_quad' => sub {
my $self = shift;
my $quad = shift;
unless ($quad->is_ground) {
die "Cannot add a non-ground quad (with variables) to a store";
}
};
sub add_iter {
my $self = shift;
my $iter = shift;
my $type = $iter->item_type;
use Data::Dumper;
die "Iterator type $type isn't quads" unless (Role::Tiny::does_role($type, 'Attean::API::Quad'));
while (my $q = $iter->next) {
$self->add_quad($q);
}
}
}
package Attean::API::ETagCacheableQuadStore 0.017 {
use Moo::Role;
with 'Attean::API::QuadStore';
requires 'etag_value_for_quads';
}
package Attean::API::TimeCacheableQuadStore 0.017 {
use Moo::Role;
with 'Attean::API::QuadStore';
requires 'mtime_for_quads';
}
package Attean::API::BulkUpdatableStore 0.017 {
use Moo::Role;
requires 'begin_bulk_updates';
requires 'end_bulk_updates';
}
1;
__END__
=head1 BUGS
Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/attean/issues>.
=head1 SEE ALSO
L<http://www.perlrdf.org/>
=head1 AUTHOR
Gregory Todd Williams C<< <gwilliams@cpan.org> >>
=head1 COPYRIGHT
Copyright (c) 2014--2016 Gregory Todd Williams.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|