Search in sources :

Example 1 with RowAVL

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

the class RowStoreAVLDisk method getAccessor.

public CachedObject getAccessor(Index key) {
    NodeAVL node = (NodeAVL) accessorList[key.getPosition()];
    if (node == null) {
        return null;
    }
    if (!node.isInMemory()) {
        RowAVL row = (RowAVL) get(node.getPos(), false);
        node = row.getNode(key.getPosition());
        accessorList[key.getPosition()] = node;
    }
    return node;
}
Also used : NodeAVL(org.hsqldb_voltpatches.index.NodeAVL) RowAVL(org.hsqldb_voltpatches.RowAVL)

Example 2 with RowAVL

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

the class RowStoreAVLMemory method getNewCachedObject.

public CachedObject getNewCachedObject(Session session, Object object) {
    Row row = new RowAVL(table, (Object[]) object);
    if (session != null) {
        RowAction.addAction(session, RowAction.ACTION_INSERT, table, row);
    }
    int id = rowIdSequence++;
    row.setPos(id);
    rowIdMap.put(id, row);
    return row;
}
Also used : Row(org.hsqldb_voltpatches.Row) RowAVL(org.hsqldb_voltpatches.RowAVL)

Example 3 with RowAVL

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

the class IndexAVL method insert.

/**
     * Insert a node into the index
     */
@Override
public void insert(Session session, PersistentStore store, Row row) {
    NodeAVL n;
    NodeAVL x;
    boolean isleft = true;
    int compare = -1;
    writeLock.lock();
    try {
        n = getAccessor(store);
        x = n;
        if (n == null) {
            store.setAccessor(this, ((RowAVL) row).getNode(position));
            return;
        }
        while (true) {
            Row currentRow = n.getRow(store);
            compare = compareRowForInsertOrDelete(session, row, currentRow);
            if (compare == 0) {
                throw Error.error(ErrorCode.X_23505);
            }
            isleft = compare < 0;
            x = n;
            n = child(store, x, isleft);
            if (n == null) {
                break;
            }
        }
        x = set(store, x, isleft, ((RowAVL) row).getNode(position));
        balance(store, x, isleft);
    } finally {
        writeLock.unlock();
    }
}
Also used : Row(org.hsqldb_voltpatches.Row) RowAVL(org.hsqldb_voltpatches.RowAVL)

Example 4 with RowAVL

use of org.hsqldb_voltpatches.RowAVL 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 5 with RowAVL

use of org.hsqldb_voltpatches.RowAVL 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)

Aggregations

RowAVL (org.hsqldb_voltpatches.RowAVL)7 Row (org.hsqldb_voltpatches.Row)5 NodeAVL (org.hsqldb_voltpatches.index.NodeAVL)4 RowIterator (org.hsqldb_voltpatches.navigator.RowIterator)2 HsqlException (org.hsqldb_voltpatches.HsqlException)1 RowAVLDisk (org.hsqldb_voltpatches.RowAVLDisk)1