Search in sources :

Example 56 with HsqlArrayList

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

the class SchemaObjectSet method getSQL.

String[] getSQL(OrderedHashSet resolved, OrderedHashSet unresolved) {
    HsqlArrayList list = new HsqlArrayList();
    if (!(map instanceof HashMappedList)) {
        return null;
    }
    if (map.isEmpty()) {
        return ValuePool.emptyStringArray;
    }
    Iterator it = map.values().iterator();
    if (type == SchemaObject.FUNCTION || type == SchemaObject.PROCEDURE) {
        OrderedHashSet set = new OrderedHashSet();
        while (it.hasNext()) {
            RoutineSchema routine = (RoutineSchema) it.next();
            for (int i = 0; i < routine.routines.length; i++) {
                set.add(routine.routines[i]);
            }
        }
        it = set.iterator();
    }
    while (it.hasNext()) {
        SchemaObject object = (SchemaObject) it.next();
        OrderedHashSet references = object.getReferences();
        if (references != null) {
            boolean isResolved = true;
            for (int j = 0; j < references.size(); j++) {
                HsqlName name = (HsqlName) references.get(j);
                if (SqlInvariants.isSchemaNameSystem(name)) {
                    continue;
                }
                if (name.type == SchemaObject.COLUMN) {
                    name = name.parent;
                }
                if (name.type == SchemaObject.CHARSET) {
                    // some built-in character sets have no schema
                    if (name.schema == null) {
                        continue;
                    }
                }
                if (!resolved.contains(name)) {
                    isResolved = false;
                    break;
                }
            }
            if (!isResolved) {
                unresolved.add(object);
                continue;
            }
        }
        resolved.add(object.getName());
        if (object.getType() == SchemaObject.TABLE) {
            list.addAll(((Table) object).getSQL(resolved, unresolved));
        } else {
            list.add(object.getSQL());
        }
    }
    String[] array = new String[list.size()];
    list.toArray(array);
    return array;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 57 with HsqlArrayList

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

the class SessionContext method push.

public void push() {
    if (stack == null) {
        stack = new HsqlArrayList(true);
    }
    stack.add(dynamicArguments);
    stack.add(routineArguments);
    stack.add(routineVariables);
    stack.add(rangeIterators);
    stack.add(savepoints);
    stack.add(savepointTimestamps);
    rangeIterators = new RangeIterator[4];
    savepoints = new HashMappedList(4);
    savepointTimestamps = new LongDeque();
    String name = HsqlNameManager.getAutoSavepointNameString(session.actionTimestamp, depth);
    session.savepoint(name);
    depth++;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) LongDeque(org.hsqldb_voltpatches.lib.LongDeque)

Example 58 with HsqlArrayList

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

the class SchemaManager method dropSchemas.

/**
     * drop all schemas with the given authorisation
     */
void dropSchemas(Grantee grantee, boolean cascade) {
    HsqlArrayList list = getSchemas(grantee);
    Iterator it = list.iterator();
    while (it.hasNext()) {
        Schema schema = (Schema) it.next();
        dropSchema(schema.name.name, cascade);
    }
}
Also used : HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Example 59 with HsqlArrayList

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

the class DataFileDefrag method process.

void process() throws IOException {
    boolean complete = false;
    Error.printSystemOut("Defrag Transfer begins");
    transactionRowLookup = database.txManager.getTransactionIDList();
    HsqlArrayList allTables = database.schemaManager.getAllTables();
    rootsList = new int[allTables.size()][];
    Storage dest = null;
    try {
        OutputStream fos = database.getFileAccess().openOutputStreamElement(filename + ".new");
        fileStreamOut = new BufferedOutputStream(fos, 1 << 12);
        for (int i = 0; i < DataFileCache.INITIAL_FREE_POS; i++) {
            fileStreamOut.write(0);
        }
        fileOffset = DataFileCache.INITIAL_FREE_POS;
        for (int i = 0, tSize = allTables.size(); i < tSize; i++) {
            Table t = (Table) allTables.get(i);
            if (t.getTableType() == TableBase.CACHED_TABLE) {
                int[] rootsArray = writeTableToDataFile(t);
                rootsList[i] = rootsArray;
            } else {
                rootsList[i] = null;
            }
            Error.printSystemOut(t.getName().name + " complete");
        }
        writeTransactionRows();
        fileStreamOut.flush();
        fileStreamOut.close();
        fileStreamOut = null;
        // write out the end of file position
        dest = ScaledRAFile.newScaledRAFile(database, filename + ".new", false, ScaledRAFile.DATA_FILE_RAF, database.getURLProperties().getProperty("storage_class_name"), database.getURLProperties().getProperty("storage_key"));
        dest.seek(DataFileCache.LONG_FREE_POS_POS);
        dest.writeLong(fileOffset);
        dest.close();
        dest = null;
        for (int i = 0, size = rootsList.length; i < size; i++) {
            int[] roots = rootsList[i];
            if (roots != null) {
                Error.printSystemOut(org.hsqldb_voltpatches.lib.StringUtil.getList(roots, ",", ""));
            }
        }
        complete = true;
    } catch (IOException e) {
        throw Error.error(ErrorCode.FILE_IO_ERROR, filename + ".new");
    } catch (OutOfMemoryError e) {
        throw Error.error(ErrorCode.OUT_OF_MEMORY);
    } finally {
        if (fileStreamOut != null) {
            fileStreamOut.close();
        }
        if (dest != null) {
            dest.close();
        }
        if (!complete) {
            database.getFileAccess().removeElement(filename + ".new");
        }
    }
//Error.printSystemOut("Transfer complete: ", stopw.elapsedTime());
}
Also used : Storage(org.hsqldb_voltpatches.lib.Storage) Table(org.hsqldb_voltpatches.Table) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 60 with HsqlArrayList

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

the class SchemaManager method getAllTables.

/**
     *  Returns an HsqlArrayList containing references to all non-system
     *  tables and views. This includes all tables and views registered with
     *  this Database.
     */
public HsqlArrayList getAllTables() {
    Iterator schemas = allSchemaNameIterator();
    HsqlArrayList alltables = new HsqlArrayList();
    while (schemas.hasNext()) {
        String name = (String) schemas.next();
        HashMappedList current = getTables(name);
        alltables.addAll(current.values());
    }
    return alltables;
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) HsqlArrayList(org.hsqldb_voltpatches.lib.HsqlArrayList) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator)

Aggregations

HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)69 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)21 Iterator (org.hsqldb_voltpatches.lib.Iterator)14 HsqlList (org.hsqldb_voltpatches.lib.HsqlList)11 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)10 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)10 Table (org.hsqldb_voltpatches.Table)7 Type (org.hsqldb_voltpatches.types.Type)6 SchemaObject (org.hsqldb_voltpatches.SchemaObject)5 Method (java.lang.reflect.Method)4 Constraint (org.hsqldb_voltpatches.Constraint)3 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)3 Grantee (org.hsqldb_voltpatches.rights.Grantee)3 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)2 Result (org.hsqldb_voltpatches.result.Result)2 BufferedOutputStream (java.io.BufferedOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)1 NumberSequence (org.hsqldb_voltpatches.NumberSequence)1