public abstract class Database extends Object implements ReadableDatabase, WritableDatabase
GroundAtoms
.
Every GroundAtom retrieved from a Database is either a RandomVariableAtom
or an ObservedAtom
. The method ReadableDatabase.getAtom(Predicate, Constant...)
determines which type a GroundAtom is. In addition, a GroundAtom with a
StandardPredicate
can be persisted in a Database. If a
GroundAtom is persisted, it is persisted in one of the Partitions the
Database can read and is available for querying via ReadableDatabase.executeQuery(DatabaseQuery)
.
DataStore.getDatabase(org.linqs.psl.database.Partition, org.linqs.psl.database.Partition...)
methods.
A Database writes to and reads from one Partition
of a DataStore
and can read from additional Partitions. The write Partition of a Database
may not be a read (or write) Partition of any other Database managed by the datastore.
A Database can be instantiated with a set of StandardPredicates
to close. (Any StandardPredicate not closed initially remains open.) Whether
a StandardPredicate is open or closed affects the behavior of
ReadableDatabase.getAtom(Predicate, Constant...)
.
ReadableDatabase.getAtom(Predicate, Constant...)
to ensure there exists only a single object for each GroundAtom from the Database.
A Database contains an AtomCache
which is used to store GroundAtoms
that have been instantiated in memory and ensure these objects are unique.
commit(RandomVariableAtom)
or
RandomVariableAtom.commitToDB()
.
DatabaseQueries
can be run via ReadableDatabase.executeQuery(DatabaseQuery)
.
Note that queries only act on the GroundAtoms persisted in Partitions and
GroundAtoms with FunctionalPredicates.Modifier and Type | Field and Description |
---|---|
protected AtomCache |
cache
The atom cache for this database.
|
protected boolean |
closed
Keeps track of the open / closed status of this database.
|
protected DataStore |
parentDataStore
The backing data store that created this database.
|
protected List<Integer> |
readIDs |
protected List<Partition> |
readPartitions
The partition IDs that this database reads from.
|
protected int |
writeID |
protected Partition |
writePartition
The partition ID in which this database writes.
|
Constructor and Description |
---|
Database(DataStore parent,
Partition write,
Partition[] read) |
Modifier and Type | Method and Description |
---|---|
void |
commit(RandomVariableAtom atom)
Persists a RandomVariableAtom in this Database's write Partition.
|
int |
countAllGroundAtoms(StandardPredicate predicate)
Get a count of all the ground atoms for a predicate.
|
abstract int |
countAllGroundAtoms(StandardPredicate predicate,
List<Integer> partitions) |
int |
countAllGroundRandomVariableAtoms(StandardPredicate predicate)
Get a count of all the ground RandomVariableAtoms for a predicate.
|
List<GroundAtom> |
getAllGroundAtoms(StandardPredicate predicate)
Fetch all the ground atoms for a predicate.
|
abstract List<GroundAtom> |
getAllGroundAtoms(StandardPredicate predicate,
List<Integer> partitions) |
List<ObservedAtom> |
getAllGroundObservedAtoms(StandardPredicate predicate)
Fetch all the ground ObservedAtoms for a predicate.
|
List<RandomVariableAtom> |
getAllGroundRandomVariableAtoms(StandardPredicate predicate)
Fetch all the ground RandomVariableAtoms for a predicate.
|
abstract GroundAtom |
getAtom(StandardPredicate predicate,
boolean create,
Constant... arguments) |
DataStore |
getDataStore() |
List<Partition> |
getReadPartitions() |
Partition |
getWritePartition() |
boolean |
hasAtom(StandardPredicate predicate,
Constant... arguments)
Check to see if a ground atom exists in the database.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
executeGroundingQuery, executeQuery, getAtom, isClosed
close, commit, commit, deleteAtom, moveToWritePartition
protected final DataStore parentDataStore
protected final Partition writePartition
protected final int writeID
protected final List<Partition> readPartitions
protected final AtomCache cache
protected boolean closed
public abstract GroundAtom getAtom(StandardPredicate predicate, boolean create, Constant... arguments)
public boolean hasAtom(StandardPredicate predicate, Constant... arguments)
ReadableDatabase
hasAtom
in interface ReadableDatabase
public int countAllGroundAtoms(StandardPredicate predicate)
ReadableDatabase
countAllGroundAtoms
in interface ReadableDatabase
public abstract int countAllGroundAtoms(StandardPredicate predicate, List<Integer> partitions)
public int countAllGroundRandomVariableAtoms(StandardPredicate predicate)
ReadableDatabase
countAllGroundRandomVariableAtoms
in interface ReadableDatabase
public List<GroundAtom> getAllGroundAtoms(StandardPredicate predicate)
ReadableDatabase
getAllGroundAtoms
in interface ReadableDatabase
public abstract List<GroundAtom> getAllGroundAtoms(StandardPredicate predicate, List<Integer> partitions)
public List<RandomVariableAtom> getAllGroundRandomVariableAtoms(StandardPredicate predicate)
ReadableDatabase
getAllGroundRandomVariableAtoms
in interface ReadableDatabase
public List<ObservedAtom> getAllGroundObservedAtoms(StandardPredicate predicate)
ReadableDatabase
getAllGroundObservedAtoms
in interface ReadableDatabase
public void commit(RandomVariableAtom atom)
WritableDatabase
commit
in interface WritableDatabase
public DataStore getDataStore()
public Partition getWritePartition()
Copyright © 2018 University of California, Santa Cruz. All rights reserved.