Search in sources :

Example 71 with Iterator

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

the class StatementManager method removeSession.

/**
     * Releases the link betwen the session and all compiled statement objects
     * it is linked to. If any such statement is not linked with any other
     * session, it is removed from management.
     *
     * @param sessionID the session identifier
     */
synchronized void removeSession(long sessionID) {
    LongKeyIntValueHashMap scsMap;
    long csid;
    Iterator i;
    scsMap = (LongKeyIntValueHashMap) sessionUseMap.remove(sessionID);
    if (scsMap == null) {
        return;
    }
    i = scsMap.keySet().iterator();
    while (i.hasNext()) {
        csid = i.nextLong();
        int usecount = useMap.get(csid, 1) - 1;
        if (usecount == 0) {
            Statement cs = (Statement) csidMap.remove(csid);
            if (cs != null) {
                int schemaid = cs.getSchemaName().hashCode();
                LongValueHashMap sqlMap = (LongValueHashMap) schemaMap.get(schemaid);
                String sql = (String) sqlLookup.remove(csid);
                sqlMap.remove(sql);
            }
            useMap.remove(csid);
        } else {
            useMap.put(csid, usecount);
        }
    }
}
Also used : LongKeyIntValueHashMap(org.hsqldb_voltpatches.lib.LongKeyIntValueHashMap) LongValueHashMap(org.hsqldb_voltpatches.lib.LongValueHashMap) Iterator(org.hsqldb_voltpatches.lib.Iterator)

Example 72 with Iterator

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

the class SchemaManager method getCascadingReferences.

//
private void getCascadingReferences(HsqlName object, OrderedHashSet set) {
    OrderedHashSet newSet = new OrderedHashSet();
    Iterator it = referenceMap.get(object);
    while (it.hasNext()) {
        HsqlName name = (HsqlName) it.next();
        boolean added = set.add(name);
        if (added) {
            newSet.add(name);
        }
    }
    for (int i = 0; i < newSet.size(); i++) {
        HsqlName name = (HsqlName) newSet.get(i);
        getCascadingReferences(name, set);
    }
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 73 with Iterator

use of org.hsqldb_voltpatches.lib.Iterator 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 74 with Iterator

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

the class SessionData method updateLobUsage.

// LOBs
// if rolled back, delete created lobs and ignore all changes
// if committed,
// delete created lobs that have no usage count (due to constraint violation or savepoint rollback)
// update LobManager user counts, delete lobs that have no usage
public void updateLobUsage(boolean commit) {
    if (!hasLobOps) {
        return;
    }
    hasLobOps = false;
    if (commit) {
        for (int i = 0; i < createdLobs.size(); i++) {
            long lobID = createdLobs.get(i);
            int delta = lobUsageCount.get(lobID, 0);
            if (delta == 1) {
                lobUsageCount.remove(lobID);
                createdLobs.remove(i);
                i--;
            } else if (!session.isBatch) {
                database.lobManager.adjustUsageCount(lobID, delta - 1);
                lobUsageCount.remove(lobID);
                createdLobs.remove(i);
                i--;
            }
        }
        if (!lobUsageCount.isEmpty()) {
            Iterator it = lobUsageCount.keySet().iterator();
            while (it.hasNext()) {
                long lobID = it.nextLong();
                int delta = lobUsageCount.get(lobID);
                database.lobManager.adjustUsageCount(lobID, delta - 1);
            }
            lobUsageCount.clear();
        }
        return;
    } else {
        for (int i = 0; i < createdLobs.size(); i++) {
            long lobID = createdLobs.get(i);
            database.lobManager.deleteLob(lobID);
        }
        createdLobs.clear();
        lobUsageCount.clear();
        return;
    }
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator)

Example 75 with Iterator

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

the class Cache method saveAll.

/**
     * Writes out all modified cached Rows.
     */
synchronized void saveAll() {
    Iterator it = new BaseHashIterator();
    int savecount = 0;
    for (; it.hasNext(); ) {
        CachedObject r = (CachedObject) it.next();
        if (r.hasChanged()) {
            rowTable[savecount++] = r;
        }
    }
    saveRows(savecount);
    Error.printSystemOut(saveAllTimer.elapsedTimeToMessage("Cache.saveRow() total row save time"));
    Error.printSystemOut("Cache.saveRow() total row save count = " + saveRowCount);
    Error.printSystemOut(makeRowTimer.elapsedTimeToMessage("Cache.makeRow() total row load time"));
    Error.printSystemOut("Cache.makeRow() total row load count = " + makeRowCount);
    Error.printSystemOut(sortTimer.elapsedTimeToMessage("Cache.sort() total time"));
}
Also used : Iterator(org.hsqldb_voltpatches.lib.Iterator)

Aggregations

Iterator (org.hsqldb_voltpatches.lib.Iterator)102 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)64 SchemaObject (org.hsqldb_voltpatches.SchemaObject)57 Table (org.hsqldb_voltpatches.Table)55 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)51 Constraint (org.hsqldb_voltpatches.Constraint)50 TextTable (org.hsqldb_voltpatches.TextTable)39 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)28 HsqlException (org.hsqldb_voltpatches.HsqlException)18 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)14 NumberType (org.hsqldb_voltpatches.types.NumberType)10 HashSet (org.hsqldb_voltpatches.lib.HashSet)9 Type (org.hsqldb_voltpatches.types.Type)9 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6 IntervalType (org.hsqldb_voltpatches.types.IntervalType)6