Created
September 7, 2012 16:29
-
-
Save kasei/3667578 to your computer and use it in GitHub Desktop.
RDF::Query rewriting ideas
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
$query->rewrite_algebra( postfix => sub { | |
my $visitor = shift; | |
my $algebra = shift; | |
if ($algebra->isa('RDF::Query::Algebra::BasicGraphPattern')) | |
return $visitor->stop; # stop traversal | |
if ($algebra->isa('RDF::Query::Algebra::Filter')) { | |
my $expr = $algebra->expr; | |
if ($expr->isa('RDF::Query::Expression::Function')) { | |
if ($expr->uri eq 'sparql:regex') { | |
# replace the algebra with a new one that's more efficient... | |
return $new_algebra; | |
} | |
} | |
} | |
return; | |
} ); | |
# Maybe there are better (DSL-like) ways to write the algebra pattern to match? | |
if ($algebra->matches('FILTER/FUNCTION[sparql:regex]')) { ... } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment