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);
}
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;
}
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);
}
}
}
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;
}
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();
}
Aggregations