public class RDBMSDataStore extends Object implements DataStore
DatabaseDriver
implementation, and
through the ConfigBundle
can use custom names for its value, confidence, and
partition columns.
The ConfigBundle can also specify whether or not this RDBMSDatabase should use
RDBMSUniqueStringID
for its UniqueID implementation (as opposed to using
RDBMSUniqueIntID
).
Modifier and Type | Field and Description |
---|---|
static String |
CONFIDENCE_COLUMN_DEFAULT
Default value for the CONFIDENCE_COLUMN_KEY property
|
static String |
CONFIDENCE_COLUMN_KEY
Key for String property for the name of the confidence column in the database.
|
static String |
CONFIG_PREFIX
Prefix of property keys used by this class.
|
static String |
PARTITION_COLUMN_DEFAULT
Default value for the PARTITION_COLUMN_KEY property
|
static String |
PARTITION_COLUMN_KEY
Key for String property for the name of the partition column in the database.
|
static boolean |
USE_STRING_ID_DEFAULT
Default value for the USE_STRING_ID_KEY property
|
static String |
USE_STRING_ID_KEY
Key for boolean property of whether to use
RDBMSUniqueStringID as a UniqueID. |
static String |
VALUE_COLUMN_DEFAULT
Default value for the VALUE_COLUMN_KEY property
|
static String |
VALUE_COLUMN_KEY
Key for String property for the name of the value column in the database.
|
Constructor and Description |
---|
RDBMSDataStore(DatabaseDriver dbDriver,
ConfigBundle config)
Returns an RDBMSDataStore that utilizes the connection created by the
DatabaseDriver . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases all resources and locks obtained by this DataStore.
|
int |
deletePartition(Partition partition)
Deletes all
GroundAtoms persisted in a Partition. |
Database |
getDatabase(Partition write,
Partition... read)
Creates a Database that can read from and write to a
Partition and
optionally read from additional Partitions. |
Database |
getDatabase(Partition write,
Set<StandardPredicate> toClose,
Partition... read)
Creates a Database that can read from and write to a
Partition and
optionally read from additional Partitions. |
static String |
getDatabaseID(RDBMSDatabase db)
Registers and returns an ID for a given RDBMSDatabase.
|
Inserter |
getInserter(StandardPredicate predicate,
Partition partition)
Creates an Inserter for persisting new
GroundAtoms
in a Partition . |
Partition |
getNextPartition()
Get the next available partition
|
Set<StandardPredicate> |
getRegisteredPredicates()
Returns the set of StandardPredicates registered with this DataStore.
|
static String |
getSimilarityFunctionID(ExternalFunction extFun)
Registers and returns an ID for a given ExternalFunction.
|
UniqueID |
getUniqueID(Object key)
Returns a UniqueID based on the given key.
|
Updater |
getUpdater(StandardPredicate predicate,
Partition partition)
Creates an Updater for updating
GroundAtoms persisted
in a Partition . |
static double |
registeredExternalFunctionCall(String databaseID,
String functionID,
String... args)
Used by the RDBMS to make an external function call.
|
void |
registerPredicate(StandardPredicate predicate)
Registers a StandardPredicate so that
GroundAtoms of that
StandardPredicate can be persisted in this DataStore. |
protected void |
releasePartitions(RDBMSDatabase db) |
public static final String CONFIG_PREFIX
ConfigManager
,
Constant Field Valuespublic static final String VALUE_COLUMN_KEY
public static final String VALUE_COLUMN_DEFAULT
public static final String CONFIDENCE_COLUMN_KEY
public static final String CONFIDENCE_COLUMN_DEFAULT
public static final String PARTITION_COLUMN_KEY
public static final String PARTITION_COLUMN_DEFAULT
public static final String USE_STRING_ID_KEY
RDBMSUniqueStringID
as a UniqueID.public static final boolean USE_STRING_ID_DEFAULT
public RDBMSDataStore(DatabaseDriver dbDriver, ConfigBundle config)
DatabaseDriver
.dbDriver
- the DatabaseDriver that contains a connection to the backing database.config
- the configuration for this DataStore.public void registerPredicate(StandardPredicate predicate)
DataStore
GroundAtoms
of that
StandardPredicate can be persisted in this DataStore.
If GroundAtoms of a StandardPredicate were already persisted in this DataStore at initialization, that StandardPredicate is already registered.
registerPredicate
in interface DataStore
predicate
- the predicate to registerpublic Database getDatabase(Partition write, Partition... read)
DataStore
Partition
and
optionally read from additional Partitions.getDatabase
in interface DataStore
write
- the Partition to write to and read fromread
- additional Partitions to read frompublic Database getDatabase(Partition write, Set<StandardPredicate> toClose, Partition... read)
DataStore
Partition
and
optionally read from additional Partitions.
Additionally, defines a set of StandardPredicates as closed in the Database, meaning that all GroundAtoms of that Predicate are ObservedAtoms.
getDatabase
in interface DataStore
write
- the Partition to write to and read fromtoClose
- set of StandardPredicates to closeread
- additional Partitions to read frompublic UniqueID getUniqueID(Object key)
DataStore
An Integer must always be a valid key. Other types may be supported by implementations and/or configurations.
If two keys are equal, they must map to the same UniqueID.
getUniqueID
in interface DataStore
key
- the key to a UniqueIDpublic Inserter getInserter(StandardPredicate predicate, Partition partition)
DataStore
GroundAtoms
in a Partition
.getInserter
in interface DataStore
predicate
- the Predicate of the Atoms to be insertedpartition
- the Partition into which Atoms will be insertedpublic Updater getUpdater(StandardPredicate predicate, Partition partition)
DataStore
GroundAtoms
persisted
in a Partition
.getUpdater
in interface DataStore
predicate
- the Predicate of the Atoms to be updatedpartition
- the Partition of the Atoms to be updatedpublic Set<StandardPredicate> getRegisteredPredicates()
DataStore
Database.getRegisteredPredicates()
on an associated Database,
since additional predicates might have been registered since that Database
was created.getRegisteredPredicates
in interface DataStore
public int deletePartition(Partition partition)
DataStore
GroundAtoms
persisted in a Partition.deletePartition
in interface DataStore
partition
- the partition to deletepublic Partition getNextPartition()
DataStore
getNextPartition
in interface DataStore
public void close()
DataStore
protected void releasePartitions(RDBMSDatabase db)
public static final String getSimilarityFunctionID(ExternalFunction extFun)
extFun
- the ExternalFunction to registerpublic static final String getDatabaseID(RDBMSDatabase db)
db
- the RDBMSDatabase to registerpublic static final double registeredExternalFunctionCall(String databaseID, String functionID, String... args)
databaseID
- the ID for the RDBMSDatabase
associated with this function callfunctionID
- the ID of the ExternalFunction
to executeargs
- the arguments for the ExternalFunction