Package org.hsqldb.lib

Examples of org.hsqldb.lib.IntKeyHashMap$KeySet


     */
    private IntKeyHashMap getDBNameArray() {

        final String  prefix       = ServerProperties.sc_key_dbname + ".";
        final int     prefixLen    = prefix.length();
        IntKeyHashMap idToAliasMap = new IntKeyHashMap();
        Enumeration   en           = serverProperties.propertyNames();

        for (; en.hasMoreElements(); ) {
            String key = (String) en.nextElement();

            if (!key.startsWith(prefix)) {
                continue;
            }

            int dbNumber;

            try {
                dbNumber = Integer.parseInt(key.substring(prefixLen));
            } catch (NumberFormatException e1) {
                printWithThread("maformed database enumerator: " + key);

                continue;
            }

            String alias = serverProperties.getProperty(key).toLowerCase();

            if (!aliasSet.add(alias)) {
                printWithThread("duplicate alias: " + alias);
            }

            Object existing = idToAliasMap.put(dbNumber, alias);

            if (existing != null) {
                printWithThread("duplicate database enumerator: " + key);
            }
        }
View Full Code Here


    /**
     * Initialises the database attributes lists from the server properties object.
     */
    private void setDBInfoArrays() {

        IntKeyHashMap dbNumberMap  = getDBNameArray();
        int           maxDatabases = dbNumberMap.size();

        if (serverProperties.isPropertyTrue(
                ServerProperties.sc_key_remote_open_db)) {
            int max = serverProperties.getIntegerProperty(
                ServerProperties.sc_key_max_databases,
                ServerConstants.SC_DEFAULT_MAX_DATABASES);

            if (maxDatabases < max) {
                maxDatabases = max;
            }
        }

        dbAlias          = new String[maxDatabases];
        dbPath           = new String[dbAlias.length];
        dbType           = new String[dbAlias.length];
        dbID             = new int[dbAlias.length];
        dbActionSequence = new long[dbAlias.length];
        dbProps          = new HsqlProperties[dbAlias.length];

        Iterator it = dbNumberMap.keySet().iterator();

        for (int i = 0; it.hasNext(); ) {
            int    dbNumber = it.nextInt();
            String path     = getDatabasePath(dbNumber, true);

            if (path == null) {
                printWithThread("missing database path: "
                                + dbNumberMap.get(dbNumber));

                continue;
            }

            HsqlProperties dbURL = DatabaseURL.parseURL(path, false, false);

            if (dbURL == null) {
                printWithThread("malformed database path: " + path);

                continue;
            }

            dbAlias[i] = (String) dbNumberMap.get(dbNumber);
            dbPath[i= dbURL.getProperty("database");
            dbType[i= dbURL.getProperty("connection_type");
            dbProps[i] = dbURL;

            i++;
View Full Code Here

     */
    private IntKeyHashMap getDBNameArray() {

        final String  prefix       = ServerProperties.sc_key_dbname + ".";
        final int     prefixLen    = prefix.length();
        IntKeyHashMap idToAliasMap = new IntKeyHashMap();
        Enumeration   en           = serverProperties.propertyNames();

        for (; en.hasMoreElements(); ) {
            String key = (String) en.nextElement();

            if (!key.startsWith(prefix)) {
                continue;
            }

            int dbNumber;

            try {
                dbNumber = Integer.parseInt(key.substring(prefixLen));
            } catch (NumberFormatException e1) {
                printWithThread("maformed database enumerator: " + key);

                continue;
            }

            String alias = serverProperties.getProperty(key).toLowerCase();

            if (!aliasSet.add(alias)) {
                printWithThread("duplicate alias: " + alias);
            }

            Object existing = idToAliasMap.put(dbNumber, alias);

            if (existing != null) {
                printWithThread("duplicate database enumerator: " + key);
            }
        }
View Full Code Here

     *      manage compiled statement objects.
     */
    StatementManager(Database database) {

        this.database = database;
        schemaMap     = new IntKeyHashMap();
        csidMap       = new LongKeyHashMap();
        next_cs_id    = 0;
    }
View Full Code Here

            if (indexArrayKeepMap == null) {
                if (root == null) {
                    return;
                }

                indexArrayKeepMap = new IntKeyHashMap();
            }

            indexArrayKeepMap.put(index.hashCode(), root);
        } else {
            if (indexArrayMap == null) {
                if (root == null) {
                    return;
                }

                indexArrayMap = new IntKeyHashMap();
            }

            indexArrayMap.put(index.hashCode(), root);
        }
    }
View Full Code Here

     * @throws  HsqlException
     */
    public static void runScript(Database database, String logFilename,
                                 int logType) throws HsqlException {

        IntKeyHashMap sessionMap = new IntKeyHashMap();
        Session sysSession = database.getSessionManager().getSysSession();
        Session       current    = sysSession;
        int           currentId  = 0;

        database.setReferentialIntegrity(false);

        ScriptReaderBase scr = null;

        try {
            StopWatch sw = new StopWatch();

            scr = ScriptReaderBase.newScriptReader(database, logFilename,
                                                   logType);

            while (scr.readLoggedStatement(current)) {
                int sessionId = scr.getSessionNumber();

                if (currentId != sessionId) {
                    currentId = sessionId;
                    current   = (Session) sessionMap.get(currentId);

                    if (current == null) {
                        current =
                            database.getSessionManager().newSession(database,
                                sysSession.getUser(), false, true);

                        sessionMap.put(currentId, current);
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);

                    continue;
                }

                Result result = null;

                switch (scr.getStatementType()) {

                    case ScriptReaderBase.ANY_STATEMENT :
                        result = current.sqlExecuteDirectNoPreChecks(
                            scr.getLoggedStatement());

                        if (result != null && result.isError()) {
                            if (result.getException() != null) {
                                throw result.getException();
                            }

                            throw Trace.error(result);
                        }
                        break;

                    case ScriptReaderBase.SEQUENCE_STATEMENT :
                        scr.getCurrentSequence().reset(
                            scr.getSequenceValue());
                        break;

                    case ScriptReaderBase.COMMIT_STATEMENT :
                        current.commit();
                        break;

                    case ScriptReaderBase.INSERT_STATEMENT : {
                        Object[] data = scr.getData();

                        scr.getCurrentTable().insertNoCheckFromLog(current,
                                data);

                        break;
                    }
                    case ScriptReaderBase.DELETE_STATEMENT : {
                        Object[] data = scr.getData();

                        scr.getCurrentTable().deleteNoCheckFromLog(current,
                                data);

                        break;
                    }
                    case ScriptReaderBase.SCHEMA_STATEMENT : {
                        current.setSchema(scr.getCurrentSchema());
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);
                }
            }
        } catch (Throwable e) {
            String message;

View Full Code Here

        runScript(database, scr);
    }

    private static void runScript(Database database, ScriptReaderBase scr) {

        IntKeyHashMap sessionMap = new IntKeyHashMap();
        Session       current    = null;
        int           currentId  = 0;
        String        statement;
        int           statementType;
        Statement dummy = new StatementDML(StatementTypes.UPDATE_CURSOR,
                                           StatementTypes.X_SQL_DATA_CHANGE,
                                           null);
        String databaseFile = database.getPath();
        boolean fullReplay = database.getURLProperties().isPropertyTrue(
            HsqlDatabaseProperties.hsqldb_full_log_replay);

        dummy.setCompileTimestamp(Long.MAX_VALUE);
        database.setReferentialIntegrity(false);

        try {
            StopWatch sw = new StopWatch();

            while (scr.readLoggedStatement(current)) {
                int sessionId = scr.getSessionNumber();

                if (current == null || currentId != sessionId) {
                    currentId = sessionId;
                    current   = (Session) sessionMap.get(currentId);

                    if (current == null) {
                        current =
                            database.getSessionManager().newSessionForLog(
                                database);

                        sessionMap.put(currentId, current);
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);

                    continue;
                }

                Result result = null;

                statementType = scr.getStatementType();

                switch (statementType) {

                    case ScriptReaderBase.ANY_STATEMENT :
                        statement = scr.getLoggedStatement();

                        Statement cs;

                        try {
                            cs = current.compileStatement(statement);

                            if (database.getProperties().isVersion18()) {

                                // convert BIT columns in .log to BOOLEAN
                                if (cs.getType()
                                        == StatementTypes.CREATE_TABLE) {
                                    Table table =
                                        (Table) ((StatementSchema) cs)
                                            .getArguments()[0];

                                    for (int i = 0; i < table.getColumnCount();
                                            i++) {
                                        ColumnSchema column =
                                            table.getColumn(i);

                                        if (column.getDataType().isBitType()) {
                                            column.setType(Type.SQL_BOOLEAN);
                                        }
                                    }
                                }
                            }

                            result = current.executeCompiledStatement(cs,
                                    ValuePool.emptyObjectArray);
                        } catch (Throwable e) {
                            result = Result.newErrorResult(e);
                        }

                        if (result != null && result.isError()) {
                            if (result.getException() != null) {
                                throw result.getException();
                            }

                            throw Error.error(result);
                        }
                        break;

                    case ScriptReaderBase.COMMIT_STATEMENT :
                        current.commit(false);
                        break;

                    case ScriptReaderBase.INSERT_STATEMENT : {
                        current.sessionContext.currentStatement = dummy;

                        current.beginAction(dummy);

                        Object[] data = scr.getData();

                        scr.getCurrentTable().insertNoCheckFromLog(current,
                                data);
                        current.endAction(Result.updateOneResult);

                        break;
                    }
                    case ScriptReaderBase.DELETE_STATEMENT : {
                        current.sessionContext.currentStatement = dummy;

                        current.beginAction(dummy);

                        Table    table = scr.getCurrentTable();
                        Object[] data  = scr.getData();
                        Row row = table.getDeleteRowFromLog(current, data);

                        if (row != null) {
                            current.addDeleteAction(table, row, null);
                        }

                        current.endAction(Result.updateOneResult);

                        break;
                    }
                    case ScriptReaderBase.SET_SCHEMA_STATEMENT : {
                        HsqlName name =
                            database.schemaManager.findSchemaHsqlName(
                                scr.getCurrentSchema());

                        current.setCurrentSchemaHsqlName(name);

                        break;
                    }
                    case ScriptReaderBase.SESSION_ID : {
                        break;
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);
                }
            }
        } catch (HsqlException e) {

            // stop processing on bad log line
View Full Code Here

    TextCache(Table table, String name) {

        super(table.database, name);

        this.table       = table;
        uncommittedCache = new IntKeyHashMap();
    }
View Full Code Here

    /**
     * Initialises the database attributes lists from the server properties object.
     */
    private void setDBInfoArrays() {

        IntKeyHashMap dbNumberMap  = getDBNameArray();
        int           maxDatabases = dbNumberMap.size();

        if (serverProperties.isPropertyTrue(
                ServerProperties.sc_key_remote_open_db)) {
            int max = serverProperties.getIntegerProperty(
                ServerProperties.sc_key_max_databases,
                ServerConstants.SC_DEFAULT_MAX_DATABASES);

            if (maxDatabases < max) {
                maxDatabases = max;
            }
        }

        dbAlias          = new String[maxDatabases];
        dbPath           = new String[dbAlias.length];
        dbType           = new String[dbAlias.length];
        dbID             = new int[dbAlias.length];
        dbActionSequence = new long[dbAlias.length];
        dbProps          = new HsqlProperties[dbAlias.length];

        Iterator it = dbNumberMap.keySet().iterator();

        for (int i = 0; it.hasNext(); ) {
            int    dbNumber = it.nextInt();
            String path     = getDatabasePath(dbNumber, true);

            if (path == null) {
                printWithThread("missing database path: "
                                + dbNumberMap.get(dbNumber));

                continue;
            }

            HsqlProperties dbURL = DatabaseURL.parseURL(path, false, false);

            if (dbURL == null) {
                printWithThread("malformed database path: " + path);

                continue;
            }

            dbAlias[i] = (String) dbNumberMap.get(dbNumber);
            dbPath[i= dbURL.getProperty("database");
            dbType[i= dbURL.getProperty("connection_type");
            dbProps[i] = dbURL;

            i++;
View Full Code Here

     */
    private IntKeyHashMap getDBNameArray() {

        final String  prefix       = ServerProperties.sc_key_dbname + ".";
        final int     prefixLen    = prefix.length();
        IntKeyHashMap idToAliasMap = new IntKeyHashMap();
        Enumeration   en           = serverProperties.propertyNames();

        for (; en.hasMoreElements(); ) {
            String key = (String) en.nextElement();

            if (!key.startsWith(prefix)) {
                continue;
            }

            int dbNumber;

            try {
                dbNumber = Integer.parseInt(key.substring(prefixLen));
            } catch (NumberFormatException e1) {
                printWithThread("maformed database enumerator: " + key);

                continue;
            }

            String alias = serverProperties.getProperty(key).toLowerCase();

            if (!aliasSet.add(alias)) {
                printWithThread("duplicate alias: " + alias);
            }

            Object existing = idToAliasMap.put(dbNumber, alias);

            if (existing != null) {
                printWithThread("duplicate database enumerator: " + key);
            }
        }
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.IntKeyHashMap$KeySet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.