Search in sources :

Example 41 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TextTable method getHeader.

public String getHeader() {
    PersistentStore store = database.persistentStoreCollection.getStore(this);
    TextCache cache = (TextCache) store.getCache();
    String header = cache == null ? null : cache.getHeader();
    return header == null ? null : StringConverter.toQuotedString(header, '\"', true);
}
Also used : TextCache(org.hsqldb_voltpatches.persist.TextCache) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 42 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TransactionManager method mergeRolledBackTransaction.

/**
     * merge a given list of transaction rollback action with given timestamp
     */
void mergeRolledBackTransaction(Object[] list, int start, int limit) {
    for (int i = start; i < limit; i++) {
        RowAction rowact = (RowAction) list[i];
        if (rowact == null || rowact.type == RowActionBase.ACTION_NONE || rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
            continue;
        }
        Row row = rowact.memoryRow;
        if (row == null) {
            PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
            row = (Row) store.get(rowact.getPos(), false);
        }
        if (row == null) {
            continue;
        }
        synchronized (row) {
            rowact.mergeRollback(row);
        }
    }
//        } catch (Throwable t) {
//            System.out.println("throw in merge");
//            t.printStackTrace();
//        }
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 43 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class Table method deleteNoCheckFromLog.

/**
     * For log statements. Delete a single row.
     */
public void deleteNoCheckFromLog(Session session, Object[] data) {
    Row row = null;
    PersistentStore store = session.sessionData.getRowStore(this);
    if (hasPrimaryKey()) {
        RowIterator it = getPrimaryIndex().findFirstRow(session, store, data, primaryKeyColsSequence);
        row = it.getNextRow();
    } else if (bestIndex == null) {
        RowIterator it = rowIterator(session);
        while (true) {
            row = it.getNextRow();
            if (row == null) {
                break;
            }
            if (IndexAVL.compareRows(row.getData(), data, defaultColumnMap, colTypes) == 0) {
                break;
            }
        }
    } else {
        RowIterator it = bestIndex.findFirstRow(session, store, data);
        while (true) {
            row = it.getNextRow();
            if (row == null) {
                break;
            }
            Object[] rowdata = row.getData();
            // reached end of range
            if (bestIndex.compareRowNonUnique(data, bestIndex.getColumns(), rowdata) != 0) {
                row = null;
                break;
            }
            if (IndexAVL.compareRows(rowdata, data, defaultColumnMap, colTypes) == 0) {
                break;
            }
        }
    }
    if (row == null) {
        return;
    }
    deleteNoCheck(session, row);
}
Also used : RowIterator(org.hsqldb_voltpatches.navigator.RowIterator) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 44 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class Table method getIndexRootsArray.

/**
     *  Return the list of file pointers to root nodes for this table's
     *  indexes.
     */
public final int[] getIndexRootsArray() {
    PersistentStore store = database.persistentStoreCollection.getStore(this);
    int[] roots = new int[getIndexCount()];
    for (int i = 0; i < getIndexCount(); i++) {
        CachedObject accessor = store.getAccessor(indexList[i]);
        roots[i] = accessor == null ? -1 : accessor.getPos();
    }
    return roots;
}
Also used : CachedObject(org.hsqldb_voltpatches.persist.CachedObject) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 45 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TextTable method connect.

/**
     * connects to the data source
     */
private void connect(Session session, boolean withReadOnlyData) {
    // Open new cache:
    if ((dataSource.length() == 0) || isConnected) {
        // nothing to do
        return;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(this);
    this.store = store;
    DataFileCache cache = null;
    try {
        cache = (TextCache) database.logger.openTextCache(this, dataSource, withReadOnlyData, isReversed);
        store.setCache(cache);
        // read and insert all the rows from the source file
        Row row = null;
        int nextpos = 0;
        if (((TextCache) cache).ignoreFirst) {
            nextpos += ((TextCache) cache).readHeaderLine();
        }
        while (true) {
            row = (Row) store.get(nextpos, false);
            if (row == null) {
                break;
            }
            Object[] data = row.getData();
            nextpos = row.getPos() + row.getStorageSize();
            ((RowAVLDiskData) row).setNewNodes();
            systemUpdateIdentityValue(data);
            enforceRowConstraints(session, data);
            for (int i = 0; i < indexList.length; i++) {
                indexList[i].insert(null, store, row);
            }
        }
    } catch (Exception e) {
        int linenumber = cache == null ? 0 : ((TextCache) cache).getLineNumber();
        clearAllData(session);
        if (cache != null) {
            database.logger.closeTextCache(this);
            store.release();
        }
        // source and cache or have an empty source and null cache.
        throw Error.error(ErrorCode.TEXT_FILE, 0, new Object[] { new Integer(linenumber), e.getMessage() });
    }
    isConnected = true;
    isReadOnly = withReadOnlyData;
}
Also used : DataFileCache(org.hsqldb_voltpatches.persist.DataFileCache) TextCache(org.hsqldb_voltpatches.persist.TextCache) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Aggregations

PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)103 Table (org.hsqldb_voltpatches.Table)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)73 SchemaObject (org.hsqldb_voltpatches.SchemaObject)59 Constraint (org.hsqldb_voltpatches.Constraint)57 TextTable (org.hsqldb_voltpatches.TextTable)56 Iterator (org.hsqldb_voltpatches.lib.Iterator)51 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)51 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)20 HsqlException (org.hsqldb_voltpatches.HsqlException)19 Session (org.hsqldb_voltpatches.Session)16 Result (org.hsqldb_voltpatches.result.Result)16 NumberType (org.hsqldb_voltpatches.types.NumberType)10 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Type (org.hsqldb_voltpatches.types.Type)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 CachedObject (org.hsqldb_voltpatches.persist.CachedObject)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6