Implementation of The Internal data-nase¶
There are two options to implement traditional immediate update semantics.
- In the first option, we only remove an element of the chain when it is physically disposed of. This simplifies things, because pointers are always valid, but it complicates some stuff a bit:
o You may have go through long lines of deleted db entries before you actually reach the one you want.
o Deleted clauses are also not removed of the chain. The solution was to place a fail in every clause, but you still have to backtrack through failed clauses.
An alternative solution is to remove clauses from the chain, even if they are still phisically present. Unfortunately this creates problems because immediate update semantics means you have to backtrack clauses or see the db entries stored later.
There are several solutions. One of the simplest is to use an age counter. When you backtrack to a removed clause or to a deleted db entry you use the age to find newly entered clauses in the DB.
This still causes a problem when you backtrack to a deleted clause, because clauses are supposed to point to the next alternative, and having been removed from the chain you cannot point there directly. One solution is to have a predicate in C that recovers the place where to go to and then gets rid of the clause.
Define:¶
Functions:¶
1. static UInt new_trail_size(void):
1. static int recover_from_record_error(void):
1. static void init_int_keys(void):
1. static DBProp FetchIntDBPropFromKey(Int key, int flag, int new, char *error_mssg):
1. static Prop FindDBPropHavingLock(AtomEntry *ae, int CodeDB, unsigned int arity, Term dbmod):
1. static Prop FindDBProp(AtomEntry *ae, int CodeDB, unsigned int arity, Term dbmod):
1. static DBProp FetchDBPropFromKey(Term twork, int flag, int new, char *error_mssg):
1. static void init_int_lu_keys(void):
1. static int resize_int_keys(UInt new_size):
1. static DBProp find_int_key(Int key):
1. static PredEntry * new_lu_int_key(Int key):
1. static PredEntry * find_lu_int_key(Int key):
1. PredEntry * Yap_FindLUIntKey(Int key):
1. static PredEntry * new_lu_entry(Term t):
1. static DBProp find_entry(Term t):
1. static PredEntry * find_lu_entry(Term t):
1. static CELL * cpcells(CELL to, CELL from, Int n):
1. static void linkblk(link_entry r, CELL c, CELL offs):
1. static Int cmpclls(CELL a, CELL b, Int n):
1. static CELL CalcKey(Term tw):
1. static CELL EvalMasks(register Term tm, CELL *keyp):
1. CELL Yap_EvalMasks(register Term tm, CELL *keyp):
1. static CELL * copy_long_int(CELL st, CELL pt):
1. static CELL * copy_double(CELL st, CELL pt):
1. static CELL * copy_string(CELL st, CELL pt):
1. static CELL * copy_big_int(CELL st, CELL pt):
1. static CELL * MkDBTerm(register CELL pt0, register CELL pt0_end, register CELL StoPoint, CELL CodeMax, CELL tbase, CELL attachmentsp, int vars_foundp, struct db_globs dbg):
1. static DBRef check_if_cons(DBRef p, Term to_compare):
1. static DBRef check_if_var(DBRef p):
1. static DBRef check_if_wvars(DBRef p, unsigned int NOfCells, CELL *BTptr):
1. static int scheckcells(int NOfCells, register CELL m1, register CELL m2, link_entry *lp, register CELL bp):
1. static DBRef check_if_nvars(DBRef p, unsigned int NOfCells, CELL BTptr, struct db_globs dbg):
1. static DBRef generate_dberror_msg(int errnumb, UInt sz, char *msg):
1. static DBRef CreateDBWithDBRef(Term Tm, DBProp p, struct db_globs *dbg):
1. static DBTerm * CreateDBTermForAtom(Term Tm, UInt extra_size, struct db_globs *dbg):
1. static DBTerm * CreateDBTermForVar(UInt extra_size, struct db_globs *dbg):
1. static DBRef CreateDBRefForAtom(Term Tm, DBProp p, int InFlag, struct db_globs *dbg):
1. static DBRef CreateDBRefForVar(Term Tm, DBProp p, int InFlag, struct db_globs *dbg):
1. static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int pstat, UInt extra_size, struct db_globs dbg):
1. static DBRef record(int Flag, Term key, Term t_data, Term t_code USES_REGS):
1. static DBRef record_at(int Flag, DBRef r0, Term t_data, Term t_code USES_REGS):
1. static LogUpdClause * new_lu_db_entry(Term t, PredEntry *pe):
1. LogUpdClause * Yap_new_ludbe(Term t, PredEntry *pe, UInt nargs):
1. static LogUpdClause * record_lu(PredEntry *pe, Term t, int position):
1. static LogUpdClause * record_lu_at(int position, LogUpdClause *ocl, Term t):