Search in sources :

Example 6 with HashMappedList

use of org.hsqldb_voltpatches.lib.HashMappedList in project voltdb by VoltDB.

the class HSQLInterface method getXMLForTable.

/**
     * Get a serialized XML representation of a particular table.
     */
public VoltXMLElement getXMLForTable(String tableName) throws HSQLParseException {
    VoltXMLElement xml = emptySchema.duplicate();
    // search all the tables XXX probably could do this non-linearly,
    //  but i don't know about case-insensitivity yet
    HashMappedList hsqlTables = getHSQLTables();
    for (int i = 0; i < hsqlTables.size(); i++) {
        Table table = (Table) hsqlTables.get(i);
        String candidateTableName = table.getName().name;
        // found the table of interest
        if (candidateTableName.equalsIgnoreCase(tableName)) {
            VoltXMLElement vxmle = table.voltGetTableXML(sessionProxy);
            assert (vxmle != null);
            xml.children.add(vxmle);
            return xml;
        }
    }
    return null;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList)

Example 7 with HashMappedList

use of org.hsqldb_voltpatches.lib.HashMappedList in project voltdb by VoltDB.

the class HSQLInterface method getTableNames.

/**
     * @return The set of all table/view names in the schema.
     */
private Set<String> getTableNames() {
    Set<String> names = new HashSet<>();
    // load all the tables
    HashMappedList hsqlTables = getHSQLTables();
    for (int i = 0; i < hsqlTables.size(); i++) {
        Table table = (Table) hsqlTables.get(i);
        names.add(table.getName().name);
    }
    return names;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HashSet(java.util.HashSet)

Example 8 with HashMappedList

use of org.hsqldb_voltpatches.lib.HashMappedList in project voltdb by VoltDB.

the class HSQLInterface method printTables.

/**
     * Debug-only method that prints out the names of all
     * tables in the current schema.
     */
@SuppressWarnings("unused")
private void printTables() {
    try {
        String schemaName = sessionProxy.getSchemaName(null);
        System.out.println("*** Tables For Schema: " + schemaName + " ***");
    } catch (HsqlException caught) {
        caught.printStackTrace();
    }
    // load all the tables
    HashMappedList hsqlTables = getHSQLTables();
    for (int i = 0; i < hsqlTables.size(); i++) {
        Table table = (Table) hsqlTables.get(i);
        System.out.println(table.getName().name);
    }
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList)

Example 9 with HashMappedList

use of org.hsqldb_voltpatches.lib.HashMappedList in project voltdb by VoltDB.

the class HSQLInterface method getHSQLTables.

private HashMappedList getHSQLTables() {
    try {
        String schemaName = null;
        schemaName = sessionProxy.getSchemaName(null);
        // search all the tables XXX probably could do this non-linearly,
        //  but i don't know about case-insensitivity yet
        SchemaManager schemaManager = sessionProxy.getDatabase().schemaManager;
        return schemaManager.getTables(schemaName);
    } catch (HsqlException caught) {
        m_logger.warn("Unexpected error in the SQL parser", caught);
        return new HashMappedList();
    }
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList)

Example 10 with HashMappedList

use of org.hsqldb_voltpatches.lib.HashMappedList in project voltdb by VoltDB.

the class LobManager method createSchema.

public void createSchema() {
    sysLobSession = database.sessionManager.getSysLobSession();
    Session session = sysLobSession;
    InputStream fis = getClass().getResourceAsStream(resourceFileName);
    InputStreamReader reader = null;
    try {
        reader = new InputStreamReader(fis, "ISO-8859-1");
    } catch (Exception e) {
    }
    LineNumberReader lineReader = new LineNumberReader(reader);
    LineGroupReader lg = new LineGroupReader(lineReader, starters);
    HashMappedList map = lg.getAsMap();
    lg.close();
    String sql = (String) map.get("/*lob_schema_definition*/");
    Statement statement = session.compileStatement(sql);
    Result result = statement.execute(session);
    Table table = database.schemaManager.getTable(session, "BLOCKS", "SYSTEM_LOBS");
    //            table.isTransactional = false;
    getLob = session.compileStatement(getLobSQL);
    getLobPart = session.compileStatement(getLobPartSQL);
    createLob = session.compileStatement(createLobSQL);
    createLobPart = session.compileStatement(createLobPartSQL);
    divideLobPart = session.compileStatement(divideLobPartSQL);
    deleteLob = session.compileStatement(deleteLobSQL);
    deleteLobPart = session.compileStatement(deleteLobPartSQL);
    setLobLength = session.compileStatement(updateLobLengthSQL);
    setLobUsage = session.compileStatement(updateLobUsageSQL);
    getNextLobId = session.compileStatement(getNextLobIdSQL);
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) Table(org.hsqldb_voltpatches.Table) InputStreamReader(java.io.InputStreamReader) LineGroupReader(org.hsqldb_voltpatches.lib.LineGroupReader) HsqlByteArrayInputStream(org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream) InputStream(java.io.InputStream) Statement(org.hsqldb_voltpatches.Statement) IOException(java.io.IOException) EOFException(java.io.EOFException) HsqlException(org.hsqldb_voltpatches.HsqlException) Session(org.hsqldb_voltpatches.Session) LineNumberReader(java.io.LineNumberReader) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)23 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)4 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)4 HashSet (org.hsqldb_voltpatches.lib.HashSet)3 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)3 Index (org.hsqldb_voltpatches.index.Index)2 Iterator (org.hsqldb_voltpatches.lib.Iterator)2 RowIterator (org.hsqldb_voltpatches.navigator.RowIterator)2 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)2 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)2 Result (org.hsqldb_voltpatches.result.Result)2 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 HashSet (java.util.HashSet)1 HsqlException (org.hsqldb_voltpatches.HsqlException)1 SimpleName (org.hsqldb_voltpatches.HsqlNameManager.SimpleName)1 RangeIteratorBase (org.hsqldb_voltpatches.RangeVariable.RangeIteratorBase)1