use of org.voltdb.types.TimestampType in project voltdb by VoltDB.
the class paymentByCustomerIdC method processPayment.
public VoltTable[] processPayment(short w_id, byte d_id, short c_w_id, byte c_d_id, int c_id, double h_amount, VoltTableRow customer, TimestampType timestamp) {
//customer info
final byte[] c_first = customer.getStringAsBytes(C_FIRST_IDX);
final byte[] c_middle = customer.getStringAsBytes(C_MIDDLE_IDX);
final byte[] c_last = customer.getStringAsBytes(C_LAST_IDX);
final byte[] c_street_1 = customer.getStringAsBytes(C_STREET_1_IDX);
final byte[] c_street_2 = customer.getStringAsBytes(C_STREET_2_IDX);
final byte[] c_city = customer.getStringAsBytes(C_CITY_IDX);
final byte[] c_state = customer.getStringAsBytes(C_STATE_IDX);
final byte[] c_zip = customer.getStringAsBytes(C_ZIP_IDX);
final byte[] c_phone = customer.getStringAsBytes(C_PHONE_IDX);
final TimestampType c_since = customer.getTimestampAsTimestamp(C_SINCE_IDX);
final byte[] c_credit = customer.getStringAsBytes(C_CREDIT_IDX);
final double c_credit_lim = customer.getDouble(C_CREDIT_LIM_IDX);
final double c_discount = customer.getDouble(C_DISCOUNT_IDX);
final double c_balance = customer.getDouble(C_BALANCE_IDX) - h_amount;
final double c_ytd_payment = customer.getDouble(C_YTD_PAYMENT_IDX) + h_amount;
final int c_payment_cnt = (int) customer.getLong(C_PAYMENT_CNT_IDX) + 1;
byte[] c_data;
if (Arrays.equals(c_credit, Constants.BAD_CREDIT_BYTES)) {
c_data = customer.getStringAsBytes(C_DATA_IDX);
byte[] newData = (c_id + " " + c_d_id + " " + c_w_id + " " + d_id + " " + w_id + " " + h_amount + "|").getBytes();
int newLength = newData.length + c_data.length;
if (newLength > Constants.MAX_C_DATA) {
newLength = Constants.MAX_C_DATA;
}
ByteBuilder builder = new ByteBuilder(newLength);
int minLength = newLength;
if (newData.length < minLength)
minLength = newData.length;
builder.append(newData, 0, minLength);
int remaining = newLength - minLength;
builder.append(c_data, 0, remaining);
c_data = builder.array();
voltQueueSQL(updateBCCustomer, c_balance, c_ytd_payment, c_payment_cnt, c_data, c_w_id, c_d_id, c_id);
} else {
c_data = new byte[0];
voltQueueSQL(updateGCCustomer, c_balance, c_ytd_payment, c_payment_cnt, c_w_id, c_d_id, c_id);
}
voltExecuteSQL();
// TPC-C 2.5.3.3: Must display the following fields:
// W_ID, D_ID, C_ID, C_D_ID, C_W_ID, W_STREET_1, W_STREET_2, W_CITY, W_STATE, W_ZIP,
// D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, C_FIRST, C_MIDDLE, C_LAST, C_STREET_1,
// C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_SINCE, C_CREDIT, C_CREDIT_LIM,
// C_DISCOUNT, C_BALANCE, the first 200 characters of C_DATA (only if C_CREDIT = "BC"),
// H_AMOUNT, and H_DATE.
// Return the entire warehouse and district tuples. The client provided:
// w_id, d_id, c_d_id, c_w_id, h_amount, h_data.
// Build a table for the rest
final VoltTable misc = misc_template.clone(1024);
misc.addRow(c_id, c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_since, c_credit, c_credit_lim, c_discount, c_balance, c_data);
return new VoltTable[] { misc };
}
use of org.voltdb.types.TimestampType in project voltdb by VoltDB.
the class AllTypesJavaAbort method run.
public long run() {
// insert 100 times using different values
byte base = 1;
for (int i = 0; i < 100; i++, base++) {
char[] uninlineable = new char[1000];
for (int j = 0; j < uninlineable.length; j++) uninlineable[j] = (char) (base + 32);
voltQueueSQL(insert, base, base + 1, base + 2, base + 3, new TimestampType().getTime(), (double) base / 100.0, new BigDecimal(base), String.valueOf(base + 32), String.valueOf(uninlineable));
}
long tupleChanged = voltExecuteSQL()[0].asScalarLong();
assert (tupleChanged > 0);
throw new VoltAbortException("Emacs rules");
}
use of org.voltdb.types.TimestampType in project voltdb by VoltDB.
the class AllTypesJavaError method run.
public long run() {
// insert 100 times using different values
byte base = 1;
for (int i = 0; i < 100; i++, base++) {
char[] uninlineable = new char[1000];
for (int j = 0; j < uninlineable.length; j++) uninlineable[j] = (char) (base + 32);
voltQueueSQL(insert, base, base + 1, base + 2, base + 3, new TimestampType().getTime(), (double) base / 100.0, new BigDecimal(base), String.valueOf(base + 32), String.valueOf(uninlineable));
}
long tupleChanged = voltExecuteSQL()[0].asScalarLong();
assert (tupleChanged > 0);
// divide by 0 to ensure the transaction gets rolled back
return (5 / 0);
}
use of org.voltdb.types.TimestampType in project voltdb by VoltDB.
the class AllTypesMultiOpsJavaError method run.
public long run(int[] order, int id) {
byte base = 1;
for (int i : order) {
char[] uninlineable = new char[1000];
for (int j = 0; j < uninlineable.length; j++) uninlineable[j] = (char) (base + 32);
switch(i) {
case INSERT:
voltQueueSQL(statements[i], id, base + 1, base + 2, base + 3, new TimestampType().getTime(), base / 100.0, new BigDecimal(base), String.valueOf(base + 32), String.valueOf(uninlineable));
case UPDATE:
voltQueueSQL(statements[i], base + 1, base + 2, base + 3, new TimestampType().getTime(), base / 100.0, new BigDecimal(base), String.valueOf(base + 32), String.valueOf(uninlineable), id);
case DELETE:
voltQueueSQL(statements[i], id);
case TRUNCATE:
voltQueueSQL(statements[i]);
}
base++;
}
long tupleChanged = voltExecuteSQL()[0].asScalarLong();
assert (tupleChanged > 0);
// divide by 0 to cause error so that everything will be rolled back.
return (5 / 0);
}
use of org.voltdb.types.TimestampType in project voltdb by VoltDB.
the class TestParameterSet method testGetCRCWithoutCrash.
public void testGetCRCWithoutCrash() throws IOException {
ParameterSet pset;
PureJavaCrc32C crc;
ByteBuffer buf;
Object[] psetObjs = new Object[] { // null values
null, // null values
VoltType.NULL_INTEGER, // null values
VoltType.NULL_DECIMAL, // numbers
(byte) 1, // numbers
(short) 2, // numbers
(int) 3, // numbers
(long) 4, // numbers
1.2f, // numbers
3.6d, // strings
"This is spinal tap", // strings
"", // binary
"ABCDF012", // binary
new byte[] { 1, 3, 5 }, // binary
new byte[0], // decimal
new BigDecimal(5.5), // timestamp
new TimestampType(new Date()) };
pset = ParameterSet.fromArrayNoCopy(psetObjs);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc1 = crc.getValue();
ArrayUtils.reverse(psetObjs);
pset = ParameterSet.fromArrayNoCopy(psetObjs);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc2 = crc.getValue();
pset = ParameterSet.fromArrayNoCopy(new Object[0]);
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc3 = crc.getValue();
pset = ParameterSet.fromArrayNoCopy(new Object[] { 1 });
crc = new PureJavaCrc32C();
buf = ByteBuffer.allocate(pset.getSerializedSize());
pset.flattenToBuffer(buf);
crc.update(buf.array());
long crc4 = crc.getValue();
assertNotSame(crc1, crc2);
assertNotSame(crc1, crc3);
assertNotSame(crc1, crc4);
assertNotSame(crc2, crc3);
assertNotSame(crc2, crc4);
assertNotSame(crc3, crc4);
}
Aggregations