use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient in project voltdb by VoltDB.
the class Result method newSingleColumnResult.
public static Result newSingleColumnResult(String colName, Type type) {
Result result = newResult(ResultConstants.DATA);
result.metaData = ResultMetaData.newResultMetaData(1);
result.metaData.columns[0] = new ColumnBase(null, null, null, colName);
result.metaData.columns[0].setType(type);
result.metaData.prepareData();
//
result.navigator = new RowSetNavigatorClient(8);
return result;
}
use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient in project voltdb by VoltDB.
the class Result method newDataResult.
public static Result newDataResult(ResultMetaData md) {
Result result = newResult(ResultConstants.DATA);
result.navigator = new RowSetNavigatorClient();
result.metaData = md;
return result;
}
use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient 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.navigator.RowSetNavigatorClient in project voltdb by VoltDB.
the class StatementInsert method getInsertSelectNavigator.
RowSetNavigator getInsertSelectNavigator(Session session) {
Type[] colTypes = baseTable.getColumnTypes();
int[] columnMap = insertColumnMap;
//
Result result = queryExpression.getResult(session, 0);
RowSetNavigator nav = result.initialiseNavigator();
Type[] sourceTypes = result.metaData.columnTypes;
RowSetNavigatorClient newData = new RowSetNavigatorClient(2);
while (nav.hasNext()) {
Object[] data = baseTable.getNewRowData(session);
Object[] sourceData = (Object[]) nav.getNext();
for (int i = 0; i < columnMap.length; i++) {
int j = columnMap[i];
Type sourceType = sourceTypes[i];
data[j] = colTypes[j].convertToType(session, sourceData[i], sourceType);
}
newData.add(data);
}
return newData;
}
use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient in project voltdb by VoltDB.
the class Result method newResult.
public static Result newResult(int type) {
RowSetNavigator navigator = null;
Result result = null;
switch(type) {
case ResultConstants.CALL_RESPONSE:
case ResultConstants.EXECUTE:
navigator = new RowSetNavigatorClient(1);
break;
case ResultConstants.UPDATE_RESULT:
navigator = new RowSetNavigatorClient(1);
break;
case ResultConstants.BATCHEXECUTE:
case ResultConstants.BATCHEXECDIRECT:
navigator = new RowSetNavigatorClient(4);
break;
case ResultConstants.SETSESSIONATTR:
case ResultConstants.PARAM_METADATA:
navigator = new RowSetNavigatorClient(1);
break;
case ResultConstants.BATCHEXECRESPONSE:
navigator = new RowSetNavigatorClient(4);
break;
case ResultConstants.DATA:
case ResultConstants.DATAHEAD:
case ResultConstants.DATAROWS:
break;
case ResultConstants.LARGE_OBJECT_OP:
throw Error.runtimeError(ErrorCode.U_S0500, "Result");
default:
}
result = new Result();
result.mode = (byte) type;
result.navigator = navigator;
return result;
}
Aggregations