org.nsdl.mptstore.core
Interface TableManager

All Known Implementing Classes:
BasicTableManager

public interface TableManager

Provides thread-safe read/write access to the tables used by MPTStore. Implementations of this interface will typically cache the predicate-to-table mappings in memory, and will always persist them to the database.

Author:
cwilper@cs.cornell.edu

Method Summary
 int dropAllPredicateTables()
          Drop all predicate tables and mappings, effectively re-initializing the triplestore.
 int dropEmptyPredicateTables()
          Drop all unused predicate tables and mappings.
 java.lang.String getOrMapTableFor(PredicateNode predicate)
          Get the name of the table reserved for relationships of the given type.
 PredicateNode getPredicateFor(java.lang.String table)
          Get the predicate that's mapped to the given table, if such a mapping exists.
 java.util.Set<PredicateNode> getPredicates()
          Get the set of predicates for which a table mapping exists.
 java.lang.String getTableFor(PredicateNode predicate)
          Get the name of the table reserved for relationships of the given type, if it exists.
 java.util.Set<java.lang.String> getTables()
          Get the set of tables that store per-predicate relationships.
 

Method Detail

getOrMapTableFor

java.lang.String getOrMapTableFor(PredicateNode predicate)
                                  throws java.sql.SQLException
Get the name of the table reserved for relationships of the given type.

If such a table does not yet exist, it will be automatically created and permanently associated with the given predicate.

Parameters:
predicate - The type of relationship.
Returns:
The table name for the given predicate, never null.
Throws:
java.sql.SQLException - if a database error occurs while the table is

getTableFor

java.lang.String getTableFor(PredicateNode predicate)
Get the name of the table reserved for relationships of the given type, if it exists.

Parameters:
predicate - The type of relationship.
Returns:
The table name for the given predicate, or null if no such predicate exists in the graph.

getPredicateFor

PredicateNode getPredicateFor(java.lang.String table)
Get the predicate that's mapped to the given table, if such a mapping exists.

Parameters:
table - The name of the table.
Returns:
The predicate, or null if no such mapping exists.

getTables

java.util.Set<java.lang.String> getTables()
Get the set of tables that store per-predicate relationships.

Returns:
A set with zero or more table names.

getPredicates

java.util.Set<PredicateNode> getPredicates()
Get the set of predicates for which a table mapping exists.

Returns:
A set with zero or more predicates.

dropEmptyPredicateTables

int dropEmptyPredicateTables()
                             throws java.sql.SQLException
Drop all unused predicate tables and mappings.

Returns:
the number of dropped predicate tables.
Throws:
java.sql.SQLException - if a database error occured during the operation.

dropAllPredicateTables

int dropAllPredicateTables()
                           throws java.sql.SQLException
Drop all predicate tables and mappings, effectively re-initializing the triplestore.

Returns:
the number of dropped predicate tables.
Throws:
java.sql.SQLException - if a database error occured during the operation.