Search in sources :

Example 16 with Row

use of org.hsqldb_voltpatches.Row in project voltdb by VoltDB.

the class RowStoreAVLMemory method insertIndexNodes.

boolean insertIndexNodes(Index primaryIndex, Index newIndex) {
    int position = newIndex.getPosition();
    RowIterator it = primaryIndex.firstRow(this);
    int rowCount = 0;
    HsqlException error = null;
    try {
        while (it.hasNext()) {
            Row row = it.getNextRow();
            ((RowAVL) row).insertNode(position);
            // count before inserting
            rowCount++;
            newIndex.insert(null, this, row);
        }
        return true;
    } catch (java.lang.OutOfMemoryError e) {
        error = Error.error(ErrorCode.OUT_OF_MEMORY);
    } catch (HsqlException e) {
        error = e;
    }
    // backtrack on error
    // rowCount rows have been modified
    it = primaryIndex.firstRow(this);
    for (int i = 0; i < rowCount; i++) {
        Row row = it.getNextRow();
        NodeAVL backnode = ((RowAVL) row).getNode(0);
        int j = position;
        while (--j > 0) {
            backnode = backnode.nNext;
        }
        backnode.nNext = backnode.nNext.nNext;
    }
    throw error;
}
Also used : NodeAVL(org.hsqldb_voltpatches.index.NodeAVL) RowIterator(org.hsqldb_voltpatches.navigator.RowIterator) Row(org.hsqldb_voltpatches.Row) RowAVL(org.hsqldb_voltpatches.RowAVL) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 17 with Row

use of org.hsqldb_voltpatches.Row in project voltdb by VoltDB.

the class RowStoreAVLMemory method dropIndexFromRows.

void dropIndexFromRows(Index primaryIndex, Index oldIndex) {
    RowIterator it = primaryIndex.firstRow(this);
    int position = oldIndex.getPosition() - 1;
    while (it.hasNext()) {
        Row row = it.getNextRow();
        int i = position - 1;
        NodeAVL backnode = ((RowAVL) row).getNode(0);
        while (i-- > 0) {
            backnode = backnode.nNext;
        }
        backnode.nNext = backnode.nNext.nNext;
    }
}
Also used : NodeAVL(org.hsqldb_voltpatches.index.NodeAVL) RowIterator(org.hsqldb_voltpatches.navigator.RowIterator) Row(org.hsqldb_voltpatches.Row) RowAVL(org.hsqldb_voltpatches.RowAVL)

Example 18 with Row

use of org.hsqldb_voltpatches.Row in project voltdb by VoltDB.

the class RowStoreAVLDiskData method getNewCachedObject.

public CachedObject getNewCachedObject(Session session, Object object) {
    Row row = new RowAVLDiskData(table, (Object[]) object);
    add(row);
    RowAction.addAction(session, RowAction.ACTION_INSERT, table, row);
    return row;
}
Also used : RowAVLDiskData(org.hsqldb_voltpatches.RowAVLDiskData) Row(org.hsqldb_voltpatches.Row)

Example 19 with Row

use of org.hsqldb_voltpatches.Row in project voltdb by VoltDB.

the class RowStoreAVLHybrid method getNewCachedObject.

public CachedObject getNewCachedObject(Session session, Object object) {
    if (isCached) {
        Row row = new RowAVLDisk(table, (Object[]) object);
        add(row);
        if (isTempTable) {
            RowAction.addAction(session, RowAction.ACTION_INSERT, (Table) table, row);
        }
        return row;
    } else {
        memoryRowCount++;
        if (useCache && memoryRowCount > maxMemoryRowCount) {
            changeToDiskTable();
            return getNewCachedObject(session, object);
        }
        Row row = new RowAVL(table, (Object[]) object);
        int id = rowIdSequence++;
        row.setPos(id);
        rowIdMap.put(id, row);
        if (isTempTable) {
            RowAction.addAction(session, RowAction.ACTION_INSERT, (Table) table, row);
        }
        return row;
    }
}
Also used : RowAVLDisk(org.hsqldb_voltpatches.RowAVLDisk) Row(org.hsqldb_voltpatches.Row) RowAVL(org.hsqldb_voltpatches.RowAVL)

Example 20 with Row

use of org.hsqldb_voltpatches.Row in project voltdb by VoltDB.

the class RowStoreAVLHybrid method changeToDiskTable.

public void changeToDiskTable() {
    cache = session.sessionData.getResultCache();
    if (cache != null) {
        RowIterator iterator = table.rowIterator(this);
        ArrayUtil.fillArray(accessorList, null);
        isCached = true;
        cache.storeCount++;
        while (iterator.hasNext()) {
            Row row = iterator.getNextRow();
            Row newRow = (Row) getNewCachedObject(session, row.getData());
            indexRow(null, newRow);
        }
        rowIdMap.clear();
    }
    maxMemoryRowCount = Integer.MAX_VALUE;
}
Also used : RowIterator(org.hsqldb_voltpatches.navigator.RowIterator) Row(org.hsqldb_voltpatches.Row)

Aggregations

Row (org.hsqldb_voltpatches.Row)20 RowAVL (org.hsqldb_voltpatches.RowAVL)5 RowIterator (org.hsqldb_voltpatches.navigator.RowIterator)4 HsqlException (org.hsqldb_voltpatches.HsqlException)3 RowAVLDisk (org.hsqldb_voltpatches.RowAVLDisk)2 SchemaObject (org.hsqldb_voltpatches.SchemaObject)2 NodeAVL (org.hsqldb_voltpatches.index.NodeAVL)2 RowAVLDiskData (org.hsqldb_voltpatches.RowAVLDiskData)1