/usr/share/perl5/RDF/Trine/Model/Union.pm is in librdf-trine-perl 1.014-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 | # RDF::Trine::Model::Union
# -----------------------------------------------------------------------------
=head1 NAME
RDF::Trine::Model::Union - Union models for joining multiple stores together
=head1 VERSION
This document describes RDF::Trine::Model::Union version 1.014
=head1 METHODS
Beyond the methods documented below, this class inherits methods from the
L<RDF::Trine::Model> class.
=over 4
=cut
package RDF::Trine::Model::Union;
use strict;
use warnings;
no warnings 'redefine';
use base qw(RDF::Trine::Model);
use Scalar::Util qw(blessed);
use RDF::Trine::Node;
use RDF::Trine::Store;
our ($VERSION);
BEGIN {
$VERSION = '1.014';
}
################################################################################
=item C<< new ( @stores ) >>
Returns a new union-model over the list of supplied rdf stores.
=cut
sub new {
my $class = shift;
my @stores = @_;
my $self = bless({ stores => \@stores }, $class);
}
=item C<< add_statement ( $statement [, $context] ) >>
Adds the specified C<$statement> to the first rdf store.
=cut
sub add_statement {
my $self = shift;
my @iterators;
my ($store) = $self->_stores;
$store->add_statement( @_ );
}
=item C<< remove_statement ( $statement [, $context]) >>
Removes the specified C<$statement> from all of the rdf stores.
=cut
sub remove_statement {
my $self = shift;
foreach my $store ($self->_stores) {
$store->remove_statement( @_ );
}
}
=item C<< remove_statements ( $subject, $predicate, $object [, $context]) >>
Removes all statements matching the supplied C<$statement> pattern from all of the rdf stores.
=cut
sub remove_statements {
my $self = shift;
foreach my $store ($self->_stores) {
$store->remove_statements( @_ );
}
}
=item C<< count_statements ($subject, $predicate, $object) >>
Returns a count of all the statements matching the specified subject,
predicate and objects. Any of the arguments may be undef to match any value.
=cut
sub count_statements {
my $self = shift;
my $count = 0;
foreach my $store ($self->_stores) {
$count += $store->count_statements( @_ );
}
return $count;
}
=item C<< get_statements ($subject, $predicate, $object [, $context] ) >>
Returns a stream object of all statements matching the specified subject,
predicate and objects from all of the rdf stores. Any of the arguments may be
undef to match any value.
=cut
sub get_statements {
my $self = shift;
my @iterators;
foreach my $store ($self->_stores) {
my $i = $store->get_statements( @_ );
push(@iterators, $i);
# my @data;
# while (my $d = $i->next) {
# warn '++++++++++++++++++ ' . $d->as_string;
#
# }
#
# my $m = $i->materialize;
# push(@iterators, $m);
}
while (@iterators > 1) {
my $i = shift(@iterators);
my $j = shift(@iterators);
unshift(@iterators, $i->concat( $j ));
}
return $iterators[0]->unique;
}
# =item C<< get_pattern ( $bgp [, $context] ) >>
#
# Returns a stream object of all bindings matching the specified graph pattern.
#
# =cut
#
# sub get_pattern {
# my $self = shift;
# my @iterators;
# foreach my $store ($self->_stores) {
# push(@iterators, $store->get_pattern( @_ ));
# }
# while (@iterators > 1) {
# my $i = shift(@iterators);
# my $j = shift(@iterators);
# unshift(@iterators, $i->concat( $j ));
# }
# return $iterators[0];
# }
sub _stores {
my $self = shift;
return @{ $self->{stores} };
}
sub _store {
my $self = shift;
return;
}
1;
__END__
=back
=head1 BUGS
Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/perlrdf/issues>.
=head1 AUTHOR
Gregory Todd Williams C<< <gwilliams@cpan.org> >>
=head1 COPYRIGHT
Copyright (c) 2006-2012 Gregory Todd Williams. This
program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
|