Interface RDBMSStorageLayout
- All Known Implementing Classes:
AdHocSQLLayout, EncodingAdHocSQLLayout, NaturalSQLLayout
public interface RDBMSStorageLayout
This represents how the RDBMS stores atoms into tables and rows.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix used for predicate-backed atom tables.static final StringPrefix used for generated SQL index names.static final StringName of the table storing predicates and their backing atom tables.static final StringName of the table storing serialized terms. -
Method Summary
Modifier and TypeMethodDescriptionaddSpecificConditions(String sql_query, List<Object> arguments, FOQuery<?> q) Adds layout-specific conditions to an SQL query.booleanFiltering of the query is represented by the WHERE conditions in SQL.voidcreateDatabaseSchema(RDBMSDriver driver) Creates the schema associated with this layout on the given database.createPredicate(String predicate, int arity, PredicateFactory factory) Recreates a predicate from its stored representation and arity.createTerm(String term, TermFactory factory) Recreates a term from its stored representation.getAllPredicates(PredicateFactory factory) Returns all predicates known to the underlying database.Returns the names of all atom tables.getColumnName(String table, int term_index) Returns the name of the column storing a term at a given position.default ObjectReturns the storage representation of a term.getTableName(Atom atom) Returns the atom table name for the supplied atom, creating it if needed.Returns the name of the terms table.voidhandleTerms(Set<Term> all_terms) Handles the given terms, storing them if needed.booleanhasCorrectDatabaseSchema(RDBMSDriver driver) Checks whether the database schema matches this storage layout.
-
Field Details
-
ATOM_TABLE_PREDICATE_PREFIX
Prefix used for predicate-backed atom tables.- See Also:
-
TERM_TABLE_NAME
-
PREDICATE_TABLE_NAME
Name of the table storing predicates and their backing atom tables.- See Also:
-
INDEX_NAME_PREFIX
-
-
Method Details
-
canHandleFiltering
boolean canHandleFiltering()Filtering of the query is represented by the WHERE conditions in SQL. If the strategy can generate the conditions in every case, then this method should return true. Otherwise, it should return false and additional filtering will be needed- Returns:
- true iff this strategy can handle complete filtering of the query
-
getTableName
Returns the atom table name for the supplied atom, creating it if needed.If the table in which the given atom does not exist, this method creates it and return its name
- Parameters:
atom- the atom for which to get the table name- Returns:
- The name of the table in which the given atom is stored
- Throws:
SQLException- if an exception occur
-
handleTerms
Handles the given terms, storing them if needed.- Parameters:
all_terms- the terms to handle- Throws:
SQLException- if an exception occur
-
getColumnName
-
addSpecificConditions
Adds layout-specific conditions to an SQL query.- Parameters:
sql_query- an SQL query represented as stringarguments- the arguments to add to the queryq- the query for the conditions- Returns:
- is not yet defined
-
hasCorrectDatabaseSchema
Checks whether the database schema matches this storage layout.- Parameters:
driver- the database driver- Returns:
- true iff the given driver's database have the correct schema of data for this strategy
- Throws:
SQLException- if an exception occur
-
createDatabaseSchema
Creates the schema associated with this layout on the given database.- Parameters:
driver- the database driver- Throws:
SQLException- if an exception occur
-
getAllTableNames
Returns the names of all atom tables.- Returns:
- the name of all the tables storing atoms
- Throws:
SQLException- if an exception occur
-
getTermsTableName
String getTermsTableName()Returns the name of the terms table.- Returns:
- The name of the terms table
-
getAllPredicates
Returns all predicates known to the underlying database.- Parameters:
factory- the predicate factory- Returns:
- all the predicates stored in the database; even if no atom exists with this predicate
- Throws:
SQLException- if an exception occur
-
createTerm
Recreates a term from its stored representation.This is the reverse operation of getRepresentation
- Parameters:
term- string representationfactory- to instantiate the term- Returns:
- the term associated with the given string representation
- Throws:
SQLException- if an exception occur
-
createPredicate
Recreates a predicate from its stored representation and arity.- Parameters:
predicate- string representationarity- predicate arityfactory- to instantiate the predicate- Returns:
- the predicate associated with the given string representation and arity
-
getRepresentation
Returns the storage representation of a term.This is the reverse operation of createTerm
- Parameters:
t- the term- Returns:
- the string representation according to the storage strategy of the given term
- Throws:
SQLException- if an exception occur
-