use of org.hsqldb_voltpatches.navigator.RowIterator in project voltdb by VoltDB.
the class Constraint method checkReferencedRows.
/**
* Check used before creating a new foreign key cosntraint, this method
* checks all rows of a table to ensure they all have a corresponding
* row in the main table.
*/
void checkReferencedRows(Session session, Table table, int[] rowColArray) {
Index mainIndex = getMainIndex();
PersistentStore store = session.sessionData.getRowStore(table);
RowIterator it = table.rowIterator(session);
while (true) {
Row row = it.getNextRow();
if (row == null) {
break;
}
Object[] rowData = row.getData();
if (ArrayUtil.hasNull(rowData, rowColArray)) {
if (core.matchType == OpTypes.MATCH_SIMPLE) {
continue;
}
} else if (mainIndex.exists(session, store, rowData, rowColArray)) {
continue;
}
if (ArrayUtil.hasAllNull(rowData, rowColArray)) {
continue;
}
String colValues = "";
for (int i = 0; i < rowColArray.length; i++) {
Object o = rowData[rowColArray[i]];
colValues += table.getColumnTypes()[i].convertToString(o);
colValues += ",";
}
String[] info = new String[] { getName().name, getMain().getName().name };
throw Error.error(ErrorCode.X_23502, ErrorCode.CONSTRAINT, info);
}
}
use of org.hsqldb_voltpatches.navigator.RowIterator in project voltdb by VoltDB.
the class RowStoreAVLMemory method reindex.
/**
* for result tables
*/
void reindex(Session session, Index index) {
setAccessor(index, null);
RowIterator it = table.rowIterator(session);
while (it.hasNext()) {
Row row = it.getNextRow();
// may need to clear the node before insert
index.insert(session, this, row);
}
}
use of org.hsqldb_voltpatches.navigator.RowIterator 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;
}
use of org.hsqldb_voltpatches.navigator.RowIterator 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;
}
}
use of org.hsqldb_voltpatches.navigator.RowIterator 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;
}
Aggregations