view release on metacpan or search on metacpan
lib/Attean/API/Parser.pm view on Meta::CPAN
use Types::Standard qw(CodeRef Bool);
use Moo::Role;
use Scalar::Util qw(blessed);
use namespace::clean;
has 'handler' => (is => 'rw', isa => CodeRef, default => sub { sub {} });
has 'lazy_iris' => (is => 'rw', isa => Bool, default => 0);
requires 'canonical_media_type'; # => (is => 'ro', isa => 'Str', init_arg => undef);
requires 'media_types'; # => (is => 'ro', isa => 'ArrayRef[Str]', init_arg => undef);
requires 'handled_type'; # => (is => 'ro', isa => 'Type::Tiny', init_arg => undef);
requires 'file_extensions'; # => (is => 'ro', isa => 'ArrayRef[Str]', init_arg => undef);
=item C<< new_iri( value => $value ) >>
Constructs and returns a new L<Attean::IRI> object, respecting the parser's
C<lazy_iris> attribute.
=cut
sub new_iri {
my $self = shift;
my %args;
lib/Attean/API/Parser.pm view on Meta::CPAN
}
package Attean::API::CDTBlankNodeMappingParser 0.035 {
use Types::Standard qw(HashRef ConsumerOf InstanceOf Maybe Bool);
use Scalar::Util qw(blessed);
use UUID::Tiny ':std';
use Data::Dumper;
use Moo::Role;
with 'Attean::API::Parser';
has 'blank_nodes' => (is => 'ro', isa => Maybe[HashRef[ConsumerOf['Attean::API::Blank']]]);
has 'parse_id' => (is => 'rw', default => sub { unpack('H*', create_uuid()) });
has 'enable_cdt_rewriting' => (is => 'rw', isa => Bool, default => 1);
foreach my $method (qw(parse_iter_from_io parse_iter_from_bytes parse_cb_from_io parse_cb_from_bytes)) {
around $method => sub {
my $orig = shift;
my $self = $_[0];
$self->parse_id(unpack('H*', create_uuid()));
my $term = $orig->(@_);
lib/Attean/API/Plan.pm view on Meta::CPAN
package Attean::API::Plan 0.035 {
use Scalar::Util qw(blessed);
use Types::Standard qw(ArrayRef CodeRef Str Object InstanceOf Bool Num Int);
use Moo::Role;
has 'cost' => (is => 'rw', isa => Int, predicate => 'has_cost');
has 'distinct' => (is => 'rw', isa => Bool, required => 1, default => 0);
has 'item_type' => (is => 'ro', isa => Str, required => 1, default => 'Attean::API::Result');
has 'in_scope_variables' => (is => 'ro', isa => ArrayRef[Str], required => 1);
has 'ordered' => (is => 'ro', isa => ArrayRef, required => 1, default => sub { [] });
requires 'impl';
requires 'plan_as_string';
=item C<< as_string >>
Returns a tree-structured string representation of this plan, including children.
=cut
lib/Attean/API/Plan.pm view on Meta::CPAN
package Attean::API::Plan::Join 0.035 {
use Types::Standard qw(CodeRef);
use Types::Standard qw(ArrayRef Str ConsumerOf Bool);
use Moo::Role;
with 'Attean::API::Plan', 'Attean::API::BinaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'join_variables' => (is => 'ro', isa => ArrayRef[Str], required => 1);
has 'anti' => (is => 'ro', isa => Bool, default => 0); # is this an anti-join
has 'left' => (is => 'ro', isa => Bool, default => 0); # is this a left, outer-join
# if this is a left, outer-join, this is the filter expression that acts as part of the join operation (see the SPARQL semantics for LeftJoin for more details)
has 'expression' => (is => 'ro', isa => ConsumerOf['Attean::API::Expression'], required => 0, default => sub { Attean::ValueExpression->new( value => Attean::Literal->true ) });
}
1;
__END__
lib/Attean/API/Query.pm view on Meta::CPAN
=item * L<Attean::API::NaryPropertyPath>
=cut
package Attean::API::NaryPropertyPath 0.035 {
use Types::Standard qw(ArrayRef ConsumerOf);
use Moo::Role;
# has 'children' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::PropertyPath']], required => 1);
requires 'separator';
sub as_string {
my $self = shift;
my @children = @{ $self->children };
if (scalar(@children) == 1) {
return $children[0]->as_string;
} else {
return sprintf("(%s)", join($self->separator, map { $_->as_string } @children));
}
}
lib/Attean/API/Serializer.pm view on Meta::CPAN
=cut
use Type::Tiny;
package Attean::API::Serializer 0.035 {
use Moo::Role;
use Carp qw(confess);
requires 'canonical_media_type'; # => (is => 'ro', isa => 'Str', init_arg => undef);
requires 'media_types'; # => (is => 'ro', isa => 'ArrayRef[Str]', init_arg => undef);
requires 'handled_type'; # => (is => 'ro', isa => 'Type::Tiny', init_arg => undef);
requires 'file_extensions'; # => (is => 'ro', isa => 'ArrayRef[Str]', init_arg => undef);
requires 'serialize_iter_to_io'; # serialize_iter_to_io($io, $iter)
requires 'serialize_iter_to_bytes'; # $data = serialize_iter_to_bytes($iter)
before 'serialize_iter_to_io' => sub {
my $self = shift;
my $io = shift || confess "No filehandle passed to serialize_iter_to_io";
my $iter = shift || confess "No iterator passed to serialize_iter_to_io";
};
lib/Attean/Algebra.pm view on Meta::CPAN
use Attean::API::Query;
package Attean::Algebra::Query 0.035 {
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(Bool ArrayRef HashRef ConsumerOf);
use Moo;
use namespace::clean;
has 'dataset' => (is => 'ro', isa => HashRef[ArrayRef[ConsumerOf['Attean::API::Term']]], default => sub { +{} });
has 'subquery' => (is => 'ro', isa => Bool, default => 0);
with 'Attean::API::UnionScopeVariables', 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
sub algebra_as_string {
my $self = shift;
my $name = $self->subquery ? 'SubQuery' : 'Query';
my %dataset = %{ $self->dataset };
my @default = @{ $dataset{ default } || [] };
lib/Attean/Algebra.pm view on Meta::CPAN
use namespace::clean;
sub in_scope_variables {
my $self = shift;
my ($child) = @{ $self->children };
my @vars = $child->in_scope_variables;
return Set::Scalar->new(@vars, map { $_->value } @{ $self->variables })->elements;
}
with 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1);
has 'expression' => (is => 'ro', isa => ConsumerOf['Attean::API::Expression'], required => 1);
sub algebra_as_string {
my $self = shift;
my @vars = map { $_->as_string } @{ $self->variables };
my $vars = '(' . join(', ', @vars) . ')';
return sprintf('Unfold { %s â %s }', $vars, $self->expression->as_string);
}
sub tree_attributes { return qw(variables expression) };
sub sparql_tokens {
lib/Attean/Algebra.pm view on Meta::CPAN
=cut
package Attean::Algebra::Project 0.035 {
use Types::Standard qw(ArrayRef ConsumerOf);
use Moo;
use namespace::clean;
with 'Attean::API::SPARQLQuerySerializable';
with 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1);
sub in_scope_variables {
my $self = shift;
my ($child) = @{ $self->children };
my $set = Set::Scalar->new( $child->in_scope_variables );
my $proj = Set::Scalar->new( map { $_->value } @{ $self->variables } );
return $set->intersection($proj)->elements;
}
sub algebra_as_string {
my $self = shift;
lib/Attean/Algebra.pm view on Meta::CPAN
package Attean::Algebra::OrderBy 0.035 {
use Moo;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef InstanceOf);
use namespace::clean;
with 'Attean::API::SPARQLQuerySerializable';
with 'Attean::API::UnionScopeVariables', 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'comparators' => (is => 'ro', isa => ArrayRef[InstanceOf['Attean::Algebra::Comparator']], required => 1);
sub tree_attributes { return qw(comparators) };
sub algebra_as_string {
my $self = shift;
return sprintf('Order { %s }', join(', ', map { $_->as_string } @{ $self->comparators }));
}
}
=item * L<Attean::Algebra::BGP>
lib/Attean/Algebra.pm view on Meta::CPAN
use Moo;
use Attean::RDF;
use Set::Scalar;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Algebra', 'Attean::API::NullaryQueryTree', 'Attean::API::CanonicalizingBindingSet';
has 'triples' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TriplePattern']], default => sub { [] });
sub in_scope_variables {
my $self = shift;
my $set = Set::Scalar->new();
foreach my $t (@{ $self->triples }) {
my @vars = $t->referenced_variables();
$set->insert(@vars);
}
return $set->elements;
}
lib/Attean/Algebra.pm view on Meta::CPAN
use Moo;
use Attean::API::Query;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::SPARQLQuerySerializable';
with 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'groupby' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Expression']]);
has 'aggregates' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::AggregateExpression']]);
sub BUILD {
my $self = shift;
foreach my $a (@{ $self->aggregates }) {
my $op = $a->operator;
if ($op eq 'RANK') {
if (scalar(@{ $self->aggregates }) > 1) {
die "Cannot use both aggregates and RANKing in grouping operator";
}
}
lib/Attean/Algebra.pm view on Meta::CPAN
package Attean::Algebra::NegatedPropertySet 0.035 {
use Moo;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::PropertyPath';
has 'predicates' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 0, default => sub { [] });
has 'reversed' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 0, default => sub { [] });
sub as_string {
my $self = shift;
my @forward = map { $_->ntriples_string } @{ $self->predicates };
my @rev = map { '^' . $_->ntriples_string } @{ $self->reversed };
return sprintf("!(%s)", join('|', @forward, @rev));
}
sub algebra_as_string { return 'NPS' }
sub tree_attributes { return qw(predicates reversed) };
sub as_sparql {
lib/Attean/Algebra.pm view on Meta::CPAN
package Attean::Algebra::Table 0.035 {
use Moo;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Algebra', 'Attean::API::NullaryQueryTree';
has variables => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']]);
has rows => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Result']]);
sub in_scope_variables {
my $self = shift;
return map { $_->value } @{ $self->variables };
}
sub tree_attributes { return qw(variables rows) };
sub algebra_as_string { return 'Table' }
sub sparql_tokens {
my $self = shift;
lib/Attean/Algebra.pm view on Meta::CPAN
package Attean::Algebra::Construct 0.035 {
use Moo;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::SPARQLQuerySerializable';
with 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'triples' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TriplePattern']]);
sub in_scope_variables { return qw(subject predicate object); }
sub tree_attributes { return; }
sub algebra_as_string {
my $self = shift;
my $triples = $self->triples;
return sprintf('Construct { %s }', join(' . ', map { $_->as_string } @$triples));
}
}
lib/Attean/Algebra.pm view on Meta::CPAN
package Attean::Algebra::Describe 0.035 {
use Moo;
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::SPARQLQuerySerializable';
with 'Attean::API::Algebra', 'Attean::API::UnaryQueryTree';
has 'terms' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TermOrVariable']]);
sub in_scope_variables { return qw(subject predicate object); }
sub tree_attributes { return; }
sub algebra_as_string { return 'Describe' }
}
=item * L<Attean::Algebra::Load>
=cut
lib/Attean/Algebra.pm view on Meta::CPAN
use Moo;
use Scalar::Util qw(blessed);
use AtteanX::SPARQL::Constants;
use AtteanX::SPARQL::Token;
use List::Util qw(all any);
use Types::Standard qw(HashRef ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Algebra', 'Attean::API::QueryTree';
has 'dataset' => (is => 'ro', isa => HashRef, default => sub { +{} });
has 'insert' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']], default => sub { [] });
has 'delete' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']], default => sub { [] });
sub in_scope_variables { return; }
sub tree_attributes { return; }
sub _op_type {
my $self = shift;
my $i = scalar(@{ $self->insert });
my $d = scalar(@{ $self->delete });
my $w = scalar(@{ $self->children });
my $ig = all { $_->is_ground } @{ $self->insert };
lib/Attean/CodeIterator.pm view on Meta::CPAN
use Moo;
use Type::Tiny::Role;
use Scalar::Util qw(blessed);
use Types::Standard qw(CodeRef ArrayRef);
use Role::Tiny ();
use namespace::clean;
with 'Attean::API::Iterator';
has generator => (is => 'ro', isa => CodeRef, required => 1);
has _buffer => (is => 'ro', isa => ArrayRef, init_arg => undef, default => sub { [] });
=item C<< next >>
Returns the iterator's next item, or undef upon reaching the end of iteration.
=cut
sub next {
my $self = shift;
my $buffer = $self->_buffer;
lib/Attean/Expression.pm view on Meta::CPAN
};
sub BUILD {
my ($self, $args) = @_;
state $type = Enum[qw(COUNT SUM MIN MAX AVG GROUP_CONCAT SAMPLE RANK CUSTOM FOLD)];
$type->assert_valid(shift->operator);
}
has 'custom_iri' => (is => 'ro', isa => Maybe[Str]);
has 'operator' => (is => 'ro', isa => UpperCaseStr, coerce => UpperCaseStr->coercion, required => 1);
has 'scalar_vars' => (is => 'ro', isa => HashRef, default => sub { +{} });
has 'distinct' => (is => 'ro', isa => Bool, default => 0);
has 'variable' => (is => 'ro', isa => ConsumerOf['Attean::API::Variable'], required => 1);
has 'order' => (is => 'ro', isa => ArrayRef, required => 1, default => sub { [] });
with 'Attean::API::AggregateExpression';
with 'Attean::API::SPARQLSerializable';
sub tree_attributes { return qw(operator scalar_vars variable) }
sub is_stable {
my $self = shift;
foreach my $expr (@{ $self->groups }, values %{ $self->aggregates }) {
return 0 unless ($expr->is_stable);
lib/Attean/IteratorSequence.pm view on Meta::CPAN
=cut
package Attean::IteratorSequence 0.035 {
use Moo;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Iterator';
has iterators => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Iterator']], default => sub { [] });
=item C<< next >>
Returns the iterator's next item, or undef upon reaching the end of iteration.
=cut
sub next {
my $self = shift;
my $list = $self->iterators;
lib/Attean/ListIterator.pm view on Meta::CPAN
=cut
package Attean::ListIterator 0.035 {
use Moo;
use Scalar::Util qw(blessed);
use Type::Tiny::Role;
use Types::Standard qw(ArrayRef Int);
use namespace::clean;
has values => (is => 'ro', isa => ArrayRef, required => 1);
has current => (is => 'rw', isa => Int, init_arg => undef, default => 0);
sub BUILD {
my $self = shift;
my $role = $self->item_type;
foreach my $item (@{ $self->values }) {
if (Role::Tiny->is_role($role)) {
die "ListIterator item <$item> is not a $role" unless (blessed($item) and $item->does($role));
}
}
lib/Attean/Plan.pm view on Meta::CPAN
=item * L<Attean::Plan::Construct>
=cut
package Attean::Plan::Construct 0.035 {
use Moo;
use List::Util qw(all);
use Types::Standard qw(Str ArrayRef ConsumerOf InstanceOf);
use namespace::clean;
has 'triples' => (is => 'ro', 'isa' => ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']], required => 1);
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
sub plan_as_string {
my $self = shift;
my $triples = $self->triples;
return sprintf('Construct { %s }', join(' . ', map { $_->as_string } @$triples));
}
sub BUILDARGS {
lib/Attean/Plan.pm view on Meta::CPAN
=cut
package Attean::Plan::Describe 0.035 {
use Moo;
use Attean::RDF;
use List::Util qw(all);
use Types::Standard qw(Str ArrayRef ConsumerOf InstanceOf);
use namespace::clean;
has 'graph' => (is => 'ro');
has 'terms' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::TermOrVariable']]);
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
sub plan_as_string {
my $self = shift;
my $terms = $self->terms;
return sprintf('Describe { %s }', join(' . ', map { $_->as_string } @$terms));
}
lib/Attean/Plan.pm view on Meta::CPAN
package Attean::Plan::Merge 0.035 {
use Moo;
use Scalar::Util qw(blessed);
use Types::Standard qw(Str ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::BinaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'variables' => (is => 'ro', isa => ArrayRef[Str], required => 1);
sub plan_as_string { return 'Merge' }
sub impl {
my $self = shift;
my $model = shift;
my @children = map { $_->impl($model) } @{ $self->children };
return sub {
die "Unimplemented";
};
lib/Attean/Plan.pm view on Meta::CPAN
use POSIX qw(ceil floor);
use Digest::SHA;
use Digest::MD5 qw(md5_hex);
use Scalar::Util qw(blessed looks_like_number);
use List::Util qw(uniq all);
use Types::Standard qw(ConsumerOf ArrayRef InstanceOf HashRef);
use namespace::clean;
with 'MooX::Log::Any';
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
has 'expressions' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Expression']], required => 1);
has 'active_graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 1);
sub plan_as_string {
my $self = shift;
my @strings = map { sprintf('?%s â %s', $_, $self->expressions->{$_}->as_string) } keys %{ $self->expressions };
return sprintf('Extend { %s }', join(', ', @strings));
}
sub tree_attributes { return qw(variable expression) };
sub BUILDARGS {
my $class = shift;
lib/Attean/Plan.pm view on Meta::CPAN
Evaluates a sub-plan and returns projected results by only keeping a fixed-set
of variable bindings in each result.
=cut
package Attean::Plan::Project 0.035 {
use Moo;
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
use Types::Standard qw(ArrayRef ConsumerOf);
has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1);
sub BUILDARGS {
my $class = shift;
my %args = @_;
my @vars = map { $_->value } @{ $args{variables} };
if (exists $args{in_scope_variables}) {
Carp::confess "in_scope_variables is computed automatically, and must not be specified in the $class constructor";
}
$args{in_scope_variables} = \@vars;
lib/Attean/Plan.pm view on Meta::CPAN
package Attean::Plan::OrderBy 0.035 {
use Moo;
use Types::Standard qw(HashRef ArrayRef InstanceOf Bool Str);
use Scalar::Util qw(blessed);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'variables' => (is => 'ro', isa => ArrayRef[Str], required => 1);
has 'ascending' => (is => 'ro', isa => HashRef[Bool], required => 1);
sub plan_as_string {
my $self = shift;
my @vars = @{ $self->variables };
my $ascending = $self->ascending;
my @strings = map { sprintf('%s(?%s)', ($ascending->{$_} ? 'ASC' : 'DESC'), $_) } @vars;
return sprintf('Order { %s }', join(', ', @strings));
}
sub sort_rows {
lib/Attean/Plan.pm view on Meta::CPAN
=cut
package Attean::Plan::Table 0.035 {
use Moo;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree';
has variables => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']]);
has rows => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Result']]);
sub tree_attributes { return qw(variables rows) };
sub plan_as_string {
my $self = shift;
my $level = shift;
my $indent = ' ' x ($level + 1);
my $vars = join(', ', map { "?$_" } @{ $self->in_scope_variables });
my $s = "Table (" . $vars . ")";
foreach my $row (@{ $self->rows }) {
$s .= "\n-${indent} " . $row->as_string;
lib/Attean/Plan.pm view on Meta::CPAN
=cut
package Attean::Plan::Exists 0.035 {
use Moo;
use Types::Standard qw(ArrayRef ConsumerOf);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has variables => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']]);
has rows => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Result']]);
sub tree_attributes { return qw(variables rows) };
sub plan_as_string { return 'Exists' }
sub impl {
my $self = shift;
my $model = shift;
my ($impl) = map { $_->impl($model) } @{ $self->children };
return sub {
my $iter = $impl->();
lib/Attean/Plan.pm view on Meta::CPAN
use I18N::LangTags;
use POSIX qw(ceil floor);
use Digest::SHA;
use Digest::MD5 qw(md5_hex);
use Scalar::Util qw(blessed);
use List::Util qw(uniq);
use Types::Standard qw(ConsumerOf InstanceOf HashRef ArrayRef);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree';
has 'aggregates' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Expression']], required => 1);
has 'groups' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Expression']], required => 1);
has 'active_graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 1);
sub plan_as_string {
my $self = shift;
my @astrings = map { sprintf('?%s â %s', $_, $self->aggregates->{$_}->as_string) } keys %{ $self->aggregates };
my @gstrings = map { sprintf('%s', $_->as_string) } @{ $self->groups };
return sprintf('Aggregate { %s } Groups { %s }', join(', ', @astrings), join(', ', @gstrings));
}
sub tree_attributes { return qw(aggregates groups) };
sub BUILD {
lib/Attean/Plan.pm view on Meta::CPAN
package Attean::Plan::Clear 0.035 {
use Moo;
use Scalar::Util qw(blessed);
use Types::Standard qw(ConsumerOf ArrayRef);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::NullaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Term']]);
sub plan_as_string {
my $self = shift;
my $level = shift;
my $indent = ' ' x (1+$level);
my $s = sprintf("Clear { %d graphs }", scalar(@{ $self->graphs }));
foreach my $g (@{ $self->graphs }) {
my $name = $g->as_sparql;
chomp($name);
$s .= "\n-${indent} $name";
lib/Attean/Plan.pm view on Meta::CPAN
package Attean::Plan::Drop 0.035 {
use Moo;
use Scalar::Util qw(blessed);
use Types::Standard qw(ConsumerOf ArrayRef);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::NullaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Term']]);
sub plan_as_string {
my $self = shift;
my $level = shift;
my $indent = ' ' x (1+$level);
my $s = sprintf("Drop { %d graphs }", scalar(@{ $self->graphs }));
foreach my $g (@{ $self->graphs }) {
$s .= "\n-${indent} " . $g->as_sparql;
}
return $s;
lib/Attean/Plan.pm view on Meta::CPAN
package Attean::Plan::TripleTemplateToModelQuadMethod 0.035 {
use Moo;
use Scalar::Util qw(blessed);
use Types::Standard qw(ConsumerOf Str ArrayRef HashRef);
use namespace::clean;
with 'Attean::API::Plan', 'Attean::API::UnaryQueryTree';
with 'Attean::API::UnionScopeVariablesPlan';
has 'order' => (is => 'ro', isa => ArrayRef[Str], required => 1);
has 'patterns' => (is => 'ro', isa => HashRef[ArrayRef[ConsumerOf['Attean::API::TripleOrQuadPattern']]], required => 1);
has 'graph' => (is => 'ro', isa => ConsumerOf['Attean::API::Term']);
sub plan_as_string {
my $self = shift;
my $level = shift;
my $indent = ' ' x (1+$level);
my $s = sprintf("Template-to-Model { Default graph: %s }", $self->graph->as_string);
foreach my $method (@{ $self->order }) {
my $pattern = $self->patterns->{ $method };
$s .= "\n-${indent} Method: ${method}";
lib/Attean/Plan.pm view on Meta::CPAN
use Digest::SHA;
use Digest::MD5 qw(md5_hex);
use Scalar::Util qw(blessed looks_like_number);
use List::Util qw(uniq all);
use Types::Standard qw(ConsumerOf ArrayRef InstanceOf HashRef);
use namespace::clean;
with 'MooX::Log::Any';
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1);
has 'expression' => (is => 'ro', isa => ConsumerOf['Attean::API::Expression'], required => 1);
has 'active_graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 1);
sub plan_as_string {
my $self = shift;
my @vars = map { $_->as_string } @{ $self->variables };
my $vars = '(' . join(', ', @vars) . ')';
return sprintf('Unfold { %s â %s }', $vars, $self->expression->as_string);
}
sub tree_attributes { return qw(variable expression) };
sub BUILDARGS {
lib/Attean/Result.pm view on Meta::CPAN
use namespace::clean;
with 'Attean::API::Result';
=item C<< bindings >>
Returns the HASH reference containing the variable bindings for this result.
=cut
has 'bindings' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::TermOrTriple']], default => sub { +{} });
# sub BUILD {
# my $self = shift;
# my $args = shift;
# use Data::Dumper;
# my $b = $args->{bindings};
# my $keys = [keys %$b];
# if (scalar(@$keys) == 2) {
# Carp::cluck 'NEW RESULT CONSTRUCTED with variables ' . Dumper($keys);
# }
lib/AtteanX/Parser/NTuples.pm view on Meta::CPAN
package AtteanX::Parser::NTuples 0.035 {
use utf8;
use Moo;
use Attean;
use Carp qw(carp);
use Encode qw(decode);
use Types::Standard qw(Bool HashRef ArrayRef HashRef Str Maybe InstanceOf ConsumerOf);
use namespace::clean;
has 'blank_nodes' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Blank']], predicate => 'has_blank_nodes_map', default => sub { +{} });
=item C<< parse_term_from_bytes( $bytes ) >>
Parses the given C<< $bytes >> and returns a corresponding L<Attean::API::Term> object.
=cut
sub parse_term_from_bytes {
my $self = shift;
unless (ref($self)) {
lib/AtteanX/Parser/RDFXML.pm view on Meta::CPAN
Returns a list of file extensions that may be parsed with the parser.
=cut
sub file_extensions { return [qw(rdf xrdf)] }
with 'Attean::API::TripleParser', 'Attean::API::AbbreviatingParser', 'Attean::API::Parser';
with 'Attean::API::PushParser';
has 'bnode_prefix' => (is => 'ro', isa => Str, default => '');
has 'blank_nodes' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Blank']], default => sub { +{} });
=item C<< parse_cb_from_io( $fh ) >>
Calls the C<< $parser->handler >> function once for each
L<Attean::API::Binding> object that result from parsing
the data read from the L<IO::Handle> object C<< $fh >>.
=cut
sub parse_cb_from_io {
lib/AtteanX/Parser/SPARQL.pm view on Meta::CPAN
use AtteanX::Parser::SPARQLLex;
use AtteanX::SPARQL::Constants;
use Types::Standard qw(ConsumerOf InstanceOf HashRef ArrayRef Bool Str Int);
use Scalar::Util qw(blessed looks_like_number reftype refaddr);
######################################################################
use Moo;
has 'lexer' => (is => 'rw', isa => InstanceOf['AtteanX::Parser::SPARQLLex::Iterator']);
has 'args' => (is => 'ro', isa => HashRef);
has 'build' => (is => 'rw', isa => HashRef);
has 'update' => (is => 'rw', isa => Bool);
has 'baseURI' => (is => 'rw');
has '_stack' => (is => 'rw', isa => ArrayRef);
has 'filters' => (is => 'rw', isa => ArrayRef);
has 'counter' => (is => 'rw', isa => Int, default => 0);
has '_pattern_container_stack' => (is => 'rw', isa => ArrayRef);
has 'blank_nodes' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Blank']], predicate => 'has_blank_nodes_map', default => sub { +{} });
sub file_extensions { return [qw(rq ru)] }
sub canonical_media_type { return "application/sparql-query" }
sub media_types {
return [qw(application/sparql-query application/sparql-update)];
}
sub handled_type {
lib/AtteanX/Parser/SPARQLLex.pm view on Meta::CPAN
use Moo;
use Attean;
use Encode;
use Encode qw(decode);
use Types::Standard qw(ArrayRef);
use namespace::clean;
sub canonical_media_type { return "application/x-sparql-query-tokens" }
# these pass through to the lexer iterator
has extend => ( is => 'ro', isa => ArrayRef, default => sub { [] } );
sub media_types {
return [qw(application/x-sparql-query-tokens)];
}
sub handled_type {
state $ITEM_TYPE = Type::Tiny::Role->new(role => 'AtteanX::SPARQL::Token');
return $ITEM_TYPE;
}
lib/AtteanX/Parser/SPARQLLex.pm view on Meta::CPAN
use utf8;
use Moo;
use Attean;
use Encode;
use Encode qw(decode);
use AtteanX::SPARQL::Token;
use AtteanX::SPARQL::Constants;
use Types::Standard qw(FileHandle Ref Str Int ArrayRef HashRef ConsumerOf InstanceOf);
use namespace::clean;
has lookahead_methods => ( is => 'ro', isa => HashRef, default => sub { +{} } );
has lookahead_tokens => ( is => 'ro', isa => HashRef, default => sub { +{} } );
has extend => ( is => 'ro', isa => ArrayRef, default => sub { [] } );
has token_buffer => ( is => 'ro', isa => ArrayRef, default => sub { [] } );
with 'AtteanX::API::Lexer';
my $r_ECHAR = qr/\\([tbnrf\\"'])/o;
my $r_STRING_LITERAL1 = qr/'(([^\x{27}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*'/o;
my $r_STRING_LITERAL2 = qr/"(([^\x{22}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*"/o;
my $r_STRING_LITERAL_LONG1 = qr/'''(('|'')?([^'\\]|${r_ECHAR}))*'''/o;
my $r_STRING_LITERAL_LONG2 = qr/"""(("|"")?([^"\\]|${r_ECHAR}))*"""/o;
my $r_LANGTAG = qr/@[a-zA-Z]+(-[a-zA-Z0-9]+)*/o;
my $r_IRI_REF = qr/<([^<>"{}|^`\\\x{00}-\x{20}])*>/o;
lib/AtteanX/Parser/Trig.pm view on Meta::CPAN
sub canonical_media_type { return "text/trig" }
sub media_types {
return [qw(text/trig)];
}
sub file_extensions { return [qw(trig)] }
has 'canonicalize' => (is => 'rw', isa => Bool, default => 0);
has '_map' => (is => 'ro', isa => HashRef[Str], default => sub { +{} });
with 'Attean::API::MixedStatementParser';
################################################################################
# this is the entry point where we change the rules from Turtle to Trig
sub _parse {
my $self = shift;
my $l = shift;
$l->check_for_bom;
lib/AtteanX/Parser/Turtle.pm view on Meta::CPAN
sub canonical_media_type { return "text/turtle" }
sub media_types {
return [qw(application/x-turtle application/turtle text/turtle)];
}
sub file_extensions { return [qw(ttl)] }
has 'canonicalize' => (is => 'rw', isa => Bool, default => 0);
has '_map' => (is => 'ro', isa => HashRef[Str], default => sub { +{} });
=item C<< has_namespaces >>
Returns true if the parser has a namespace map, false otherwise.
=cut
has 'namespaces' => (is => 'rw', isa => Maybe[NamespaceMap], predicate => 'has_namespaces');
has 'blank_nodes' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Blank']], predicate => 'has_blank_nodes_map', default => sub { +{} });
has '_stack' => (
is => 'ro',
isa => ArrayRef,
default => sub { [] },
init_arg => undef,
);
with 'Attean::API::TripleParser';
with 'Attean::API::AbbreviatingParser';
with 'Attean::API::PushParser';
lib/AtteanX/Parser/Turtle/Token.pm view on Meta::CPAN
use Sub::Install;
use namespace::clean;
our $VERSION = 0.035;
has type => ( is => 'ro', );
has start_line => ( is => 'ro', );
has start_column => ( is => 'ro', );
has line => ( is => 'ro', );
has column => ( is => 'ro', );
has args => ( is => 'ro', isa => ArrayRef[Str]);
=item C<< value >>
Returns the token value.
=cut
sub value {
my $self = shift;
my $args = $self->args;
lib/AtteanX/SPARQL/Token.pm view on Meta::CPAN
use List::Util qw(mesh);
use Sub::Util qw(set_subname);
use AtteanX::SPARQL::Constants;
use namespace::clean;
has type => ( is => 'ro', );
has start_line => ( is => 'ro', );
has start_column => ( is => 'ro', );
has line => ( is => 'ro', );
has column => ( is => 'ro', );
has args => ( is => 'ro', isa => ArrayRef[Str]);
extends 'AtteanX::Parser::Turtle::Token';
=item C<< value >>
Returns the token value.
=cut
sub value {
lib/AtteanX/Serializer/RDFXML.pm view on Meta::CPAN
use Encode qw(encode);
use Scalar::Util qw(blessed);
use Attean::API::Iterator;
use Attean::ListIterator;
use List::Util qw(any);
use namespace::clean;
has 'canonical_media_type' => (is => 'ro', isa => Str, init_arg => undef, default => 'application/rdf+xml');
has '_rev' => (is => 'rw', isa => HashRef, init_arg => undef, default => sub { +{} });
has 'scoped_namespaces' => (is => 'rw', init_arg => undef);
has 'blank_nodes' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Blank']], default => sub { +{} });
=item C<< file_extensions >>
Returns a list of file extensions associated with the serialized format.
=cut
sub file_extensions { return [qw(rdf xml)] }
=item C<< media_types >>
lib/AtteanX/Store/Memory.pm view on Meta::CPAN
=over 4
=item C<< new () >>
Returns a new memory-backed storage object.
=cut
has _size => (is => 'rw', isa => Int, init_arg => undef, default => 0);
has statements => (is => 'rw', isa => ArrayRef[ConsumerOf['Attean::API::Quad']], init_arg => undef, default => sub { [] });
has subject => (is => 'ro', isa => HashRef[InstanceOf['Set::Scalar']], init_arg => undef, default => sub { +{} });
has predicate => (is => 'ro', isa => HashRef[InstanceOf['Set::Scalar']], init_arg => undef, default => sub { +{} });
has object => (is => 'ro', isa => HashRef[InstanceOf['Set::Scalar']], init_arg => undef, default => sub { +{} });
has graph => (is => 'ro', isa => HashRef[InstanceOf['Set::Scalar']], init_arg => undef, default => sub { +{} });
has graph_nodes => (is => 'rw', isa => HashRef[ConsumerOf['Attean::API::IRI']], init_arg => undef, default => sub { +{} });
has hash => (is => 'rw', isa => InstanceOf['Digest::SHA'], default => sub { Digest::SHA->new });
has mtime => (is => 'rw', isa => Int, default => sub { return time() });
=item C<< size >>
Returns the number of quads in the store.
=cut