AtteanX-Store-DBI-0.002/ 000755 000765 000024 00000000000 13765312550 014643 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/inc/ 000755 000765 000024 00000000000 13765312545 015420 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/SIGNATURE 000644 000765 000024 00000006234 13765312550 016134 0 ustar 00greg staff 000000 000000 This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.81.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
% cpansign -v
It will check each file's integrity, as well as the signature's
validity. If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SHA1 25e4d6942df15b2bed4ad0a8ad7fd001ecdd4924 Changes
SHA1 77dd35c1247483f080d885f9dab85436494709e4 MANIFEST
SHA1 d86aa4c01b118c8f49456252b8619a1fd47865fc META.yml
SHA1 7123645c1dc9aa69d0b8762ebc6e64f3f51afbc1 Makefile.PL
SHA1 05411a9b4c484a973260a56aacdaad48e4be6914 README.md
SHA1 0195dc3a3cae16a81231087f5e8b6e52364de6d5 bin/attean_dbi
SHA1 c3f8f9f2a209f80b7ca3c8af3a6b1b7b408ad620 inc/Module/Install.pm
SHA1 d001b4b9a48395a8c4134b234a0e1789138427c5 inc/Module/Install/AuthorTests.pm
SHA1 de30b539a326675c42e6ad360fddb05902d621be inc/Module/Install/Base.pm
SHA1 81fffeca82bcd7100d8435b139f0780fcc5cdf9c inc/Module/Install/Can.pm
SHA1 470809a1dbe03e197e74dde79c6af40b5f7f9b26 inc/Module/Install/DOAPChangeSets.pm
SHA1 b4dd9cb3cf0cb60390c575bd3405e2297d4a0b1a inc/Module/Install/Fetch.pm
SHA1 b84cf97b12f8e5ef37bea54e33ddce32dff804d1 inc/Module/Install/Makefile.pm
SHA1 0d9fd69718198fcd1560214c4f23fcaa44f8395e inc/Module/Install/Metadata.pm
SHA1 78f307119470d0c85d7d6496e76fc95cb939b462 inc/Module/Install/Scripts.pm
SHA1 a4ed3f5a3e2f117b8f453771b9e52e8c0f5fcfbc inc/Module/Install/Share.pm
SHA1 99b8179fbd9e05422b161cf91abe198744188064 inc/Module/Install/Win32.pm
SHA1 6a91e14bbecc64e9c8e2261dfa4b360641d152e4 inc/Module/Install/WriteAll.pm
SHA1 60ea9dd220cc035417ab40f4f407aa5519d1a53c lib/AtteanX/Store/DBI.pm
SHA1 19894ead40e6a0c6c527a133dacdeeac7d56f4af lib/Test/AtteanX/Store/DBI.pm
SHA1 de7a9c395b6e24abb2f42f50ea1b3bc6538af23d meta/changes.ttl
SHA1 d1003e1dc2641a248f2b923c19fd2925968e1f40 share/database-schema/mysql-create.sql
SHA1 af09f59eb466d0f248d22c5536222d29279211f6 share/database-schema/mysql-drop.sql
SHA1 b95f5a6d45b5cb15b667aee3d32d68fee33e4d80 share/database-schema/postgresql-create.sql
SHA1 456f4864d61d51a7fe4fa507ce644d5404861949 share/database-schema/postgresql-drop.sql
SHA1 313ad5717ff2de8118df7560789dbc803edd66d4 share/database-schema/sqlite-create.sql
SHA1 af09f59eb466d0f248d22c5536222d29279211f6 share/database-schema/sqlite-drop.sql
SHA1 316dba855401e75fb790031321c4637f1da37f8e t/store-dbi-mysql.t
SHA1 924bbcf89dc2c1475e144a6686e6e5ace10364ca t/store-dbi-postgresql.t
SHA1 b9c9e0a7cacd4fa6f6a11cfefd00c0b74e2cc17f t/store-dbi-sqlite.t
SHA1 8260840c52125be2050b6993fd5d957acc1b18b7 xt/dawg11-mysql.t
SHA1 6d7a1fee15d71e3e93fb8e873eb193e6f4bdb840 xt/dawg11-postgresql.t
SHA1 dde9e19ac0a5c64168cbcc4ea03aa9ed0c7ba548 xt/dawg11-sqlite.t
SHA1 61bf86179ce63f1148d1fb8c7a4c57bee395f7fc xt/pod-coverage.t
SHA1 6387af7a5fde0747be5bc9ad2ec15ca9759bd95a xt/pod.t
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iEYEARECAAYFAl/VlWUACgkQhPK6VMqoyC1BBwCgpVDmj5LNLENpwrL7rYUTZ4qy
+x8AoLRJmKQNvyqCTLKnvPUXT6fz3c79
=TBgi
-----END PGP SIGNATURE-----
AtteanX-Store-DBI-0.002/bin/ 000755 000765 000024 00000000000 13765312545 015417 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/Changes 000644 000765 000024 00000000742 13765312543 016143 0 ustar 00greg staff 000000 000000 AtteanX::Store::DBI
===================
Created: 2016-03-14
Home page:
Bug tracker:
0.002 2020-12-12
- (Update) Add DBD::SQLite as a test prereq (#6).
- (Update) Remove Math::Cartesian::Product from prereq list (#4).
- (Update) Remove mistakenly added LICENSE file (#5).
- (Update) Update copyright years (#3).
0.001 2020-12-02
- (Addition) Initial release.
AtteanX-Store-DBI-0.002/MANIFEST 000644 000765 000024 00000001731 13765312545 016002 0 ustar 00greg staff 000000 000000 bin/attean_dbi
Changes
inc/Module/Install.pm
inc/Module/Install/AuthorTests.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/DOAPChangeSets.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Scripts.pm
inc/Module/Install/Share.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/AtteanX/Store/DBI.pm
lib/Test/AtteanX/Store/DBI.pm
Makefile.PL
MANIFEST This list of files
META.yml
meta/changes.ttl
README.md
share/database-schema/mysql-create.sql
share/database-schema/mysql-drop.sql
share/database-schema/postgresql-create.sql
share/database-schema/postgresql-drop.sql
share/database-schema/sqlite-create.sql
share/database-schema/sqlite-drop.sql
t/store-dbi-mysql.t
t/store-dbi-postgresql.t
t/store-dbi-sqlite.t
xt/dawg11-mysql.t
xt/dawg11-postgresql.t
xt/dawg11-sqlite.t
xt/pod-coverage.t
xt/pod.t
SIGNATURE Public-key signature (added by MakeMaker)
AtteanX-Store-DBI-0.002/meta/ 000755 000765 000024 00000000000 13765312545 015575 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/t/ 000755 000765 000024 00000000000 13765312545 015112 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/xt/ 000755 000765 000024 00000000000 13765312545 015302 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/PaxHeader/README.md 000644 000765 000024 00000000036 13761617237 020100 x ustar 00greg staff 000000 000000 30 mtime=1606885023.242905658
AtteanX-Store-DBI-0.002/README.md 000644 000765 000024 00000000626 13761617237 016134 0 ustar 00greg staff 000000 000000 AtteanX::Store::DBI
===================
An Attean quadstore implementation based on relational databases.
Getting Help
------------
A group of perl-rdf developers are usually available in the
[perlrdf IRC channel](irc://irc.perl.org/perlrdf) where we're happy to answer
questions.
You can also:
* Create a new [GitHub Issue](https://github.com/kasei/atteanx-store-dbi/issues) or submit a pull request
AtteanX-Store-DBI-0.002/META.yml 000644 000765 000024 00000002262 13765312543 016120 0 ustar 00greg staff 000000 000000 ---
abstract: 'Database quad-store'
author:
- 'Gregory Todd Williams C<< >>'
- 'Gregory Todd Williams '
build_requires:
DBD::SQLite: 0
ExtUtils::MakeMaker: 6.59
HTTP::Message::PSGI: 0
Test::Exception: 0
Test::LWP::UserAgent: 0
Test::Modern: 0
Test::Moose: 0
Test::More: 0.88
Test::Roo: 0
configure_requires:
ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.19'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: AtteanX-Store-DBI
no_index:
directory:
- inc
- share
- t
- xt
requires:
Attean: 0.013
Cache::LRU: 0
DBI: 0
DBIx::MultiStatementDo: 0
File::ShareDir: 0
File::Slurp: 0
List::MoreUtils: 0
Moo: 1.006
MooX::Log::Any: 0
Try::Tiny: 0
Type::Tiny: 0
namespace::clean: 0
perl: 5.14.0
resources:
IRC: irc://irc.perl.org/#perlrdf
bugtracker: https://github.com/kasei/atteanx-store-dbi/issues
homepage: https://metacpan.org/release/AtteanX-Store-DBI/
license: http://dev.perl.org/licenses/
repository: https://github.com/kasei/atteanx-store-dbi/
version: '0.002'
AtteanX-Store-DBI-0.002/lib/ 000755 000765 000024 00000000000 13765312545 015415 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/PaxHeader/Makefile.PL 000644 000765 000024 00000000036 13764534140 020565 x ustar 00greg staff 000000 000000 30 mtime=1607645280.153539003
AtteanX-Store-DBI-0.002/Makefile.PL 000644 000765 000024 00000002550 13764534140 016617 0 ustar 00greg staff 000000 000000 use strict;
use warnings;
use inc::Module::Install;
name 'AtteanX-Store-DBI';
all_from 'lib/AtteanX/Store/DBI.pm';
author 'Gregory Todd Williams ';
license 'perl';
test_requires 'Test::Exception' => 0;
test_requires 'Test::Modern' => 0;
test_requires 'Test::Moose' => 0;
test_requires 'Test::More' => 0.88;
test_requires 'Test::Roo' => 0;
test_requires 'HTTP::Message::PSGI' => 0;
test_requires 'Test::LWP::UserAgent' => 0;
test_requires 'DBD::SQLite' => 0;
perl_version '5.014';
requires 'Attean' => 0.013;
requires 'List::MoreUtils' => 0;
requires 'Moo' => 1.006000;
requires 'MooX::Log::Any' => 0;
requires 'namespace::clean' => 0;
requires 'Try::Tiny' => 0;
requires 'Type::Tiny' => 0;
requires 'File::Slurp' => 0;
requires 'File::ShareDir' => 0;
requires 'DBI' => 0;
requires 'Cache::LRU' => 0;
requires 'DBI' => 0;
requires 'DBIx::MultiStatementDo' => 0;
resources(
'homepage' => "https://metacpan.org/release/AtteanX-Store-DBI/",
'repository' => "https://github.com/kasei/atteanx-store-dbi/",
'bugtracker' => "https://github.com/kasei/atteanx-store-dbi/issues",
'IRC' => "irc://irc.perl.org/#perlrdf",
);
author_tests('xt');
install_share;
install_script glob('bin/attean_*');
write_doap_changes "meta/changes.ttl", "Changes", "turtle";
sign;
WriteAll;
AtteanX-Store-DBI-0.002/share/ 000755 000765 000024 00000000000 13765312545 015751 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/share/database-schema/ 000755 000765 000024 00000000000 13765312545 020753 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/share/database-schema/mysql-create.sql 000644 000765 000024 00000001602 13133671135 024071 0 ustar 00greg staff 000000 000000 CREATE TABLE IF NOT EXISTS attean_version (
attean_version VARCHAR(16),
store_version VARCHAR(16),
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE TABLE IF NOT EXISTS term (
term_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`type` ENUM('iri', 'literal', 'blank'),
datatype_id BIGINT REFERENCES term(term_id),
value LONGTEXT NOT NULL,
language TEXT,
INDEX (`type`, datatype_id, value(64), language(64))
) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE TABLE IF NOT EXISTS quad (
subject BIGINT UNSIGNED NOT NULL REFERENCES term,
predicate BIGINT UNSIGNED NOT NULL REFERENCES term,
object BIGINT UNSIGNED NOT NULL REFERENCES term,
graph BIGINT UNSIGNED NOT NULL REFERENCES term,
PRIMARY KEY (subject, predicate, object, graph),
KEY (predicate,object,graph,subject),
INDEX (graph)
);
AtteanX-Store-DBI-0.002/share/database-schema/postgresql-drop.sql 000644 000765 000024 00000000134 13133671713 024631 0 ustar 00greg staff 000000 000000 DROP TABLE quad;
DROP TABLE term;
DROP TYPE TERM_TYPE;
DROP TABLE IF EXISTS attean_version;
AtteanX-Store-DBI-0.002/share/database-schema/sqlite-create.sql 000644 000765 000024 00000001440 13133667440 024231 0 ustar 00greg staff 000000 000000 CREATE TABLE IF NOT EXISTS attean_version (
attean_version VARCHAR(16),
store_version VARCHAR(16),
created DATETIME DEFAULT CURRENT_TIMESTAMP,
updated DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS term (
term_id INTEGER PRIMARY KEY,
type CHAR(7),
datatype_id BIGINT REFERENCES term(term_id),
value LONGTEXT NOT NULL,
language TEXT
);
CREATE UNIQUE INDEX term_idx ON term (type, datatype_id, language, value);
CREATE TABLE IF NOT EXISTS quad (
subject BIGINT NOT NULL REFERENCES term,
predicate BIGINT NOT NULL REFERENCES term,
object BIGINT NOT NULL REFERENCES term,
graph BIGINT NOT NULL REFERENCES term,
PRIMARY KEY (subject, predicate, object, graph)
);
CREATE INDEX quad_pogs_idx ON quad (predicate,object,graph,subject);
CREATE INDEX quad_g ON quad (graph);
AtteanX-Store-DBI-0.002/share/database-schema/mysql-drop.sql 000644 000765 000024 00000000106 13133671055 023571 0 ustar 00greg staff 000000 000000 DROP TABLE quad;
DROP TABLE term;
DROP TABLE IF EXISTS attean_version; AtteanX-Store-DBI-0.002/share/database-schema/sqlite-drop.sql 000644 000765 000024 00000000106 13133672072 023725 0 ustar 00greg staff 000000 000000 DROP TABLE quad;
DROP TABLE term;
DROP TABLE IF EXISTS attean_version; AtteanX-Store-DBI-0.002/share/database-schema/postgresql-create.sql 000644 000765 000024 00000001502 13133667350 025132 0 ustar 00greg staff 000000 000000 CREATE TABLE IF NOT EXISTS attean_version (
attean_version VARCHAR(16),
store_version VARCHAR(16),
created TIMESTAMP DEFAULT NOW(),
updated TIMESTAMP DEFAULT NOW()
);
CREATE TYPE TERM_TYPE AS ENUM ('iri', 'literal', 'blank');
CREATE TABLE IF NOT EXISTS term (
term_id SERIAL PRIMARY KEY,
type TERM_TYPE,
datatype_id BIGINT REFERENCES term(term_id),
value TEXT NOT NULL,
language TEXT,
UNIQUE (datatype_id, value, language)
);
CREATE TABLE IF NOT EXISTS quad (
subject BIGINT NOT NULL REFERENCES term,
predicate BIGINT NOT NULL REFERENCES term,
object BIGINT NOT NULL REFERENCES term,
graph BIGINT NOT NULL REFERENCES term,
PRIMARY KEY (subject, predicate, object, graph)
);
CREATE INDEX IF NOT EXISTS quad_graph_idx ON quad (graph);
CREATE INDEX IF NOT EXISTS quad_pogs_idx ON quad (predicate,object,graph,subject);
AtteanX-Store-DBI-0.002/lib/Test/ 000755 000765 000024 00000000000 13765312545 016334 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/lib/AtteanX/ 000755 000765 000024 00000000000 13765312545 016761 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/lib/AtteanX/Store/ 000755 000765 000024 00000000000 13765312545 020055 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/lib/AtteanX/Store/PaxHeader/DBI.pm 000644 000765 000024 00000000036 13765312374 022761 x ustar 00greg staff 000000 000000 30 mtime=1607832828.761632447
AtteanX-Store-DBI-0.002/lib/AtteanX/Store/DBI.pm 000644 000765 000024 00000066067 13765312374 021030 0 ustar 00greg staff 000000 000000 =head1 NAME
AtteanX::Store::DBI - Database quad-store
=head1 VERSION
This document describes AtteanX::Store::DBI version 0.002
=head1 SYNOPSIS
use Attean;
my $store = Attean->get_store('DBI')->new( dbh => $dbh );
=head1 DESCRIPTION
AtteanX::Store::DBI provides a quad-store backed by a relational database.
=head1 ATTRIBUTES
=over 4
=item C<< dbh >>
=back
=cut
use utf8;
use v5.14;
use warnings;
package AtteanX::Store::DBI {
our $VERSION = '0.002';
use Moo;
use DBI;
use Attean 0.013;
use DBI::Const::GetInfoType;
use Type::Tiny::Role;
use Types::Standard qw(Int Str ArrayRef HashRef ConsumerOf InstanceOf);
use Encode;
use Cache::LRU;
use Set::Scalar;
use DBIx::MultiStatementDo;
use List::MoreUtils qw(zip);
use List::Util qw(any all first);
use File::ShareDir qw(dist_dir dist_file);
use File::Slurp;
use Scalar::Util qw(refaddr reftype blessed);
use namespace::clean;
with 'Attean::API::MutableQuadStore';
with 'Attean::API::BulkUpdatableStore';
with 'Attean::API::QuadStore';
with 'Attean::API::CostPlanner';
my @pos_names = Attean::API::Quad->variables;
=head1 ROLES
This class consumes L,
L, and L.
=head1 METHODS
=over 4
=item C<< new ( dbh => $dbh ) >>
Returns a new quad-store object backed by the database referenced by the
supplied database handle.
=cut
has dbh => (is => 'ro', isa => InstanceOf['DBI::db'], required => 1);
has _i2t_cache => (is => 'ro', default => sub { Cache::LRU->new( size => 256 ) });
has _t2i_cache => (is => 'ro', default => sub { Cache::LRU->new( size => 256 ) });
=item C<< init() >>
Create the tables and indexes required for using the database as a quadstore.
=cut
sub init {
my $self = shift;
my $dbh = $self->dbh;
my $batch = DBIx::MultiStatementDo->new( dbh => $dbh );
my $file = $self->create_schema_file or die 'No schema files available for store initialization';
my $sql = read_file($file);
$batch->do($sql);
}
=item C<< temporary_store() >>
Returns a temporary (in-memory, SQLite) store.
=cut
sub temporary_store {
my $class = shift;
my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:', '', '');
my $store = $class->new(dbh => $dbh);
$store->init();
return $store;
}
sub _last_insert_id {
my $self = shift;
my $table = shift;
my $dbh = $self->dbh;
return $dbh->last_insert_id(undef, undef, $table, undef);
}
sub _get_term {
my $self = shift;
my $id = shift;
if (my $term = $self->_i2t_cache->get($id)) {
return $term;
}
my $sth = $self->dbh->prepare('SELECT term.type, term.value, dtterm.value AS datatype, term.language FROM term LEFT JOIN term dtterm ON (term.datatype_id = dtterm.term_id) WHERE term.term_id = ?');
$sth->execute($id);
my $row = $sth->fetchrow_hashref;
my $type = $row->{type};
my $term;
my $value = $row->{value};
my $datatype = $row->{datatype};
my $lang = $row->{language};
if ($type eq 'iri') {
$term = Attean::IRI->new( value => $value );
} elsif ($type eq 'blank') {
$term = Attean::Blank->new( value => $value );
} elsif ($type eq 'literal') {
my %args = (value => $value, datatype => Attean::IRI->new(value => $datatype));
if ($lang) {
$args{language} = $lang;
}
$term = Attean::Literal->new( %args );
}
if ($term) {
$self->_i2t_cache->set($id => $term);
return $term;
}
Carp::confess "Failed to load term values for bad ID " . Dumper($id);
}
sub _get_term_id {
my $self = shift;
my $term = shift;
if (my $id = $self->_t2i_cache->get($term->as_string)) {
return $id;
}
my $dbh = $self->dbh;
my $tid;
if ($term->does('Attean::API::IRI')) {
my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?');
my $value = $term->value;
$sth->execute('iri', $value);
($tid) = $sth->fetchrow_array;
} elsif ($term->does('Attean::API::Blank')) {
my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?');
my $value = $term->value;
$sth->execute('blank', $value);
($tid) = $sth->fetchrow_array;
} elsif ($term->does('Attean::API::Literal')) {
my $dtid = $self->_get_or_create_term_id($term->datatype);
my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ? AND datatype_id = ? AND language = ?');
my $value = $term->value;
my $lang = $term->language;
$sth->execute('literal', $value, $dtid, $lang);
($tid) = $sth->fetchrow_array;
}
if (defined($tid)) {
$self->_t2i_cache->set($term->as_string => $tid);
return $tid;
}
return;
}
sub _get_or_create_term_id {
my $self = shift;
my $term = shift;
if (my $id = $self->_t2i_cache->get($term->as_string)) {
return $id;
}
my $dbh = $self->dbh;
my $tid;
my $insert_term_sth = $dbh->prepare('INSERT INTO term (type, value, datatype_id, language) VALUES (?, ?, ?, ?)');
if ($term->does('Attean::API::IRI')) {
my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?');
my $value = $term->value;
$sth->execute('iri', $value);
($tid) = $sth->fetchrow_array;
unless (defined($tid)) {
$insert_term_sth->execute('iri', $value, undef, undef);
$tid = $self->_last_insert_id('term');
}
} elsif ($term->does('Attean::API::Blank')) {
my $sth = $dbh->prepare('SELECT term_id FROM term WHERE type = ? AND value = ?');
my $value = $term->value;
$sth->execute('blank', $value);
($tid) = $sth->fetchrow_array;
unless (defined($tid)) {
$insert_term_sth->execute('blank', $value, undef, undef);
$tid = $self->_last_insert_id('term');
}
} elsif ($term->does('Attean::API::Literal')) {
my $dtid = $self->_get_or_create_term_id($term->datatype);
my $sql = 'SELECT term_id FROM term WHERE type = ? AND value = ? AND datatype_id = ?';
my $value = $term->value;
my @bind = ('literal', $value, $dtid);
my $lang = $term->language;
if ($lang) {
$sql .= ' AND language = ?';
push(@bind, $lang);
}
my $sth = $dbh->prepare($sql);
$sth->execute(@bind);
($tid) = $sth->fetchrow_array;
unless (defined($tid)) {
$insert_term_sth->execute('literal', $value, $dtid, $lang);
$tid = $self->_last_insert_id('term');
}
} else {
die "Failed to get ID for term: " . $term->as_string;
}
if (defined($tid)) {
$self->_t2i_cache->set($term->as_string => $tid);
return $tid;
}
die;
}
=item C<< get_quads ( $subject, $predicate, $object, $graph ) >>
Returns a stream object of all statements matching the specified subject,
predicate and objects. Any of the arguments may be undef to match any value,
or an ARRAY reference of terms that are allowable in the respective quad
position.
=cut
sub get_quads {
my $self = shift;
my @nodes = map { ref($_) eq 'ARRAY' ? $_ : [$_] } @_;
my @where;
my @bind;
foreach my $i (0 .. 3) {
my $name = $pos_names[$i];
my $terms = $nodes[$i];
if (defined($terms)) {
unless (scalar(@$terms) == 1 and not defined($terms->[0])) {
unless (any { $_->does('Attean::API::Variable') } @$terms) {
my @ids = map { $self->_get_term_id($_) } @$terms;
unless (scalar(@ids)) {
return Attean::ListIterator->new( values => [], item_type => 'Attean::API::Quad' );
}
push(@where, "$name IN (" . join(', ', ('?') x scalar(@ids)) . ")");
push(@bind, @ids);
}
}
}
}
my $sql = 'SELECT subject, predicate, object, graph FROM quad';
if (scalar(@where)) {
$sql .= ' WHERE ' . join(' AND ', @where);
}
my $sth = $self->dbh->prepare($sql);
$sth->execute(@bind);
my $ok = 1;
my $sub = sub {
return unless ($ok);
if (my $row = $sth->fetchrow_arrayref) {
my @terms = map { $self->_get_term($_) } @$row;
my $quad = Attean::Quad->new(zip @pos_names, @terms);
return $quad;
}
$ok = 0;
return;
};
my $iter = Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Quad' );
return $iter;
}
=item C<< count_quads ( $subject, $predicate, $object, $graph ) >>
Returns the count of all statements matching the specified subject,
predicate and objects. Any of the arguments may be undef to match any value,
or an ARRAY reference of terms that are allowable in the respective quad
position.
=cut
sub count_quads {
my $self = shift;
my @nodes = map { ref($_) eq 'ARRAY' ? $_ : [$_] } @_;
my @where;
my @bind;
foreach my $i (0 .. 3) {
my $name = $pos_names[$i];
my $terms = $nodes[$i];
if (defined($terms)) {
unless (scalar(@$terms) == 1 and not defined($terms->[0])) {
unless (any { $_->does('Attean::API::Variable') } @$terms) {
my @ids = map { $self->_get_term_id($_) } @$terms;
return 0 unless scalar(@ids);
push(@where, "$name IN (" . join(', ', ('?') x scalar(@ids)) . ")");
push(@bind, @ids);
}
}
}
}
my $sql = 'SELECT COUNT(*) FROM quad';
if (scalar(@where)) {
$sql .= ' WHERE ' . join(' AND ', @where);
}
my $sth = $self->dbh->prepare($sql);
$sth->execute(@bind);
my ($count) = $sth->fetchrow_array;
return $count;
}
=item C<< get_graphs >>
Returns an iterator over the Attean::API::Term objects comprising
the set of graphs of the stored quads.
=cut
sub get_graphs {
my $self = shift;
my $sth = $self->dbh->prepare('SELECT DISTINCT value FROM quad JOIN term ON (quad.graph = term.term_id)');
$sth->execute;
my $sub = sub {
my $row = $sth->fetchrow_arrayref;
return unless ref($row);
my ($value) = @$row;
return Attean::IRI->new(value => $value);
};
return Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Term' );
}
# -----------------------------------------------------------------------------
=item C<< add_quad ( $quad ) >>
Adds the specified C<$quad> to the underlying model.
=cut
sub add_quad {
my $self = shift;
my $st = shift;
my @ids = map { $self->_get_or_create_term_id($_) } $st->values;
if (any { not defined($_) } @ids) {
return;
}
my $type = $self->database_type;
my @bind = @ids;
my $sql = 'INSERT INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)';
if ($type eq 'sqlite') {
$sql = 'INSERT OR IGNORE INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)';
} elsif ($type eq 'mysql') {
$sql = 'INSERT IGNORE INTO quad (subject, predicate, object, graph) VALUES (?, ?, ?, ?)';
} elsif ($type eq 'postgresql') {
$sql = 'INSERT INTO quad (subject, predicate, object, graph) SELECT ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?)';
push(@bind, @ids);
}
my $sth = $self->dbh->prepare($sql);
$sth->execute(@bind);
return;
}
=item C<< remove_quad ( $statement ) >>
Removes the specified C<$statement> from the underlying model.
=cut
sub remove_quad {
my $self = shift;
my $st = shift;
my @ids = map { $self->_get_term_id($_) } $st->values;
unless (scalar(@ids) == 4) {
return;
}
unless (all { defined($_) } @ids) {
return;
}
my $sth = $self->dbh->prepare('DELETE FROM quad WHERE subject = ? AND predicate = ? AND object = ? AND graph = ?');
$sth->execute(@ids);
return;
}
=item C<< create_graph( $graph ) >>
This is a no-op function for the memory quad-store.
=cut
sub create_graph {
# no-op on a quad-store
}
=item C<< drop_graph( $graph ) >>
Removes all quads with the given C<< $graph >>.
=cut
sub drop_graph {
my $self = shift;
return $self->clear_graph(@_);
}
=item C<< clear_graph( $graph ) >>
Removes all quads with the given C<< $graph >>.
=cut
sub clear_graph {
my $self = shift;
my $graph = shift;
my $gid = $self->_get_term_id($graph);
return unless defined($gid);
my $sth = $self->dbh->prepare('DELETE FROM quad WHERE graph = ?');
$sth->execute($gid);
return;
}
=item C<< begin_transaction >>
Begin a database transaction.
=cut
sub begin_transaction {
# warn 'begin transaction';
my $self = shift;
$self->dbh->begin_work;
}
=item C<< abort_transaction >>
Rollback the current database transaction.
=cut
sub abort_transaction {
# warn 'abort transaction';
my $self = shift;
$self->dbh->rollback;
}
=item C<< end_transaction >>
Commit the current database transaction.
=cut
sub end_transaction {
# warn 'end transaction';
my $self = shift;
$self->dbh->commit;
}
=item C<< begin_bulk_updates >>
Begin a database transaction.
=cut
sub begin_bulk_updates {
my $self = shift;
$self->dbh->begin_work;
}
=item C<< end_bulk_updates >>
Commit the current database transaction.
=cut
sub end_bulk_updates {
my $self = shift;
$self->dbh->commit;
}
=item C<< database_type >>
Returns the database type name as a string (e.g. 'mysql', 'sqlite', or 'postgresql').
=cut
sub database_type {
my $self = shift;
my $dbh = $self->dbh;
# warn $dbh->get_info($GetInfoType{SQL_DRIVER_NAME});
my $type = lc($dbh->get_info($GetInfoType{SQL_DBMS_NAME}));
return $type;
}
=item C<< initialize_version >>
Insert data into the attean_version table.
=cut
sub initialize_version {
my $self = shift;
my $dbh = $self->dbh;
$dbh->do('DELETE FROM attean_version');
my $sql = 'INSERT INTO attean_version (attean_version, store_version) VALUES (?, ?);';
$dbh->do($sql, undef, $Attean::VERSION, $AtteanX::Store::DBI::VERSION);
}
=item C<< create_schema_file >>
Returns the path to the file containing the database DDL for quadstore creation
for the current database type if available, undef otherwise.
=cut
sub create_schema_file {
my $self = shift;
my $type = $self->database_type;
my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share';
my $file = File::Spec->catfile($dir, 'database-schema', sprintf('%s-create.sql', $type));
if (-r $file) {
return $file;
}
return;
}
=item C<< drop_schema_file >>
Returns the path to the file containing the database DDL for quadstore deletion
for the current database type if available, undef otherwise.
=cut
sub drop_schema_file {
my $self = shift;
my $type = $self->database_type;
my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share';
my $file = File::Spec->catfile($dir, 'database-schema', sprintf('%s-drop.sql', $type));
if (-r $file) {
return $file;
}
return;
}
=item C<< available_database_types >>
Returns the names of the database types for which the system has schemas
available to create and drop quadstore tables.
=cut
sub available_database_types {
my $self = shift;
my $dir = $ENV{ATTEAN_SHAREDIR} || eval { dist_dir('AtteanX-Store-DBI') } || 'share';
my $pat = File::Spec->catfile($dir, 'database-schema', '*-create.sql');
my @files = glob($pat);
my @types = map { /(\w+)-create.sql/ } @files;
return @types;
}
=item C<< dbi_connect_args ( $type, %args ) >>
=item C<< dbi_connect_args ( %args ) >>
Returns a quad C<< $dsn, $user, $password, \%connect_args >> suitable for
passing to C<< DBI->connect >> to obtain a database handle to be used in
constructing a C<< AtteanX::Store::DBI >> quadstore.
C<< %args >> must contain a value for the C<< database >> key. It may also
contain values for the optional keys: C<< user >>, C<< password >>,
C<< host >>, and C<< port >>.
If invoked as a class method, the C<< $type >> parameter is required, and must
be one of the database types returned by C<< available_database_types >>.
If invoked as an object method, the C<< $type >> parameter must not be
included; this information will be obtained directly from the
C<< AtteanX::Store::DBI >> object.
=cut
sub dbi_connect_args {
my $self = shift;
my $type = blessed($self) ? $self->database_type : shift;
my %args = @_;
my $database = $args{database};
my $user = $args{user};
my $password = $args{password};
my $host = $args{host};
my $port = $args{port};
my $dsn;
my %connect_args;
$connect_args{RaiseError} = 1;
if ($type eq 'mysql') {
$dsn = "DBI:mysql:database=${database}";
if (defined($host)) {
$dsn .= ";host=$host";
}
if (defined($port)) {
$dsn .= ";port=$port";
}
$connect_args{mysql_enable_utf8} = 1;
} elsif ($type eq 'postgresql') {
$dsn = "DBI:Pg:dbname=${database}";
if (defined($host)) {
$dsn .= ";host=$host";
}
if (defined($port)) {
$dsn .= ";port=$port";
}
} elsif ($type eq 'sqlite') {
$dsn = "DBI:SQLite:dbname=${database}";
$connect_args{sqlite_unicode} = 1;
}
return ($dsn, $user, $password, \%connect_args);
}
=item C<< plans_for_algebra( $algebra, $model, $active_graphs, $default_graphs ) >>
For BGP algebras, returns a DBI-specific L object, otherwise
returns undef.
=cut
sub plans_for_algebra {
my $self = shift;
my $algebra = shift;
my $model = shift;
my $active_graphs = shift;
my $default_graphs = shift;
return unless ($algebra);
my %args = @_;
my $counter = $args{dbi_filter_counter}++;
if ($algebra->isa('Attean::Algebra::Filter')) {
my $e = $algebra->expression;
if ($e->isa('Attean::FunctionExpression')) {
if ($e->operator =~ m/IS(IRI|LITERAL|BLANK)/i) {
my $type = lc($1);
my ($operand) = @{ $e->children };
if ($operand->isa('Attean::ValueExpression') and $operand->value->does('Attean::API::Variable')) {
my $var = $operand->value;
if (my ($plan) = $self->plans_for_algebra($algebra->child, $model, $active_graphs, $default_graphs, %args)) {
if ($plan->isa('AtteanX::Store::DBI::Plan')) {
if (exists $plan->variables->{ $var->value }) {
my ($table, $col) = @{ $plan->variables->{ $var->value } };
my $ref = join('.', map { $self->dbh->quote_identifier($_) } ($table, $col));
my $typecol = $self->dbh->quote_identifier('type');
push(@{ $plan->where }, "$ref IN (SELECT term_id FROM term WHERE ${typecol} = ?)");
push(@{ $plan->bindings }, $type);
return $plan;
}
}
}
}
} elsif ($e->operator eq 'STRSTARTS' or $e->operator eq 'CONTAINS') {
my ($varexpr, $pat) = @{ $e->children };
if ($varexpr->isa('Attean::ValueExpression') and $varexpr->value->does('Attean::API::Variable') and $pat->isa('Attean::ValueExpression') and $pat->value->does('Attean::API::Literal')) {
if (my ($plan) = $self->plans_for_algebra($algebra->child, $model, $active_graphs, $default_graphs, %args)) {
if ($plan->isa('AtteanX::Store::DBI::Plan')) {
my $var = $varexpr->value;
my $varname = $var->value;
if (exists $plan->variables->{ $var->value }) {
my ($table, $col) = @{ $plan->variables->{ $var->value } };
my $literal = $pat->value;
my $ref = join('.', map { $self->dbh->quote_identifier($_) } ($table, $col));
my $typecol = $self->dbh->quote_identifier('type');
my $termtable = "tf$counter";
push(@{ $plan->tables }, ['term', $termtable]);
my $db = $self->database_type;
return unless ($db eq 'mysql' or $db eq 'postgresql' or $db eq 'sqlite');
push(@{ $plan->where }, "$ref = $termtable.term_id");
push(@{ $plan->where }, "$termtable.$typecol = ?"); # TODO: Remove this (and the bindings below) if $varexpr is STR(?var) instead of just ?var.
my $op = ($e->operator eq 'STRSTARTS') ? '=' : '>=';
if ($db eq 'mysql') {
push(@{ $plan->where }, "LOCATE(?, $termtable.value) ${op} ?");
push(@{ $plan->bindings }, 'literal');
push(@{ $plan->bindings }, $literal->value);
push(@{ $plan->bindings }, 1);
} elsif ($db eq 'postgresql') {
push(@{ $plan->where }, "STRPOS($termtable.value, ?) ${op} ?");
push(@{ $plan->bindings }, 'literal');
push(@{ $plan->bindings }, $literal->value);
push(@{ $plan->bindings }, 1);
} elsif ($db eq 'sqlite') {
push(@{ $plan->where }, "INSTR($termtable.value, ?) ${op} 1");
push(@{ $plan->bindings }, 'literal');
push(@{ $plan->bindings }, $literal->value);
}
if (my $lang = $literal->language) {
push(@{ $plan->where }, "$termtable.language = ?");
push(@{ $plan->bindings }, $lang);
} else {
my $xs = Attean::IRI->new( value => 'http://www.w3.org/2001/XMLSchema#string' );
my $la = Attean::IRI->new( value => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString' );
my $xid = $self->_get_term_id($xs);
my $lid = $self->_get_term_id($la);
push(@{ $plan->where }, "$termtable.datatype_id IN (?, ?)");
push(@{ $plan->bindings }, $xid, $lid);
}
return $plan;
}
}
}
}
}
}
} elsif ($algebra->isa('Attean::Algebra::BGP') and scalar(@{ $algebra->triples }) > 0) {
my @vars = $algebra->in_scope_variables;
my @triples = @{ $algebra->triples };
my @select;
my @where_joins;
my %seen_vars;
my %source_table_for_var;
my %blanks;
my $tcounter = 0;
my $bcounter = 0;
my @tables;
my %rename_mapping;
my $rename_proj = sub {
my $name = shift;
if ($name =~ /[-._]|\W/) {
my $old = $name;
$name =~ s/_/__/g;
$name =~ s/([-.]|\W)/_d/g;
$name =~ s/([-.]|\W)/'_x' . sprintf('%02x', ord($1))/e;
$rename_mapping{$old} = $name;
}
return $name;
};
Carp::confess Dumper($active_graphs) unless (ref($active_graphs) eq 'ARRAY');
my @graph_ids = map { $self->_get_term_id($_) } @{ $active_graphs };
if (any { not defined($_) } @graph_ids) {
return;
}
my @bind;
my $graph = Attean::Variable->new(value => '___g');
$seen_vars{ $graph->value }++;
my $graph_values = sprintf('(%s)', join(', ', ('?') x scalar(@graph_ids)));
push(@bind, @graph_ids);
my @where = ("t0.graph IN $graph_values");
foreach my $t (@triples) {
my $table = 't' . $tcounter++;
push(@tables, ['quad', $table]);
my @vars;
my $q = $t->as_quadpattern($graph);
my @nodes = $q->values;
foreach my $i (0 .. $#nodes) {
my $node = $nodes[$i];
my $name = $pos_names[$i];
if ($node->does('Attean::API::Variable')) {
my $var = $node;
push(@vars, [$var, $name]);
} elsif ($node->does('Attean::API::Blank')) {
my $id = $node->value;
unless (exists $blanks{$id}) {
my $bname = sprintf('.%s_%d', 'blank', $bcounter++);
$blanks{$id} = Attean::Variable->new(value => $bname);
}
my $var = $blanks{$id};
push(@vars, [$var, $name]);
$seen_vars{ $var->value }++;
} else {
my $id = $self->_get_term_id($node);
return unless defined($id);
push(@where, sprintf('%s.%s = ?', $table, $name));
push(@bind, $id);
}
}
foreach my $vdata (@vars) {
my ($var, $name) = @$vdata;
my $var_name = $rename_proj->( $var->value );
push(@select, [$table, $name, $var_name]) unless ($seen_vars{$var->value}++);
if (my $tt = $source_table_for_var{ $var->value }) {
push(@where_joins, ['=', $tt, [$table, $name]]);
} else {
$source_table_for_var{ $var->value } = [$table, $name];
}
}
}
foreach my $w (@where_joins) {
my ($op, $a, $b) = @$w;
my ($as, $bs) = map { sprintf('%s.%s', @$_) } ($a, $b);
push(@where, join(' ', $as, $op, $bs));
}
return AtteanX::Store::DBI::Plan->new(
store => $self,
select => \@select,
where => \@where,
tables => \@tables,
in_scope_variables => [@vars],
rename_mapping => \%rename_mapping,
bindings => \@bind,
variables => \%source_table_for_var,
);
}
return;
}
=item C<< cost_for_plan( $plan ) >>
Returns the estimated cost for a DBI-specific query plan, undef otherwise.
=cut
sub cost_for_plan {
my $self = shift;
my $plan = shift;
if ($plan->isa('AtteanX::Store::DBI::Plan')) {
return 1; # TODO: actually estimate cost here
}
return;
}
}
package AtteanX::Store::DBI::Plan 0.012 {
use Moo;
use Type::Tiny::Role;
use Types::Standard qw(HashRef ArrayRef InstanceOf Str);
use namespace::clean;
has store => (is => 'ro', isa => InstanceOf['AtteanX::Store::DBI'], required => 1);
has rename_mapping => (is => 'ro', isa => HashRef[Str], default => sub { +{} });
has variables => (is => 'ro', isa => HashRef, required => 1);
has bindings => (is => 'ro', isa => ArrayRef, required => 1);
has select => (is => 'ro', isa => ArrayRef, required => 1);
has where => (is => 'ro', isa => ArrayRef, required => 1);
has tables => (is => 'ro', isa => ArrayRef[ArrayRef[Str]], required => 1);
with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::NullaryQueryTree';
sub plan_as_string {
my $self = shift;
my ($sql, @bind) = $self->sql();
return sprintf('DBI BGP { %s ← (%s) }', $sql, join(', ', @bind));
}
sub sql {
my $self = shift;
my $bind = shift;
my $store = $self->store;
my $dbh = $store->dbh;
my @bind = @{ $self->bindings };
my @where = @{ $self->where };
if ($bind) {
foreach my $var ($bind->variables) {
my $id = $store->_get_term_id($bind->value($var));
return unless defined($id);
if (my $cdata = $self->variables->{ $var }) {
my ($table, $col) = @$cdata;
push(@where, sprintf("%s.%s = ?", $table, $col));
push(@bind, $id);
}
}
}
my @select = map { sprintf("%s.%s AS %s", map { $dbh->quote_identifier( $_ ) } @$_) } @{ $self->select };
unless (scalar(@select)) {
push(@select, '1');
}
my @sql;
push(@sql, 'SELECT');
push(@sql, join(', ', @select));
push(@sql, 'FROM');
push(@sql, join(', ', map { join(' ', @$_) } @{ $self->tables }));
if (scalar(@where)) {
push(@sql, 'WHERE');
push(@sql, join(' AND ', map { "($_)" } @where));
}
my $sql = join(" ", @sql);
return ($sql, @bind);
}
sub substitute_impl {
my $self = shift;
my $model = shift;
my ($sql, @bind) = $self->sql(@_);
my $store = $self->store;
my $dbh = $store->dbh;
# warn "TODO: generatee SQL for BGP: $sql\n";
# warn "======================================================================\n";
# warn "$sql\n";
# warn "======================================================================\n";
my $vars = $self->in_scope_variables;
my $sth = $dbh->prepare($sql);
return sub {
# warn "Generating impl by executing SQL";
my $rv = $sth->execute(@bind);
unless ($rv) {
warn '*** SQL error: ' . $sth->errstr;
die;
}
my $sub = sub {
# warn '=== Iterator invoked';
# use Data::Dumper;
# warn Dumper($sql, \@bind);
if (my $row = $sth->fetchrow_hashref) {
# warn '@@@ Iterator got row';
# warn Dumper($row);
my %bindings;
foreach my $k (@$vars) {
my $key = $self->rename_mapping->{$k} // $k;
my $term = $store->_get_term($row->{$key});
$bindings{$k} = $term;
}
my $r = Attean::Result->new( bindings => \%bindings );
return $r;
} else {
# warn '^^^ Reached end-of-iterator'
}
return;
};
return Attean::CodeIterator->new( generator => $sub, item_type => 'Attean::API::Result', variables => $vars );
};
}
}
1;
__END__
=back
=head1 BUGS
Please report any bugs or feature requests to through the GitHub web interface
at L.
=head1 AUTHOR
Gregory Todd Williams C<< >>
=head1 COPYRIGHT
Copyright (c) 2014--2020 Gregory Todd Williams. This
program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut
AtteanX-Store-DBI-0.002/lib/Test/AtteanX/ 000755 000765 000024 00000000000 13765312545 017700 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/lib/Test/AtteanX/Store/ 000755 000765 000024 00000000000 13765312545 020774 5 ustar 00greg staff 000000 000000 AtteanX-Store-DBI-0.002/lib/Test/AtteanX/Store/DBI.pm 000644 000765 000024 00000012260 13761614710 021724 0 ustar 00greg staff 000000 000000 package Test::AtteanX::Store::DBI;
use utf8;
use v5.14;
use warnings;
use Test::Roo::Role;
use Test::Modern;
use Test::Moose;
use Attean;
use Attean::RDF;
requires 'create_store'; # create_store( quads => \@triples )
sub test_quads {
my @q;
for my $i (0 .. 5) {
push(@q, quad(iri('s'), iri('p'), literal($i), iri('g')));
push(@q, quad(iri('s'), iri('p'), blank("b$i"), iri('g')));
}
my @strings;
push(@strings, literal('Hi'));
push(@strings, langliteral('Hello', 'en'));
push(@strings, langliteral('火星', 'ja'));
push(@strings, dtliteral(787, 'http://www.w3.org/2001/XMLSchema#integer'));
foreach my $s (@strings) {
push(@q, quad(iri('s'), iri('str'), $s, iri('strings')));
}
return \@q;
}
test 'ISLITERAL type constraint SARG' => sub {
my $self = shift;
my $store = $self->create_store(quads => $self->test_quads);
my $model = Attean::QuadModel->new( store => $store );
my $dbh = $store->dbh;
my $typecol = $dbh->quote_identifier('type');
my $algebra = Attean->get_parser('SPARQL')->parse('SELECT * WHERE { ?s ?p ?o FILTER ISLITERAL(?o) }');
my $default_graphs = [iri('g')];
my $planner = Attean::IDPQueryPlanner->new();
my $plan = $planner->plan_for_algebra($algebra, $model, $default_graphs);
isa_ok($plan, 'AtteanX::Store::DBI::Plan');
my ($sql, @bind) = $plan->sql;
like($sql, qr