Re: [Tracker] tracker-sparql dbus sparql results



hi philip, thanks for the pointer...

i'll take a look and see if i can find the part of the code...

just to make things a little clearer :
i'm talking about the rdf data model [1]. we basically have a (global) table with three columns (subject, predicate and object).
the values in the object slot can take the form of
a) uri
b) literals (with or without language tag)
c) typed literal (with dataType information, most xsd datatypes)
d) blank nodes

from my test i know that the information to return correct rdf-terms for the object (of a triple) is there. it justs mixed up by the cursor somehow.

prove :

from a test-query i get the following single triple
<subject> <predicate> "2012...."  => the cursor tells me object value-type = 5 (correct)

from a test-query i get => amongst others <= the triple from above
<subject> <predicate1> <someuri> 
<subject> <predicate> "2012...."  => the cursor tells me object value-type = 1 (not correct)

in case i do some ORDER BY with the query and the first triple returned is

<subject> <predicateX> "some literal"
cursor will tell me that value-type of object is 2 (STRING, not correct, must be 5 => DATETIME)
<subject> <predicate> "2012...." 

the cursor simply stops looking at the value-type after encounting the first one, after having encountered a value-type, it returns that 
value-type for all following objects of triples (or bindings)


anyways .... congrats to this project, i like it!  and when i'm done implementing the openrdf repository wrapper, i'll do some advertising in the semweb, linked data community... ;-)

wkr turnguard  

[1] http://www.w3.org/TR/2014/NOTE-rdf11-primer-20140225/#section-data-model

| Jürgen Jakobitsch,
| Software Developer
| Semantic Web Company GmbH
| Mariahilfer Straße 70 / Neubaugasse 1, Top 8
| A - 1070 Wien, Austria
| Mob +43 676 62 12 710 | Fax +43.1.402 12 35 - 22

COMPANY INFORMATION
| web       : http://www.semantic-web.at/
| foaf      : http://company.semantic-web.at/person/juergen_jakobitsch
PERSONAL INFORMATION
| web       : http://www.turnguard.com
| foaf      : http://www.turnguard.com/turnguard
| g+        : https://plus.google.com/111233759991616358206/posts
| skype     : jakobitsch-punkt
| xmlns:tg  = "http://www.turnguard.com/turnguard#"


2014-04-21 21:28 GMT+02:00 Philip Van Hoof <philip codeminded be>:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jürgen,

I recall writing a blog article about the feature when we implemented
it. Maybe you can extract from the date/time of the article and its
content the commits related to the implementation of the feature?:

http://pvanhoof.be/blog/index.php/2010/09/09/less-exciting-features-also-need-to-be-done-return-types

I'm not sure whether column-types (or rather return-types would indeed
be a more suitable name for rdf-world) was done 'correctly' (the way
you describe). I remember that it was done for a limited use-case and
made to work up until it worked for that use-case.

You might have to improve the current situation before it's usable for
your use-case.

Kind regards,

Philip


Jürgen Jakobitsch schreef op 21/04/2014 17:38:
> hi, after struggling with UNIX_FD (dbus type 'h') not really being
> supported i swithed to JNA using libtracker-sparql (it's much
> easier anyway...).
>
> i however realized that the rdf datatypes do not work as expected
> (as far as i understand tracker-cursor simply uses the first
> value_type for a column and returns it for every row returned).
>
> how to verify :
>
> 1. i added the following test to
> tests/libtracker-sparql/tracker-test.c
>
> static void test_tracker_sparql_cursor_types (void) { GError *error
> = NULL;
>
> TrackerSparqlCursor *cursor1; TrackerSparqlConnection *connection;
>
> //const gchar* query = "SELECT ?o ?p WHERE {
> <file:///home/turnguard/.local/share/applications/netbeans-7.4.desktop>
> ?p ?o  . }"; const gchar* query = "SELECT ?date WHERE {
> <file:///home/turnguard/.local/share/applications/netbeans-7.4.desktop>
> < http://www.tracker-project.org/ontologies/tracker#added> ?date .
> } ORDER BY ?date"; connection = tracker_sparql_connection_get
> (NULL, &error); g_assert_no_error (error);
>
> cursor1 = tracker_sparql_connection_query (connection, query, 0,
> &error); g_assert_no_error (error); gint n_columns =
> tracker_sparql_cursor_get_n_columns (cursor1); g_print("query %s",
> query); while (tracker_sparql_cursor_next (cursor1, NULL, NULL)) {
> int i = 0; for (i = 0; i < n_columns ; i++) { g_print ("=>type of
> %s is %d ",
> tracker_sparql_cursor_get_string(cursor1,i,NULL),(int)tracker_sparql_cursor_get_value_type
>
>
(cursor1, i));
> } g_print("\n"); } g_object_unref(cursor1); }
>
> .... g_test_add_func
> ("/libtracker-sparql/tracker/test_tracker_sparql_cursor_types",
> test_tracker_sparql_cursor_types);
>
> 2. replace <file://home/turnguard....> with a known entity that has
> a tracker#added predicate
>
> 3. sudo make => ./tracker-test
>
> 4. using the first query i get 2 or 1 (depending on ?o ?p or ?p ?o)
> for the date (tracker#added)
>
> 5. using the second query i get 5 for the value_type (correct)
>
> i assume that the cursor takes the value_types of the first row it
> encounters and takes these value_types for every following row.
> such behaviour is suitable for the sql world but not for the sparql
> world. is it really the "g_once_init_leave", can i simply delete
> g_once_init_leave without sideeffects?
>
> any pointer really appreciated.
>
> wkr turnguard
>
>
> | Jürgen Jakobitsch, | Software Developer | Semantic Web Company
> GmbH | Mariahilfer Straße 70 / Neubaugasse 1, Top 8 | A - 1070
> Wien, Austria | Mob +43 676 62 12 710 | Fax +43.1.402 12 35 - 22
>
> COMPANY INFORMATION | web       : http://www.semantic-web.at/ |
> foaf      :
> http://company.semantic-web.at/person/juergen_jakobitsch PERSONAL
> INFORMATION | web       : http://www.turnguard.com | foaf      :
> http://www.turnguard.com/turnguard | g+        :
> https://plus.google.com/111233759991616358206/posts | skype     :
> jakobitsch-punkt | xmlns:tg  =
> "http://www.turnguard.com/turnguard#"
>
>
> 2014-04-18 22:17 GMT+02:00 Jürgen Jakobitsch
> <j jakobitsch semantic-web at>:
>
>> philip, thanks for information.. i'll take a closer look at
>> steroids1 dbus...
>>
>> wkr turnguard
>>
>> | Jürgen Jakobitsch, | Software Developer | Semantic Web Company
>> GmbH | Mariahilfer Straße 70 / Neubaugasse 1, Top 8 | A - 1070
>> Wien, Austria | Mob +43 676 62 12 710 | Fax +43.1.402 12 35 - 22
>>
>> COMPANY INFORMATION | web       : http://www.semantic-web.at/ |
>> foaf      :
>> http://company.semantic-web.at/person/juergen_jakobitsch PERSONAL
>> INFORMATION | web       : http://www.turnguard.com | foaf      :
>> http://www.turnguard.com/turnguard | g+        :
>> https://plus.google.com/111233759991616358206/posts | skype     :
>> jakobitsch-punkt | xmlns:tg  =
>> "http://www.turnguard.com/turnguard#"
>>
>>
>> 2014-04-18 22:04 GMT+02:00 Philip Van Hoof
>> <philip codeminded be>:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>>
>>> Hi Jürgen,
>>>
>>> In that case you should use the Steroids1 DBus object which
>>> works by passing file descriptors and pipe(). I'm guessing that
>>> in Java you can use the type FileDescriptor to turn that to a
>>> InputStream.
>>>
>>>
>>> https://git.gnome.org/browse/tracker/tree/src/tracker-store/tracker-steroids.vala
>>>
>>>
>>>
Steroid1's protocol that goes over pipe()/vmsplice() already passes
>>> the variable-names and column-types over.
>>>
>>> Usage of Resources1 is very slow and on top it's not really a
>>> supported interface. Resources1 is actually only for the
>>> GraphUpdated signal, which is the only officially supported
>>> interface that the DBus object exports.
>>>
>>> The Steroids1 DBus object is going to stay and is used for
>>> write queries and fallback for libtracker-sparql in case WAL
>>> direct access mode can't be used.
>>>
>>> Kind regards,
>>>
>>> Philip
>>>
>>>
>>> Jürgen Jakobitsch schreef op 18/04/2014 15:53:
>>>> hi philipp,
>>>>
>>>> i'm currently using the dbus resource because i'm writing
>>>> the openrdf repository in java and didn't want to got down
>>>> the jni, jna road...
>>>>
>>>> i already have built in a switch in tracker-resource.vala,
>>>> about here [1], testing the cursor.get_value_type, but the
>>>> returned value_types are not totally correct. for some uris
>>>> the value is 1 for other uris the value type is 2... i'm
>>>> gonna issue a bug report, as soon as i have verified, that
>>>> i'm not doing something wrong.. also the returned value_types
>>>> are only 1 or 2.. there are not other values (like bnode,
>>>> double, date...) although the returned string suggest they
>>>> should be used..
>>>>
>>>> wkr turnguard
>>>>
>>>> [1]
>>>>
>>> https://git.gnome.org/browse/tracker/tree/src/tracker-store/tracker-resources.vala#n102
>>>>
>>>>
>>>
| Jürgen Jakobitsch, | Software Developer | Semantic Web Company
>>>> GmbH | Mariahilfer Straße 70 / Neubaugasse 1, Top 8 | A -
>>>> 1070 Wien, Austria | Mob +43 676 62 12 710 | Fax +43.1.402 12
>>>> 35 - 22
>>>>
>>>> COMPANY INFORMATION | web       : http://www.semantic-web.at/
>>>> | foaf      :
>>>> http://company.semantic-web.at/person/juergen_jakobitsch
>>>> PERSONAL INFORMATION | web       : http://www.turnguard.com |
>>>> foaf      : http://www.turnguard.com/turnguard | g+        :
>>>> https://plus.google.com/111233759991616358206/posts | skype
>>>> : jakobitsch-punkt | xmlns:tg  =
>>>> "http://www.turnguard.com/turnguard#"
>>>>
>>>>
>>>> 2014-04-18 11:32 GMT+02:00 Philip Van Hoof
>>>> <philip codeminded be>:
>>>>
>>>>
>>>> get_value_type and get_variable_name:
>>>>
>>>>
>>>>
>>> https://git.gnome.org/browse/tracker/tree/src/libtracker-sparql/tracker-cursor.vala#n126
>>>>
>>>>
>>>>
>>>>
>>>
>>>
https://git.gnome.org/browse/tracker/tree/src/libtracker-sparql/tracker-cursor.vala#n139
>>>>
>>>> You btw shouldn't use the DBus Resources1 object, but use
>>>> libtracker-sparql instead.
>>>>
>>>>
>>>> Ivan Frade schreef op 17/04/2014 20:14:
>>>>>>> Hi Jürgen,
>>>>>>>
>>>>>>> Yes, tracker does not return bindingNames or types of
>>>>>>> the resulting nodes. It assumes the client takes care
>>>>>>> of interpreting the results of its query.
>>>>>>>
>>>>>>> A workaround would be to parse the SparQL in the
>>>>>>> wrapper and add that information when translating the
>>>>>>> DBus result set to the openrdf format. The binding
>>>>>>> Names can be added straight forward from the SELECT of
>>>>>>> the query. The type information is more complicated to
>>>>>>> deduce, based on the position in the query and/or the
>>>>>>> rdfs:range of the properties (defined in the
>>>>>>> ontology).
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Ivan
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Apr 17, 2014 at 10:11 AM, Jürgen Jakobitsch <
>>>>>>> j jakobitsch semantic-web at> wrote:
>>>>>>>
>>>>>>>> hi,
>>>>>>>>
>>>>>>>> i'm currently developing an openrdf [1] repository
>>>>>>>> implementation with a tracker-sparql backend via
>>>>>>>> dbus. this will enable java developers to include
>>>>>>>> tracker-sparql results in any application (or create
>>>>>>>> a sparql endpoint) extremly easily. openrdf's api is
>>>>>>>> quite common in the semweb community..
>>>>>>>>
>>>>>>>> everything is working very nice already  the only
>>>>>>>> trouble i'm having is that i get a vector of vectors
>>>>>>>> containing simple strings as a result object, meaning
>>>>>>>> i need to find out types (literals, uris, bnodes,
>>>>>>>> typed literals)..
>>>>>>>>
>>>>>>>> is there any known way to retrieve some more
>>>>>>>> information in the results given via dbus? also
>>>>>>>> bindingNames are missing...
>>>>>>>>
>>>>>>>> any pointer really appreciated wkr turnguard..
>>>>>>>>
>>>>>>>>
>>>>>>>> [1] http://www.openrdf.org/
>>>>>>>>
>>>>>>>> | Jürgen Jakobitsch, | Software Developer | Semantic
>>>>>>>> Web Company GmbH | Mariahilfer Straße 70 /
>>>>>>>> Neubaugasse 1, Top 8 | A - 1070 Wien, Austria | Mob
>>>>>>>> +43 676 62 12 710 | Fax +43.1.402 12 35 - 22
>>>>>>>>
>>>>>>>> COMPANY INFORMATION | web       :
>>>>>>>> http://www.semantic-web.at/ | foaf      :
>>>>>>>> http://company.semantic-web.at/person/juergen_jakobitsch
>>>>>>>>
>>>>>>>>
PERSONAL INFORMATION | web       : http://www.turnguard.com
>>>>>>>> | foaf      : http://www.turnguard.com/turnguard |
>>>>>>>> g+ :
>>>>>>>> https://plus.google.com/111233759991616358206/posts
>>>>>>>> | skype     : jakobitsch-punkt | xmlns:tg  =
>>>>>>>> "http://www.turnguard.com/turnguard#"
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> tracker-list mailing list tracker-list gnome org
>>>>>>>> https://mail.gnome.org/mailman/listinfo/tracker-list
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> tracker-list mailing list tracker-list gnome org
>>>>>>> https://mail.gnome.org/mailman/listinfo/tracker-list
>>>>>>>
>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________ tracker-list
>>>> mailing list tracker-list gnome org
>>>> https://mail.gnome.org/mailman/listinfo/tracker-list
>>>>
>>>
>>> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (MingW32)
>>> Comment: Using GnuPG with Thunderbird -
>>> http://www.enigmail.net/
>>>
>>> iQEcBAEBAgAGBQJTUYVcAAoJEEP2NSGEz4aD1eAH/j59ejV3/wkgPzUR22trrNOj
>>>
>>>
KqFBT1YRP9631NyZmphdP5q3giRnihBEjkLjF1P46eqOoO6zhRP8jo/qj64amHW8
>>> nUZ96/21ZBPp0kNeKij5vjIq5SxrqSAh6n4e0VQTP/rpwm70OoCz9h/6yKskk9Ln
>>>
>>>
EUYIHb3b4T1YUPHleuJ2SkFNsDgx71MmT2nXvCzKxf2DSB9XGupOCysPPuPbxEBf
>>> 4QofLlZmbyxiftz+Hb0g6PLFm0SFIAxGz1sWVVZHoxy7Ff2+xMrrFl3p+3ktlx6w
>>>
>>>
kZkqN7cEcqdzxzNqzqGlB7i67wIHfN3OtYMbhaZlt3UsfAsvKSRDbl/LONuilkM=
>>> =D9Uo -----END PGP SIGNATURE-----
>>>
>>
>>
>
>
>
> _______________________________________________ tracker-list
> mailing list tracker-list gnome org
> https://mail.gnome.org/mailman/listinfo/tracker-list
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJTVXF3AAoJEEP2NSGEz4aDlyAH/jc4rgJoLEiThabIajjrfFnL
TWHyDF/F5ODEOBKEVYAQpw4D5aIhp7917Wm4TcrkhYGJgirudfa7jF7J9YZiSlxT
JM9yHm39JEytfPUnOg7QqIRoAyEk10UjxT1O++j3WXBRlGx4/fwcOfPY6wHzQPQ6
lsjyslBXIBLID9r3SHz/HzoYTP6ctA3oOMZAJMQL0dR9H4y63pvvbZTr8OD+fFDC
iN9fjBjem23ajaBM4NeXEVjw/Gy/1Srs7SmDIyvvmtSHCju4aMR+rhDVa7n5/oBX
Z8FE19GjIklceGvAqddA3Lk2tmZJ20SVQdGg1oqVxi7OfbeHQfiN7DImDlzYIOk=
=VseF
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]