|
From: Richard C. <ri...@cy...> - 2007-01-23 13:53:23
|
Christian,
On 22 Jan 2007, at 19:23, Christian Weiske wrote:
> I face a very big problem regarding my SparqlEngineDb implementation:
> Sorting.
>
> One can sort by any variable of any type in Sparql. The data type =20
> of the
> values is stored in statements/l_datatype column and can hardly be
> directly used in a SQL query.
>
> Imagine the following query:
> ----------------------
> SELECT ?name ?emp
> WHERE { ?x foaf:name ?name ;
> ex:empId ?emp
> }
> ORDER BY ASC(?emp)
> ----------------------
>
> Now ?emp is an object following an "ex:empId" predicate, making the
> datatype of ?emp xsd:integer. Making the SQL query in this case is =20
> easy;
> just "ORDER BY CAST(emp as INTEGER) ASC" and it's done.
>
> Main problem is that I don't know in advance which data type the =20
> column
> will have (as there could be statements like "?a ?b ?c .", ordering by
> ?c) and that, even more serious, there could be multiple data types in
> this data.
>
> I don't know what to do here. The only ideas I came up with are:
> 1) Use a stored procedure which does comparison. This will render the
> engine useless for older db systems such as mysql < 5. I also need to
> get into stored procedures, but I think it is possible to hook into =20=
> sorting.
> 2) Sort on the client side. I would like to omit this since it would
> decrease performance greatly. Further, I couldn't use server-side
> LIMITs, making performance even worse.
> 3) Provide data type hints in the query, which would make the sparql
> implementation understand proprietary queries and still wouldn't work
> with normal queries.
>
> Anybody an idea what I could do?
I think you can write something like this in SPARQL:
ORDER BY ASC(xsd:int(?emp))
Query authors could use this as a hint that allows the engine to use =20
the right cast in the SQL translation. In the absence of such a hint, =20=
I'd just do the sorting client-side. This would be a relatively =20
simple and pragmatic solution.
Richard
>
>
> Btw, RDQL doesn't even provide ORDER support. I think I know why..
>
> --=20
> Regards/Mit freundlichen Gr=FC=DFen
> Christian Weiske
>
> ----------------------------------------------------------------------=20=
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to =20
> share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?=20
> page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV____________________________=
____=20
> _______________
> Rdfapi-php-interest mailing list
> Rdf...@li...
> https://lists.sourceforge.net/lists/listinfo/rdfapi-php-interest
|