| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 50 |  |  | 50 |  | 619 | use v5.14; | 
|  | 50 |  |  |  |  | 166 |  | 
| 2 | 50 |  |  | 50 |  | 267 | use warnings; | 
|  | 50 |  |  |  |  | 121 |  | 
|  | 50 |  |  |  |  | 2174 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | =head1 NAME | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | Attean::QuadModel - RDF model backed by a quad-store | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 VERSION | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | This document describes Attean::QuadModel version 0.032 | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | use v5.14; | 
| 15 |  |  |  |  |  |  | use Attean; | 
| 16 |  |  |  |  |  |  | my $model = Attean::QuadModel->new( store => $store ); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | The Attean::QuadModel class represents a model that is backed by a single | 
| 21 |  |  |  |  |  |  | L<Attean::API::QuadStore|Attean::API::Store> object. | 
| 22 |  |  |  |  |  |  | It conforms to the L<Attean::API::Model> role. | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | The Attean::QuadModel constructor requires one named argument: | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | =over 4 | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | =item store | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | A L<Attean::API::QuadStore|Attean::API::Store> object representing the backing | 
| 31 |  |  |  |  |  |  | quad-store. | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =back | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head1 METHODS | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =over 4 | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =cut | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | use Moo; | 
| 42 | 50 |  |  | 50 |  | 299 | use Scalar::Util qw(reftype); | 
|  | 50 |  |  |  |  | 99 |  | 
|  | 50 |  |  |  |  | 284 |  | 
| 43 | 50 |  |  | 50 |  | 19820 | use namespace::clean; | 
|  | 50 |  |  |  |  | 138 |  | 
|  | 50 |  |  |  |  | 2429 |  | 
| 44 | 50 |  |  | 50 |  | 342 |  | 
|  | 50 |  |  |  |  | 204 |  | 
|  | 50 |  |  |  |  | 432 |  | 
| 45 |  |  |  |  |  |  | has 'store'	=> ( | 
| 46 |  |  |  |  |  |  | is => 'ro', | 
| 47 |  |  |  |  |  |  | does => 'Attean::API::QuadStore', | 
| 48 |  |  |  |  |  |  | required => 1, | 
| 49 |  |  |  |  |  |  | handles	=> [qw(size count_quads count_quads_estimate get_graphs holds)], | 
| 50 |  |  |  |  |  |  | ); | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | =item C<< get_quads ( $subject, $predicate, $object, $graph ) >> | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | Returns an L<Attean::API::Iterator> for quads in the model that match the | 
| 55 |  |  |  |  |  |  | supplied C<< $subject >>, C<< $predicate >>, C<< $object >>, and C<< $graph >>. | 
| 56 |  |  |  |  |  |  | Any of these terms may be undefined or a L<Attean::API::Variable> object, in | 
| 57 |  |  |  |  |  |  | which case that term will be considered as a wildcard for the purposes of | 
| 58 |  |  |  |  |  |  | matching. | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | The returned iterator conforms to both L<Attean::API::Iterator> and | 
| 61 |  |  |  |  |  |  | L<Attean::API::QuadIterator>. | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =cut | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | my $self	= shift; | 
| 66 |  |  |  |  |  |  | my @nodes	= @_[0..3]; | 
| 67 | 89 |  |  | 89 | 1 | 1092 | foreach my $i (0..3) { | 
| 68 | 89 |  |  |  |  | 201 | my $t	= $nodes[$i]; | 
| 69 | 89 |  |  |  |  | 205 | if (not(ref($t)) or reftype($t) ne 'ARRAY') { | 
| 70 | 356 |  |  |  |  | 394 | $nodes[$i]	= [$t]; | 
| 71 | 356 | 100 | 100 |  |  | 1028 | } | 
| 72 | 345 |  |  |  |  | 638 | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | my @iters; | 
| 75 |  |  |  |  |  |  | foreach my $s (@{ $nodes[0] }) { | 
| 76 | 89 |  |  |  |  | 127 | foreach my $p (@{ $nodes[1] }) { | 
| 77 | 89 |  |  |  |  | 106 | foreach my $o (@{ $nodes[2] }) { | 
|  | 89 |  |  |  |  | 190 |  | 
| 78 | 89 |  |  |  |  | 114 | foreach my $g (@{ $nodes[3] }) { | 
|  | 89 |  |  |  |  | 489 |  | 
| 79 | 91 |  |  |  |  | 175 | push(@iters, $self->store->get_quads($s, $p, $o, $g)); | 
|  | 91 |  |  |  |  | 153 |  | 
| 80 | 91 |  |  |  |  | 107 | } | 
|  | 91 |  |  |  |  | 136 |  | 
| 81 | 95 |  |  |  |  | 2262 | } | 
| 82 |  |  |  |  |  |  | } | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | if (scalar(@iters) == 0) { | 
| 86 |  |  |  |  |  |  | return Attean::ListIterator->new(values => [], item_type => 'Attean::API::Quad'); | 
| 87 | 89 | 50 |  |  |  | 3091 | } elsif (scalar(@iters) == 1) { | 
|  |  | 100 |  |  |  |  |  | 
| 88 | 0 |  |  |  |  | 0 | return shift(@iters); | 
| 89 |  |  |  |  |  |  | } else { | 
| 90 | 87 |  |  |  |  | 384 | return Attean::IteratorSequence->new( iterators => \@iters, item_type => $iters[0]->item_type ); | 
| 91 |  |  |  |  |  |  | } | 
| 92 | 2 |  |  |  |  | 43 | } | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =item C<< plans_for_algebra( $algebra, $model, $active_graphs, $default_graphs ) >> | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | Delegates to the underlying store if the store consumes Attean::API::CostPlanner. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =cut | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | my $self	= shift; | 
| 101 |  |  |  |  |  |  | if ($self->store->does('Attean::API::CostPlanner')) { | 
| 102 |  |  |  |  |  |  | return $self->store->plans_for_algebra(@_); | 
| 103 | 130 |  |  | 130 | 1 | 222 | } | 
| 104 | 130 | 50 |  |  |  | 493 | return; | 
| 105 | 130 |  |  |  |  | 2016 | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 0 |  |  |  |  |  | =item C<< cost_for_plan( $plan ) >> | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | Delegates to the underlying store if the store consumes Attean::API::CostPlanner. | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =cut | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | my $self	= shift; | 
| 114 |  |  |  |  |  |  | if ($self->store->does('Attean::API::CostPlanner')) { | 
| 115 |  |  |  |  |  |  | return $self->store->cost_for_plan(@_); | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  | return; | 
| 118 |  |  |  |  |  |  | } | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | with 'Attean::API::Model'; | 
| 121 |  |  |  |  |  |  | with 'Attean::API::CostPlanner'; | 
| 122 |  |  |  |  |  |  | } | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | use Moo; | 
| 126 |  |  |  |  |  |  | extends 'Attean::QuadModel'; | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | has 'store'	=> ( | 
| 129 |  |  |  |  |  |  | is => 'ro', | 
| 130 | 50 |  |  | 50 |  | 45367 | does => 'Attean::API::MutableQuadStore', | 
|  | 50 |  |  |  |  | 110 |  | 
|  | 50 |  |  |  |  | 208 |  | 
| 131 |  |  |  |  |  |  | required => 1, | 
| 132 |  |  |  |  |  |  | handles	=> [qw(size count_quads count_quads_estimate add_quad remove_quad get_graphs create_graph drop_graph clear_graph add_iter)], | 
| 133 |  |  |  |  |  |  | ); | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | with 'Attean::API::MutableModel'; | 
| 136 |  |  |  |  |  |  | } | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | 1; | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =back | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =head1 BUGS | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | Please report any bugs or feature requests to through the GitHub web interface | 
| 146 |  |  |  |  |  |  | at L<https://github.com/kasei/attean/issues>. | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =head1 AUTHOR | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | Gregory Todd Williams  C<< <gwilliams@cpan.org> >> | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | Copyright (c) 2014--2022 Gregory Todd Williams. | 
| 159 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it under | 
| 160 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | =cut |