Class RecordedDatabase
- java.lang.Object
-
- org.projog.core.predicate.builtin.db.RecordedDatabase
-
public class RecordedDatabase extends java.lang.ObjectProvides a mechanism to associate a term with a key.Multiple terms can be associated with the same key.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classRecordedDatabase.Chainprivate static classRecordedDatabase.ChainIteratorprivate classRecordedDatabase.DatabaseIteratorprivate static classRecordedDatabase.Link
-
Field Summary
Fields Modifier and Type Field Description private java.util.SortedMap<PredicateKey,RecordedDatabase.Chain>chainsprivate java.util.List<PredicateKey>keysprivate java.util.concurrent.atomic.AtomicLongreferenceCtrprivate java.util.SortedMap<java.lang.Long,RecordedDatabase.Link>references
-
Constructor Summary
Constructors Constructor Description RecordedDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) IntegerNumberadd(PredicateKey key, Term value, boolean addLast)Associates a value with a key.private voidaddReference(IntegerNumber reference, RecordedDatabase.Link link, boolean addLast)private RecordedDatabase.ChaincreateChain(PredicateKey key)private RecordedDatabase.LinkcreateLink(RecordedDatabase.Chain chain, Term value, boolean addLast)private IntegerNumbercreateReference()(package private) booleanerase(java.lang.Long reference)(package private) java.util.Iterator<Record>getAll()(package private) java.util.Iterator<Record>getChain(PredicateKey key)private RecordedDatabase.ChaingetOrCreateChain(PredicateKey key)private booleanremoveReference(java.lang.Long reference)
-
-
-
Field Detail
-
referenceCtr
private final java.util.concurrent.atomic.AtomicLong referenceCtr
-
references
private final java.util.SortedMap<java.lang.Long,RecordedDatabase.Link> references
-
keys
private final java.util.List<PredicateKey> keys
-
chains
private final java.util.SortedMap<PredicateKey,RecordedDatabase.Chain> chains
-
-
Method Detail
-
add
IntegerNumber add(PredicateKey key, Term value, boolean addLast)
Associates a value with a key.- Parameters:
key- the key to associate the value withvalue- the value to store- Returns:
- reference for the newly added value
-
getAll
java.util.Iterator<Record> getAll()
-
getChain
java.util.Iterator<Record> getChain(PredicateKey key)
-
erase
boolean erase(java.lang.Long reference)
- Parameters:
reference- the reference of the term to remove- Returns:
trueif a term was removed elsefalse(i.e. if there was no term associated with the specifiedreference)
-
getOrCreateChain
private RecordedDatabase.Chain getOrCreateChain(PredicateKey key)
-
createChain
private RecordedDatabase.Chain createChain(PredicateKey key)
-
createLink
private RecordedDatabase.Link createLink(RecordedDatabase.Chain chain, Term value, boolean addLast)
-
createReference
private IntegerNumber createReference()
-
addReference
private void addReference(IntegerNumber reference, RecordedDatabase.Link link, boolean addLast)
-
removeReference
private boolean removeReference(java.lang.Long reference)
-
-