As my application relies heavily on using containsAll query, I've
decided to implement it myself. And of course it is always fun and
interesting to learn and use something quite new to oneself.
After couple hours of googling about SPARQL (only known it before as
acronym), looking at SPARQL queries produced by Qi4j logging, and
examining values.dat of the rdf indexing, I noticed that collection
properties are stored as plain strings. So, in order to produce SPARQL
query which could implement containsAll (and contains) functionality,
using regexes seemed like appropriate solution.
If you find any flaws in my implementation, feel free to comment and
fix them - I tried to produce as reliable code as possible.
After some battling, I've got things to work (already some time ago,
but was too busy in order to write proper tests, which is now fixed).
Now both containsAll and contains -queries (for properties) have their
implementation. I've updated the JIRA issue with latest code changes
and tests (qi4j_core_proper.zip (newer one),
qi4j_extensions_proper.zip (newer one), tests.zip, git-diff.zip).
Would be nice if the changes would be integrated to working branch soon.
One thing still left me puzzling a little: I couldn't find code, which
actually produces the string which can be found in values.dat. Because
there it is without _type keys for value composites, and everything
seemed to use valueType.toJSON method, which always produces the _type
-key there. I partly copypasted code from there in order to produce
appropriate regex strings.
Also there was API change to QueryExpressions:
public static <T> ContainsAllPredicate<T>
containsAll(Property<Collection<T>> proeprty, Collection<T> value)
to:
public static <T, C extends Collection<T>> ContainsAllPredicate<T, C>
containsAll( Property<C> property, C value )
so that it is no longer needed to cast property type into
parameterless one in order to avoid compilation error. And changes
propagated further onto ContainsAllPredicate (and ContainsPredicate),
as can be seen.
The PropertyReferenceImpl couldn't understand the parametrized
collections, so I fixed that one too. RdfQueryParserImpl changes are
obvious - that's the place where the abstract query gets parsed into
SPARQL one, so that one contains most of the code changes.
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev