-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 31/01/12 12:49, Ozga, Rafal wrote:
> Hi,

Hi Rafal,

> We¹re trying to build a caching layer in the front of our
> triplestore server. But to get the most out of such a cache, it¹s 
> quite important to normalize incoming SPARQL queries...

Indeed, although don't underestimate the power of a very simple minded
cache. In some of my work we did no normalisation and it was still
very effective.

> We thought that the best way of doing so would be to use the
> feature that ARQ has in store, namely SPARQL Algebra.

+1

> The problem with that approach is, however, that the algebras being
> produced by Algebra.compile(query) routine are not ³abstract
> enough² for our purpose. For the former queries we would get
> respectively:
> 
> (bgp (triple ?subject ?predicate ?object))
> 
> (bgp (triple ?s ?p ?o))

Yes, Algebra.compile in itself does no work on the form of the
operations as far as I'm aware. However that's only the beginning of
the process. ARQ (and individual query engines) spend a lot of their
time transforming algebras.

> So the question is whether we are missing something and there is
> indeed a general way of obtaining the algebras that wouldn¹t be any
> different for semantically identical queries (like those two above)
> or we have to resort to some built in-house tweaks and tricks (e.g.
> normalizing variable names, sorting algebra nodes on the same tree
> level alphabetically etc. etc.) ?

There might well be transformers doing some of this work (ISTR a
variable reassignment mechanism) -- Andy would know best. I wrote a
little piece on manipulating sparql [1] which shows a simple transformer.

Damian

[1]
<http://incubator.apache.org/jena/documentation/query/manipulating_sparql_using_arq.html>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8n6FAACgkQAyLCB+mTtylfgwCg8td99GDeryaPqrJpIX2PTzhQ
lcYAoPGSMFc038apOpz1bSjbGlOs+pbk
=Uvwc
-----END PGP SIGNATURE-----

Reply via email to