diff --git a/c/hdt4pl.cpp b/c/hdt4pl.cpp index a8bd509..3b0ed70 100644 --- a/c/hdt4pl.cpp +++ b/c/hdt4pl.cpp @@ -215,6 +215,7 @@ PREDICATE(hdt_open, 3) int indexed = TRUE; PlTail options(A3); PlTerm opt; + char *name; while(options.next(opt)) { atom_t name; @@ -234,15 +235,18 @@ PREDICATE(hdt_open, 3) return PL_type_error("option", opt); } + if ( !PL_get_file_name(A2, &name, PL_FILE_EXIST) ) + return FALSE; + try { if ( access == ATOM_map ) { if ( indexed ) - hdt = HDTManager::mapIndexedHDT(A2); + hdt = HDTManager::mapIndexedHDT(name); else hdt = HDTManager::mapHDT(A2); } else if ( access == ATOM_load ) { if ( indexed ) - hdt = HDTManager::loadIndexedHDT(A2); + hdt = HDTManager::loadIndexedHDT(name); else hdt = HDTManager::loadHDT(A2); } else @@ -752,7 +756,7 @@ PREDICATE(hdt_search_cost_id, 5) try { TripleID t(s,p,o); IteratorTripleID *it = symb->hdt->getTriples()->search(t); - int numResults = it->estimatedNumResults(); + long numResults = it->estimatedNumResults(); delete it; return (A5 = numResults); } CATCH_HDT; diff --git a/prolog/hdt.pl b/prolog/hdt.pl index 1d1b4b2..d6135b4 100644 --- a/prolog/hdt.pl +++ b/prolog/hdt.pl @@ -350,13 +350,14 @@ % % True if a triple with the indicated identifiers exists. -%% hdt_search_cost(HDT, ?S, ?P, ?O, -Cost:float) is det. +%% hdt_search_cost(HDT, ?S, ?P, ?O, -Cost:nonneg) is det. hdt_search_cost(HDT, S, P, O, Cost) :- Triple = t(S,P,O), TripleID = t(SID,PID,OID), hdt_pre_triple(HDT, Triple, TripleID), - hdt_search_cost_id(HDT, SID, PID, OID, Cost). + hdt_search_cost_id(HDT, SID, PID, OID, Cost), !. +hdt_search_cost(_, _, _, _, 0). /*******************************