Search in sources :

Example 66 with Row

use of org.h2.result.Row in project h2database by h2database.

the class PageStore method removeMetaIndex.

private void removeMetaIndex(Index index, Session session) {
    int key = index.getId() + 1;
    Row row = metaIndex.getRow(session, key);
    if (row.getKey() != key) {
        throw DbException.get(ErrorCode.FILE_CORRUPTED_1, "key: " + key + " index: " + index + " table: " + index.getTable() + " row: " + row);
    }
    metaIndex.remove(session, row);
}
Also used : Row(org.h2.result.Row)

Example 67 with Row

use of org.h2.result.Row in project h2database by h2database.

the class PageStore method getObjectIds.

public BitSet getObjectIds() {
    BitSet f = new BitSet();
    Cursor cursor = metaIndex.find(pageStoreSession, null, null);
    while (cursor.next()) {
        Row row = cursor.get();
        int id = row.getValue(0).getInt();
        if (id > 0) {
            f.set(id);
        }
    }
    return f;
}
Also used : BitSet(java.util.BitSet) Row(org.h2.result.Row) Cursor(org.h2.index.Cursor)

Example 68 with Row

use of org.h2.result.Row in project h2database by h2database.

the class MVSecondaryIndex method addBufferedRows.

@Override
public void addBufferedRows(List<String> bufferNames) {
    ArrayList<String> mapNames = new ArrayList<>(bufferNames);
    CompareMode compareMode = database.getCompareMode();
    int buffersCount = bufferNames.size();
    Queue<Source> queue = new PriorityQueue<>(buffersCount, new Source.Comparator(compareMode));
    for (String bufferName : bufferNames) {
        Iterator<ValueArray> iter = openMap(bufferName).keyIterator(null);
        if (iter.hasNext()) {
            queue.add(new Source(iter));
        }
    }
    try {
        while (!queue.isEmpty()) {
            Source s = queue.remove();
            ValueArray rowData = s.next();
            if (indexType.isUnique()) {
                Value[] array = rowData.getList();
                // don't change the original value
                array = array.clone();
                array[keyColumns - 1] = ValueLong.MIN;
                ValueArray unique = ValueArray.get(array);
                SearchRow row = convertToSearchRow(rowData);
                if (!mayHaveNullDuplicates(row)) {
                    requireUnique(row, dataMap, unique);
                }
            }
            dataMap.putCommitted(rowData, ValueNull.INSTANCE);
            if (s.hasNext()) {
                queue.offer(s);
            }
        }
    } finally {
        for (String tempMapName : mapNames) {
            MVMap<ValueArray, Value> map = openMap(tempMapName);
            map.getStore().removeMap(map);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) PriorityQueue(java.util.PriorityQueue) Value(org.h2.value.Value) CompareMode(org.h2.value.CompareMode) ValueArray(org.h2.value.ValueArray) SearchRow(org.h2.result.SearchRow)

Example 69 with Row

use of org.h2.result.Row in project h2database by h2database.

the class MVSecondaryIndex method convertToSearchRow.

/**
 * Convert array of values to a SearchRow.
 *
 * @param key the index key
 * @return the row
 */
SearchRow convertToSearchRow(ValueArray key) {
    Value[] array = key.getList();
    SearchRow searchRow = mvTable.getTemplateRow();
    searchRow.setKey((array[array.length - 1]).getLong());
    Column[] cols = getColumns();
    for (int i = 0; i < array.length - 1; i++) {
        Column c = cols[i];
        int idx = c.getColumnId();
        Value v = array[i];
        searchRow.setValue(idx, v);
    }
    return searchRow;
}
Also used : Column(org.h2.table.Column) IndexColumn(org.h2.table.IndexColumn) Value(org.h2.value.Value) SearchRow(org.h2.result.SearchRow)

Example 70 with Row

use of org.h2.result.Row in project h2database by h2database.

the class MVTable method addRowsToIndex.

private static void addRowsToIndex(Session session, ArrayList<Row> list, Index index) {
    sortRows(list, index);
    for (Row row : list) {
        index.add(session, row);
    }
    list.clear();
}
Also used : Row(org.h2.result.Row)

Aggregations

Value (org.h2.value.Value)118 Row (org.h2.result.Row)49 Column (org.h2.table.Column)48 DbException (org.h2.message.DbException)44 SearchRow (org.h2.result.SearchRow)37 SQLException (java.sql.SQLException)29 Index (org.h2.index.Index)28 IndexColumn (org.h2.table.IndexColumn)24 Cursor (org.h2.index.Cursor)21 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)20 StatementBuilder (org.h2.util.StatementBuilder)20 ArrayList (java.util.ArrayList)19 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)18 Expression (org.h2.expression.Expression)17 Statement (java.sql.Statement)16 Constraint (org.h2.constraint.Constraint)16 ValueString (org.h2.value.ValueString)16 Connection (java.sql.Connection)15 SimpleResultSet (org.h2.tools.SimpleResultSet)15