Interface RDBMSStorageLayout

All Known Implementing Classes:
AdHocSQLLayout, EncodingAdHocSQLLayout, NaturalSQLLayout

public interface RDBMSStorageLayout
This represents how the RDBMS stores atoms into tables and rows.
  • Field Details

    • ATOM_TABLE_PREDICATE_PREFIX

      static final String ATOM_TABLE_PREDICATE_PREFIX
      Prefix used for predicate-backed atom tables.
      See Also:
    • TERM_TABLE_NAME

      static final String TERM_TABLE_NAME
      Name of the table storing serialized terms.
      See Also:
    • PREDICATE_TABLE_NAME

      static final String PREDICATE_TABLE_NAME
      Name of the table storing predicates and their backing atom tables.
      See Also:
    • INDEX_NAME_PREFIX

      static final String INDEX_NAME_PREFIX
      Prefix used for generated SQL index names.
      See Also:
  • 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

      String getTableName(Atom atom) throws SQLException
      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

      void handleTerms(Set<Term> all_terms) throws SQLException
      Handles the given terms, storing them if needed.
      Parameters:
      all_terms - the terms to handle
      Throws:
      SQLException - if an exception occur
    • getColumnName

      String getColumnName(String table, int term_index)
      Returns the name of the column storing a term at a given position.
      Parameters:
      table - the name of the database table
      term_index - the column number
      Returns:
      The name of the column which store the term at the given index in the given table
    • addSpecificConditions

      SQLParameterizedQuery addSpecificConditions(String sql_query, List<Object> arguments, FOQuery<?> q)
      Adds layout-specific conditions to an SQL query.
      Parameters:
      sql_query - an SQL query represented as string
      arguments - the arguments to add to the query
      q - the query for the conditions
      Returns:
      is not yet defined
    • hasCorrectDatabaseSchema

      boolean hasCorrectDatabaseSchema(RDBMSDriver driver) throws SQLException
      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

      void createDatabaseSchema(RDBMSDriver driver) throws SQLException
      Creates the schema associated with this layout on the given database.
      Parameters:
      driver - the database driver
      Throws:
      SQLException - if an exception occur
    • getAllTableNames

      Collection<String> getAllTableNames() throws SQLException
      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

      Collection<Predicate> getAllPredicates(PredicateFactory factory) throws SQLException
      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

      Term createTerm(String term, TermFactory factory) throws SQLException
      Recreates a term from its stored representation.

      This is the reverse operation of getRepresentation

      Parameters:
      term - string representation
      factory - to instantiate the term
      Returns:
      the term associated with the given string representation
      Throws:
      SQLException - if an exception occur
    • createPredicate

      Predicate createPredicate(String predicate, int arity, PredicateFactory factory)
      Recreates a predicate from its stored representation and arity.
      Parameters:
      predicate - string representation
      arity - predicate arity
      factory - to instantiate the predicate
      Returns:
      the predicate associated with the given string representation and arity
    • getRepresentation

      default Object getRepresentation(Term t) throws SQLException
      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