hdt-cpp
hdt-cpp copied to clipboard
Compiling with Position Indepenent Code causes HDT to return incorrect results / fail.
I have been using the hdt library as a shared library and using the compiler flag -fPIC for some time now. Recently I found that a specific turtle file, when converted to hdt, will cause incorrect query results and eventual failure.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dcog: <https://dcl.net/ontology/dcog#> .
@prefix dcogrel: <https://dcl.net/ontology/dcogrel#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix uk: <https://dcl.net/uks/ontology/uks#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
uk:Supplier a owl:Class;
rdfs:label "Supplier"@en ;
rdfs:comment "A supplier relationship"@en ;
rdfs:subClassOf dcogrel:Relationship.
uk:IndustryType a owl:Class;
rdfs:label "Industry Type"@en ;
rdfs:comment "A type of industry"@en ;
rdfs:subClassOf dcog:Entity .
uk:supplier_source a owl:ObjectProperty ;
rdfs:label "Supplier Source"@en ;
rdfs:comment "Source of a supplier relationship"@en ;
rdfs:domain uk:Supplier ;
rdfs:range uk:IndustryType .
uk:supplier_target a owl:ObjectProperty ;
rdfs:label "Supplier Target"@en ;
rdfs:comment "Target of a supplier relationship"@en ;
rdfs:domain uk:Supplier ;
rdfs:range uk:IndustryType .
uk:supplier_value a owl:DatatypeProperty ;
rdfs:label "Supplier Value"@en ;
rdfs:comment "Value of a supplier relationship"@en ;
rdfs:range xsd:float ;
rdfs:domain uk:Supplier .
When compiled with -fPIC, converting the above turtle with rdf2hdt into the file mo.hdt, the following occurs:
$ hdtSearch mo.hdt
>> ? http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_source http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_target http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_source http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_target http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_value http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#Supplier http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#IndustryType http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#IndustryType http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_source http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_source http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_target http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_value http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#Supplier http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_target http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_value http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_value http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#IndustryType http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#Supplier http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_value http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_source http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#supplier_target http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#IndustryType http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
https://dcl.net/uks/ontology/uks#Supplier http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
Trying to get an element bigger than the array.
Compiling without -fPIC I get the expected behaviour:
$ hdtSearch ~/mo.hdt
>> ? http://www.w3.org/2000/01/rdf-schema#domain https://dcl.net/uks/ontology/uks#IndustryType
0 results in 145 us
If the hdt library could be altered to work with -fPIC that would be ideal. I may be able to compile against the library statically, but this will be significant work.
Is there a potential workaround? I'm guessing that it may be due to indexing in the object, and that perhaps by using a different indexing method I could avoid it.
Or is there another place I should look in the hdt code which might be more likely to have the position dependency?
Ok, this is no longer a problem in the latest commit in the 'develop' branch. Sorry to bother you!