Created
May 5, 2015 09:06
-
-
Save kasei/75ed82deb74c944de415 to your computer and use it in GitHub Desktop.
Attean IDP query planning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
no warnings 'redefine'; | |
use utf8; | |
use RDF::Query; | |
use Attean; | |
use Attean::RDF; | |
use AtteanX::RDFQueryTranslator; | |
my $graph = Attean::IRI->new('http://example.org/graph'); | |
my $query = RDF::Query->new(<<"END"); | |
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | |
SELECT DISTINCT * WHERE { | |
?s a foaf:Person ; | |
foaf:name ?name ; | |
foaf:nick "kasei" . | |
FILTER(ISIRI(?s)) | |
} | |
ORDER BY ?name | |
END | |
warn "Translating query...\n"; | |
my $t = AtteanX::RDFQueryTranslator->new(); | |
my $algebra = $t->translate_query($query); | |
warn "Query algebra:\n" . $algebra->as_string; | |
warn "-----------\n"; | |
my $store = Attean->get_store('Memory')->new(); | |
my $model = Attean::MutableQuadModel->new( store => $store ); | |
my $planner = Attean::IDPQueryPlanner->new(); | |
my $plan = $planner->plan_for_algebra($algebra, $model, $graph); | |
my $cost = $planner->cost_for_plan($plan); | |
printf("Query plan (cost: %d):\n", $cost); | |
print $plan->as_string; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment