use of org.voltdb.VoltTableRow in project voltdb by VoltDB.
the class TRUPTruncateTableMP method run.
public VoltTable[] run(long p, byte shouldRollback) {
voltQueueSQL(truncate);
voltQueueSQL(count);
voltQueueSQL(scancount);
VoltTable[] results = voltExecuteSQL(true);
VoltTable data = results[1];
VoltTableRow row = data.fetchRow(0);
long optCount = row.getLong(0);
if (optCount != 0) {
throw new VoltAbortException("after truncate (opt) count not zero");
}
data = results[2];
row = data.fetchRow(0);
long scanCount = row.getLong(0);
if (scanCount != 0) {
throw new VoltAbortException("after truncate (scan) count not zero");
}
if (shouldRollback != 0) {
throw new VoltAbortException("EXPECTED ROLLBACK");
}
return results;
}
use of org.voltdb.VoltTableRow in project voltdb by VoltDB.
the class TRUPTruncateTableSP method run.
public VoltTable[] run(long p, byte shouldRollback) {
voltQueueSQL(truncate);
voltQueueSQL(count);
voltQueueSQL(scancount);
VoltTable[] results = voltExecuteSQL(true);
VoltTable data = results[1];
VoltTableRow row = data.fetchRow(0);
long optCount = row.getLong(0);
if (optCount != 0) {
throw new VoltAbortException("after truncate (opt) count not zero");
}
data = results[2];
row = data.fetchRow(0);
long scanCount = row.getLong(0);
if (scanCount != 0) {
throw new VoltAbortException("after truncate (scan) count not zero");
}
if (shouldRollback != 0) {
throw new VoltAbortException("EXPECTED ROLLBACK");
}
return results;
}
use of org.voltdb.VoltTableRow in project voltdb by VoltDB.
the class ImportBaseProc method doWork.
protected VoltTable[] doWork(SQLStmt select, SQLStmt update, SQLStmt insert, SQLStmt select_bitmap, SQLStmt update_bitmap, SQLStmt insert_bitmap, byte cid, long ts, long cnt) {
byte[] bitmap;
// compute sequence and offsets
long seq = cnt / 1024;
int bb = (int) ((cnt - seq * 1024) % 1024);
int B = bb / 8;
int b = bb % 8;
byte mask = (byte) Math.pow(2, 7 - b);
voltQueueSQL(select, cid);
voltQueueSQL(select_bitmap, cid, seq);
VoltTable[] results = voltExecuteSQL();
VoltTable data = results[0];
int rowCount = data.getRowCount();
if (rowCount != 0) {
if (rowCount != 1)
throw new VoltAbortException(getClass().getName() + "should get only one row per cid");
VoltTableRow row = data.fetchRow(0);
long fcid = row.getLong("cid");
if (fcid != cid)
throw new VoltAbortException(getClass().getName() + " serious error expected cid " + cid + " != fetched cid: " + fcid);
long mts = Math.max(row.getLong("ts"), ts);
long mcnt = Math.max(row.getLong("cnt"), cnt);
voltQueueSQL(update, mts, mcnt, cid);
} else {
voltQueueSQL(insert, ts, cid, cnt, 1);
}
VoltTable bmdata = results[1];
rowCount = bmdata.getRowCount();
if (rowCount != 0) {
VoltTableRow row = bmdata.fetchRow(0);
bitmap = row.getVarbinary("bitmap");
if ((bitmap[B] & mask) != 0) {
// detect/report duplicates ?
}
bitmap[B] |= mask;
voltQueueSQL(update_bitmap, bitmap, cid, seq);
} else {
bitmap = new byte[1024];
bitmap[B] |= mask;
voltQueueSQL(insert_bitmap, cid, seq, bitmap);
}
return voltExecuteSQL(true);
}
use of org.voltdb.VoltTableRow in project voltdb by VoltDB.
the class PopulateDimension method run.
// INSERT one row per cid to the dimension table unless already exists
public VoltTable[] run(byte cid) {
voltQueueSQL(d_getCount, cid);
VoltTable[] results = voltExecuteSQL(false);
VoltTable dim = results[0];
long rowCount = dim.getRowCount();
if (rowCount != 1) {
throw new VoltAbortException(getClass().getName() + " invalid row count " + rowCount + " for count query" + " on dimension table for cid " + cid);
}
VoltTableRow row = dim.fetchRow(0);
long c = row.getLong(0);
switch((int) c) {
case 0:
voltQueueSQL(d_Insert, cid, cid);
results = voltExecuteSQL(true);
case 1:
return new VoltTable[] {};
default:
throw new VoltAbortException(getClass().getName() + " invalid count " + c + " of dimension rows" + " for cid " + cid);
}
}
use of org.voltdb.VoltTableRow in project voltdb by VoltDB.
the class paymentByCustomerNameW method run.
public VoltTable[] run(short w_id, byte d_id, double h_amount, short c_w_id, byte c_d_id, byte[] c_last, TimestampType timestamp) throws VoltAbortException {
// retrieve c_id from replicated CUSTOMER_NAME table
voltQueueSQL(getCidByLastName, c_last, c_d_id, c_w_id);
final VoltTable result = voltExecuteSQL()[0];
final int namecnt = result.getRowCount();
if (namecnt == 0) {
String c_lastString = null;
try {
c_lastString = new String(c_last, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
throw new VoltAbortException("paymentByCustomerNameW: no customers with last name: " + c_lastString + " in warehouse: " + c_w_id + " and in district " + c_d_id);
}
final int index = (namecnt - 1) / 2;
final VoltTableRow customer = result.fetchRow(index);
final long c_id = customer.getLong(0);
return processPayment(w_id, d_id, h_amount, c_w_id, c_d_id, c_id, timestamp);
}
Aggregations