janwielemaker / hdt Goto Github PK
View Code? Open in Web Editor NEWInterface to HDT
License: Other
Interface to HDT
License: Other
Predicate hdt_string_id/4
does not deal with Unicode characters correctly. As an MWE take the following N-Triples file:
<x:x> <y:y> "宇宙"@ja .
When used with the current version on master, we get the following result:
?- test.
"��"@ja
Predicate tets/0
is implemented as follows:
:- use_module(library(hdt)).
test :-
hdt_create_from_file('test.hdt', 'test.nt', []),
setup_call_cleanup(
hdt_open(Hdt, 'test.hdt'),
(
hdt_string_id(Hdt, object, String, 1),
format(user_output, "~s\n", [String])
),
hdt_close(Hdt)
).
For non mission-critical stuff, is this pack usable in practice?
How likely is it that it will be further enhanced in the future?
Opening an HDT file with non-ASCII characters in the file name results in an error (notice the SUPERSCRIPT TWO
Unicode character in the example):
?- [library(hdt)].
?- hdt_open(X, 'SP²B-10000.hdt', []).
ERROR: HDT: Error opening HDT file for mapping.
ERROR: In:
ERROR: [8] hdt_open(_6454,'SP²B-10000.hdt',[])
ERROR: [7] <user>
After renaming the same file to test.hdt
it works:
?- [library(hdt)].
?- hdt_open(X, 'test.hdt').
Predicate Bitmap in 322 us
Count predicates in 1 ms 141 us
Count Objects in 375 us Max was: 949
Bitmap in 120 us
Bitmap bits: 10303 Ones: 5468
Object references in 2 ms 784 us
Sort lists in 3 ms 492 us
Index generated in 8 ms 307 us
X = <hdt>(0x564949f11320).
I have a reproducible fatal error in the hdt interface. For some reason searching with a predicate and object, returns more results than simply searching for the object (in this case), and eventually gives you bounds check error.
The turtle file to reproduce this is:
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dcog: <https://datachemist.net/ontology/dcog#> .
@prefix dcogrel: <https://datachemist.net/ontology/dcogrel#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ipg: <https://datachemist.net/ontology/ipg#> .
@prefix note: <https://datachemist.net/uks/annotation/> .
@prefix inst: <https://datachemist.net/uks/candidate/> .
@prefix uksupply: <https://datachemist.net/uks/ontology/uk_supply_chain#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
uksupply:Supplier a owl:Class;
rdfs:comment "A supplier relationship"@en ;
rdfs:subClassOf dcogrel:Relationship.
uksupply:IndustryType a owl:Class;
rdfs:subClassOf dcog:Entity ;
rdfs:comment "A type of industry"@en .
uksupply:supplier_source a owl:ObjectProperty ;
rdfs:comment "Source of a supplier relationship"@en ;
rdfs:domain uksupply:Supplier ;
rdfs:range uksupply:IndustryType .
uksupply:supplier_target a owl:ObjectProperty ;
rdfs:comment "Target of a supplier relationship"@en ;
rdfs:domain uksupply:Supplier ;
rdfs:range uksupply:IndustryType .
uksupply:supplier_value a owl:DatatypeProperty ;
rdfs:comment "Value of a supplier relationship"@en ;
rdfs:range xsd:float ;
rdfs:domain uksupply:Supplier .
And the following interaction demonstrates the problem:
?- hdt_open(HDT,'/home/me/mo.hdt',[]), hdt_search_id(HDT,X,Y,1).
HDT = <hdt>(0x28d5860),
X = Y, Y = 4 ;
HDT = <hdt>(0x28d5860),
X = 5,
Y = 4 ;
false.
?- hdt_open(HDT,'/home/me/mo.hdt',[]), hdt_search_id(HDT,X,3,1).
HDT = <hdt>(0x2969930),
X = 4 ;
HDT = <hdt>(0x2969930),
X = 5 ;
HDT = <hdt>(0x2969930),
X = 2 ;
HDT = <hdt>(0x2969930),
X = 4 ;
HDT = <hdt>(0x2969930),
X = 5 ;
HDT = <hdt>(0x2969930),
X = 6 ;
HDT = <hdt>(0x2969930),
X = 3 ;
HDT = <hdt>(0x2969930),
X = 1 ;
HDT = <hdt>(0x2969930),
X = 4 ;
HDT = <hdt>(0x2969930),
X = 5 ;
HDT = <hdt>(0x2969930),
X = 6 ;
HDT = <hdt>(0x2969930),
X = 6 ;
HDT = <hdt>(0x2969930),
X = 1 ;
HDT = <hdt>(0x2969930),
X = 3 ;
HDT = <hdt>(0x2969930),
X = 6 ;
HDT = <hdt>(0x2969930),
X = 4 ;
HDT = <hdt>(0x2969930),
X = 5 ;
HDT = <hdt>(0x2969930),
X = 1 ;
HDT = <hdt>(0x2969930),
X = 3 ;
terminate called after throwing an instance of 'std::runtime_error'
what(): Trying to get an element bigger than the array.
Process prolog aborted (core dumped)
The bug can also be tickled using hdt_search instead of searching by id:
?- hdt_open(HDT,'/home/me/mo.hdt',[]), , hdt:hdt_search(HDT,X, 'http://www.w3.org/2000/01/rdf-schema#domain','https://datachemist.net/uks/ontology/uk_supply_chain#IndustryType').
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_source' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_target' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#Nonsense' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_source' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_target' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_value' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#Supplier' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#IndustryType' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_source' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_target' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_value' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_value' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#IndustryType' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#Supplier' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_value' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_source' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#supplier_target' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#IndustryType' ;
HDT = <hdt>(0x2103250),
X = 'https://datachemist.net/uks/ontology/uk_supply_chain#Supplier' ;
terminate called after throwing an instance of 'std::runtime_error'
what(): Trying to get an element bigger than the array.
Process prolog aborted (core dumped)
I've used the prolog hdt library on multi-gig databases including millions of nodes with no problem, so this one has me stumped and quite surprised to find a failure on such a small example.
Is it possible to change hdt_suggestions/5
so that it non-deterministically enumerates all results? Alternatively, could it return a lazy list?
Sometimes there are very many terms with the same prefix and then the Length
has to be set to increasingly large values.
In commit 8a3ea90 I tried to use the new, iterator-based implementation for retrieving suggestions. When I compile I get the following error, but handle
is used at other places in the same file (including earlier positions) and then the compiler does not complain:
ERROR: c/hdt4pl.cpp: In function 'foreign_t pl_hdt_suggestions__4(PlTermv)':
ERROR: c/hdt4pl.cpp:434:29: error: 'handle' was not declared in this scope
ERROR: switch(PL_foreign_control(handle))
How does handle
work in this file?
PS: This commit assumes that the develop
branch of hdt-cpp is used.
I'm attempting to build the swipl Docker image and plugins on the arm32v7 architecture, but I encountered a build error with the hdt plugin.
The plugin build fails on arm32v7 (Raspberry Pi) with the following error:
% [HDT] Compiling src/bitsequence/BitSequence375.cpp
ERROR: In file included from src/bitsequence/BitSequence375.cpp:30:0:
ERROR: src/bitsequence/../util/bitutil.h: In function 'bool hdt::bitget(uint32_t*, size_t)':
ERROR: src/bitsequence/../util/bitutil.h:86:13: error: redefinition of 'bool hdt::bitget(uint32_t*, size_t)'
ERROR: inline bool bitget(uint32_t *e, size_t p) {
ERROR: ^~~~~~
ERROR: src/bitsequence/../util/bitutil.h:69:13: note: 'bool hdt::bitget(size_t*, size_t)' previously defined here
ERROR: inline bool bitget(size_t *e, size_t p) {
ERROR: ^~~~~~
ERROR: src/bitsequence/../util/bitutil.h: In function 'void hdt::bitset(uint32_t*, size_t)':
ERROR: src/bitsequence/../util/bitutil.h:91:13: error: redefinition of 'void hdt::bitset(uint32_t*, size_t)'
ERROR: inline void bitset(uint32_t * e, size_t p) {
ERROR: ^~~~~~
ERROR: src/bitsequence/../util/bitutil.h:74:13: note: 'void hdt::bitset(size_t*, size_t)' previously defined here
ERROR: inline void bitset(size_t * e, size_t p) {
ERROR: ^~~~~~
ERROR: src/bitsequence/../util/bitutil.h: In function 'void hdt::bitclean(uint32_t*, size_t)':
ERROR: src/bitsequence/../util/bitutil.h:96:13: error: redefinition of 'void hdt::bitclean(uint32_t*, size_t)'
ERROR: inline void bitclean(uint32_t * e, size_t p) {
ERROR: ^~~~~~~~
ERROR: src/bitsequence/../util/bitutil.h:79:13: note: 'void hdt::bitclean(size_t*, size_t)' previously defined here
ERROR: inline void bitclean(size_t * e, size_t p) {
ERROR: ^~~~~~~~
Warning: At global scope:
Warning: cc1plus: warning: unrecognized command line option '-Wno-unknown-warning-option'
% Makefile:100: recipe for target 'src/bitsequence/BitSequence375.o' failed
% make[2]: Leaving directory '/usr/lib/swipl/pack/hdt/hdt-cpp/hdt-lib'
% make[2]: *** [src/bitsequence/BitSequence375.o] Error 1
% make[1]: *** [all] Error 2
% Makefile:63: recipe for target 'all' failed
% make[1]: Leaving directory '/usr/lib/swipl/pack/hdt/hdt-cpp/hdt-lib'
% Makefile:26: recipe for target 'hdt-cpp/hdt-lib/libhdt.a' failed
% make: *** [hdt-cpp/hdt-lib/libhdt.a] Error 2
ERROR: -g pack_rebuild(hdt): Process "process(path(make),[all])": exit status: 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.