Search in sources :

Example 6 with Row

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

the class RowStoreAVLDisk method getNewCachedObject.

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

Example 7 with Row

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

the class RowSetNavigatorData method exceptAll.

public void exceptAll(RowSetNavigatorData other) {
    Object[] compareData = null;
    RowIterator it;
    Row otherRow = null;
    Object[] otherData = null;
    sortFull();
    reset();
    other.sortFull();
    it = other.fullIndex.emptyIterator();
    while (hasNext()) {
        getNext();
        Object[] currentData = currentRow.getData();
        boolean newGroup = compareData == null || fullIndex.compareRowNonUnique(currentData, compareData, fullIndex.getColumnCount()) != 0;
        if (newGroup) {
            compareData = currentData;
            it = other.fullIndex.findFirstRow(session, other.store, currentData);
        }
        otherRow = it.getNextRow();
        otherData = otherRow == null ? null : otherRow.getData();
        if (otherData != null && fullIndex.compareRowNonUnique(currentData, otherData, fullIndex.getColumnCount()) == 0) {
            remove();
        }
    }
    other.close();
}
Also used : Row(org.hsqldb_voltpatches.Row)

Example 8 with Row

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

the class RowSetNavigatorData method add.

public void add(Object data) {
    try {
        Row row = (Row) store.getNewCachedObject(session, data);
        store.indexRow(null, row);
        size++;
    } catch (HsqlException e) {
    }
}
Also used : Row(org.hsqldb_voltpatches.Row) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 9 with Row

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

the class RowSetNavigatorData method addAdjusted.

private void addAdjusted(Object[] data, int[] columnMap) {
    try {
        if (columnMap == null) {
            data = (Object[]) ArrayUtil.resizeArrayIfDifferent(data, table.getColumnCount());
        } else {
            Object[] newData = new Object[table.getColumnCount()];
            ArrayUtil.projectRow(data, columnMap, newData);
            data = newData;
        }
        Row row = (Row) store.getNewCachedObject(session, data);
        store.indexRow(null, row);
        size++;
    } catch (HsqlException e) {
    }
}
Also used : Row(org.hsqldb_voltpatches.Row) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 10 with Row

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

the class IndexAVL method findFirstRow.

/**
     * Finds the first node that is larger or equal to the given one based
     * on the first column of the index only.
     *
     * @param session session object
     * @param store store object
     * @param value value to match
     * @param compare comparison Expression type
     *
     * @return iterator
     */
@Override
public RowIterator findFirstRow(Session session, PersistentStore store, Object value, int compare) {
    readLock.lock();
    try {
        if (compare == OpTypes.SMALLER || compare == OpTypes.SMALLER_EQUAL) {
            return findFirstRowNotNull(session, store);
        }
        boolean isEqual = compare == OpTypes.EQUAL || compare == OpTypes.IS_NULL;
        NodeAVL x = getAccessor(store);
        int iTest = 1;
        if (compare == OpTypes.GREATER) {
            iTest = 0;
        }
        if (value == null && !isEqual) {
            return emptyIterator;
        }
        // this method returns the correct node only with the following conditions
        boolean check = compare == OpTypes.GREATER || compare == OpTypes.EQUAL || compare == OpTypes.GREATER_EQUAL;
        if (!check) {
            Error.runtimeError(ErrorCode.U_S0500, "Index.findFirst");
        }
        while (x != null) {
            boolean t = colTypes[0].compare(value, x.getRow(store).getData()[colIndex[0]]) >= iTest;
            if (t) {
                NodeAVL r = x.getRight(store);
                if (r == null) {
                    break;
                }
                x = r;
            } else {
                NodeAVL l = x.getLeft(store);
                if (l == null) {
                    break;
                }
                x = l;
            }
        }
        /*
        while (x != null
                && Column.compare(value, x.getData()[colIndex_0], colType_0)
                   >= iTest) {
            x = next(x);
        }
*/
        while (x != null) {
            Object colvalue = x.getRow(store).getData()[colIndex[0]];
            int result = colTypes[0].compare(value, colvalue);
            if (result >= iTest) {
                x = next(store, x);
            } else {
                if (isEqual) {
                    if (result != 0) {
                        x = null;
                    }
                } else if (colvalue == null) {
                    x = next(store, x);
                    continue;
                }
                break;
            }
        }
        // MVCC
        if (session == null || x == null) {
            return getIterator(session, store, x);
        }
        while (x != null) {
            Row row = x.getRow(store);
            if (compare == OpTypes.EQUAL && colTypes[0].compare(value, row.getData()[colIndex[0]]) != 0) {
                x = null;
                break;
            }
            if (session.database.txManager.canRead(session, row)) {
                break;
            }
            x = next(store, x);
        }
        return getIterator(session, store, x);
    } finally {
        readLock.unlock();
    }
}
Also used : SchemaObject(org.hsqldb_voltpatches.SchemaObject) 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