File Coverage

blib/lib/AtteanX/Model/SPARQL.pm
Criterion Covered Total %
statement 14 15 93.3
branch n/a
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 19 22 86.3


line stmt bran cond sub pod time code
1             package AtteanX::Model::SPARQL;
2              
3 1     1   876201 use v5.14;
  1         2  
4 1     1   3 use warnings;
  1         1  
  1         38  
5              
6             our $AUTHORITY = 'cpan:KJETILK';
7             our $VERSION = '0.010';
8              
9 1     1   3 use Moo;
  1         4  
  1         4  
10 1     1   180 use Types::Standard qw(InstanceOf);
  1         1  
  1         5  
11 1     1   275 use namespace::clean;
  1         1  
  1         4  
12              
13             has 'store' => (
14             is => 'ro',
15             isa => InstanceOf['AtteanX::Store::SPARQL'],
16             required => 1,
17             handles => { size => 'size' ,
18             get_quads => 'get_triples',
19             count_quads => 'count_triples',
20             get_sparql => 'get_sparql',
21             plans_for_algebra => 'plans_for_algebra'
22             }
23             );
24              
25              
26             with 'Attean::API::Model', 'Attean::API::CostPlanner';
27              
28             sub cost_for_plan {
29             my $self = shift;
30             my $plan = shift;
31             my $planner = shift;
32              
33             # TODO: check if the store does something
34             if ($plan->isa('AtteanX::Plan::SPARQLBGP')) {
35             # BGPs should have a cost proportional to the number of triple patterns,
36             # but be much more costly if they contain a cartesian product.
37             if ($plan->children_are_variable_connected) {
38             return 10 * scalar(@{ $plan->children });
39             } else {
40             return 100 * scalar(@{ $plan->children });
41             }
42             }
43             return;
44             }
45              
46             sub get_graphs {
47 0     0 0   return Attean::ListIterator->new();
48             }
49              
50             1;
51              
52             __END__
53              
54             =pod
55              
56             =encoding utf-8
57              
58             =head1 NAME
59              
60             AtteanX::Model::SPARQL - Attean SPARQL Model
61              
62             =head1 SYNOPSIS
63              
64             my $store = Attean->get_store('SPARQL')->new(endpoint_url => $url);
65             my $model = AtteanX::Model::SPARQL->new( store => $store );
66              
67             =head1 DESCRIPTION
68              
69             This model is in practice a thin wrapper around the underlying SPARQL
70             store, that adds facilities only to allow quering and planning with
71             quad semantics.
72              
73             It consumes L<Attean::API::Model> and L<Attean::API::CostPlanner> and
74             adds no new methods or attributes.
75              
76             =head1 OTHER DETAILS
77              
78             For author, copyright and other details, see L<AtteanX::Store::SPARQL>.
79              
80              
81             =cut
82