Do you know where it is explained, how the predicates receive their “namespaces” when we create them using csv_read_file_row?
I’ve tried to assemble a predicate that stores data from .CSV in a tight loop with csv_read_file_row; I’ve put this function besides rdb_assertz/2 into rocks_preds.pl and instead of user:application (my CSV rows are transformed into application predicate), PI became just application — see rocks-predicates/rocks_preds.pl at 3071007fa6beed347418e4ed5ddcfa4af98f62a1 · JanWielemaker/rocks-predicates · GitHub
This is essentially what I use to write to RDB:
rdb_assertz_from_csv(File, Pred) :-
default_db(Dir),
rdb_assertz_from_csv(Dir, File, Pred).
rdb_assertz_from_csv(Dir, File, Pred) :-
csv_read_file_row(File, FirstClause, [functor(Pred), line(1)]),
rdb_open(Dir, DB),
clause_head_body(FirstClause, FirstHead, _FirstBody),
pi_head(PI, FirstHead),
% print(PI),
pred_property_key(PI, last_clause, KeyLC),
( rocks_get(DB, KeyLC, Id)
-> NId is Id+0
; register_predicate(DB, PI),
NId is 0
),
% Writing the rows...
forall( csv_read_file_row(File, Clause, [functor(Pred), line(LineNumber)]),
(
LineId is LineNumber + NId,
rocks_put(DB, KeyLC, LineId),
pred_clause_key(PI, LineId, KeyClause),
clause_head_body(Clause, Head, Body),
rocks_put(DB, KeyClause, (Head:-Body)),
add_to_indexes(DB, PI, Head, KeyClause)
% print((PI, KeyClause))
)
).