use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class TableBase method clearAllData.
public void clearAllData(Session session) {
PersistentStore store = session.sessionData.getRowStore(this);
store.removeAll();
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class Table method updateRowSet.
void updateRowSet(Session session, HashMappedList rowSet, int[] cols, boolean isTriggeredSet) {
boolean hasLob = false;
PersistentStore store = session.sessionData.getRowStore(this);
for (int i = 0; i < rowSet.size(); i++) {
Row row = (Row) rowSet.getKey(i);
if (row.isDeleted(session)) {
if (isTriggeredSet) {
rowSet.remove(i);
i--;
continue;
} else {
throw Error.error(ErrorCode.X_27000);
}
}
}
for (int i = 0; i < rowSet.size(); i++) {
Row row = (Row) rowSet.getKey(i);
Object[] data = (Object[]) rowSet.get(i);
// todo - see if check is necessary ??
checkRowData(session, data, cols);
deleteNoCheck(session, row);
}
for (int i = 0; i < rowSet.size(); i++) {
Object[] data = (Object[]) rowSet.get(i);
insertNoCheck(session, store, data);
}
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class Table method insertIntoTable.
/**
* Multi-row insert method. Used for CREATE TABLE AS ... queries.
*/
void insertIntoTable(Session session, Result result) {
PersistentStore store = session.sessionData.getRowStore(this);
RowSetNavigator nav = result.initialiseNavigator();
while (nav.hasNext()) {
Object[] data = nav.getNext();
Object[] newData = (Object[]) ArrayUtil.resizeArrayIfDifferent(data, getColumnCount());
insertData(store, newData);
}
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class StatementDML method executeMergeStatement.
/**
* Executes a MERGE statement. It is assumed that the argument
* is of the correct type.
*
* @return Result object
*/
Result executeMergeStatement(Session session) {
Result resultOut = null;
RowSetNavigator generatedNavigator = null;
PersistentStore store = session.sessionData.getRowStore(baseTable);
if (generatedIndexes != null) {
resultOut = Result.newUpdateCountResult(generatedResultMetaData, 0);
generatedNavigator = resultOut.getChainedResult().getNavigator();
}
int count = 0;
// data generated for non-matching rows
RowSetNavigatorClient newData = new RowSetNavigatorClient(8);
// rowset for update operation
HashMappedList updateRowSet = new HashMappedList();
RangeVariable[] joinRangeIterators = targetRangeVariables;
// populate insert and update lists
RangeIterator[] rangeIterators = new RangeIterator[joinRangeIterators.length];
for (int i = 0; i < joinRangeIterators.length; i++) {
rangeIterators[i] = joinRangeIterators[i].getIterator(session);
}
for (int currentIndex = 0; 0 <= currentIndex; ) {
RangeIterator it = rangeIterators[currentIndex];
boolean beforeFirst = it.isBeforeFirst();
if (it.next()) {
if (currentIndex < joinRangeIterators.length - 1) {
currentIndex++;
continue;
}
} else {
if (currentIndex == 1 && beforeFirst) {
Object[] data = getMergeInsertData(session);
if (data != null) {
newData.add(data);
}
}
it.reset();
currentIndex--;
continue;
}
// row matches!
if (updateExpressions != null) {
// this is always the second iterator
Row row = it.getCurrentRow();
Object[] data = getUpdatedData(session, baseTable, updateColumnMap, updateExpressions, baseTable.getColumnTypes(), row.getData());
updateRowSet.add(row, data);
}
}
// update any matched rows
if (updateRowSet.size() > 0) {
count = update(session, baseTable, updateRowSet);
}
// insert any non-matched rows
newData.beforeFirst();
while (newData.hasNext()) {
Object[] data = newData.getNext();
baseTable.insertRow(session, store, data);
if (generatedNavigator != null) {
Object[] generatedValues = getGeneratedColumns(data);
generatedNavigator.add(generatedValues);
}
}
baseTable.fireAfterTriggers(session, Trigger.INSERT_AFTER, newData);
count += newData.getSize();
if (resultOut == null) {
return Result.getUpdateCountResult(count);
} else {
resultOut.setUpdateCount(count);
return resultOut;
}
}
use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.
the class ScriptReaderBinary method readExistingData.
protected void readExistingData(Session session) throws IOException {
for (; ; ) {
String s = readTableInit();
if (s == null) {
break;
}
String schema = session.getSchemaName(currentSchema);
Table t = db.schemaManager.getUserTable(session, s, schema);
PersistentStore store = db.persistentStoreCollection.getStore(t);
int j = 0;
for (j = 0; ; j++) {
if (!readRow(store, t)) {
break;
}
}
int checkCount = readTableTerm();
if (j != checkCount) {
throw Error.error(ErrorCode.ERROR_IN_SCRIPT_FILE, ErrorCode.M_ERROR_IN_BINARY_SCRIPT_1, new Object[] { s, new Integer(j), new Integer(checkCount) });
}
}
}
Aggregations