use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class PutMp method run.
public VoltTable[] run(String key, byte[] value) {
long putCounter = 0;
// Check whether the pair exists
voltQueueSQL(checkStmt, key);
VoltTable[] queryresults = voltExecuteSQL();
// Insert new or update existing key depending on result
if (queryresults[0].getRowCount() == 0) {
//New key gets putCounter set to 0
for (int i = 0; i < 8; i++) {
value[i] = 0;
}
voltQueueSQL(insertStmt, key, value);
} else {
// Get the old count from 1st 8 bytes, increment it, stuff it
// back in
queryresults[0].advanceRow();
ByteBuffer bb = ByteBuffer.wrap(queryresults[0].getVarbinary(1));
putCounter = bb.getLong(0);
putCounter++;
bb.putLong(0, putCounter);
voltQueueSQL(updateStmt, bb.array(), key);
}
voltExecuteSQL(true);
VoltTable[] t = new VoltTable[1];
t[0] = new VoltTable(new VoltTable.ColumnInfo("counter", VoltType.BIGINT));
t[0].addRow(putCounter);
return t;
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class PutMp method run.
@SuppressWarnings("deprecation")
public VoltTable[] run(String key, byte[] value) {
long putCounter = 0;
// Check whether the pair exists
voltQueueSQL(checkStmt, key);
VoltTable[] queryresults = voltExecuteSQL();
// Insert new or update existing key depending on result
if (queryresults[0].getRowCount() == 0) {
//New key gets putCounter set to 0
for (int i = 0; i < 8; i++) {
value[i] = 0;
}
voltQueueSQL(insertStmt, key, value);
} else {
// Get the old count from 1st 8 bytes, increment it, stuff it
// back in
queryresults[0].advanceRow();
ByteBuffer bb = ByteBuffer.wrap(queryresults[0].getVarbinary(1));
putCounter = bb.getLong(0);
putCounter++;
bb.putLong(0, putCounter);
voltQueueSQL(updateStmt, bb.array(), key);
voltQueueSQL(exportStmt, queryresults[0].getString(0), queryresults[0].getVarbinary(1), getTransactionTime(), DeprecatedProcedureAPIAccess.getVoltPrivateRealTransactionId(this), getSeededRandomNumberGenerator().nextDouble());
}
voltExecuteSQL(true);
VoltTable[] t = new VoltTable[1];
t[0] = new VoltTable(new VoltTable.ColumnInfo("counter", VoltType.BIGINT));
t[0].addRow(putCounter);
return t;
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class AsyncBenchmark method printResults.
/**
* Prints the results of the voting simulation and statistics
* about performance.
*
* @throws Exception if anything unexpected happens.
*/
public synchronized void printResults() throws Exception {
ClientStats stats = fullStatsContext.fetch().getStats();
// 1. Voting Board statistics, Voting results and performance statistics
String display = "\n" + HORIZONTAL_RULE + " Voting Results\n" + HORIZONTAL_RULE + "\nA total of %d votes were received...\n" + " - %,9d Accepted\n" + " - %,9d Rejected (Invalid Contestant)\n" + " - %,9d Rejected (Maximum Vote Count Reached)\n" + " - %,9d Failed (Transaction Error)\n\n";
System.out.printf(display, stats.getInvocationsCompleted(), acceptedVotes.get(), badContestantVotes.get(), badVoteCountVotes.get(), failedVotes.get());
// 2. Voting results
VoltTable result = client.callProcedure("Results").getResults()[0];
System.out.println("Contestant Name\t\tVotes Received");
while (result.advanceRow()) {
System.out.printf("%s\t\t%,14d\n", result.getString(0), result.getLong(2));
}
System.out.printf("\nThe Winner is: %s\n\n", result.fetchRow(0).getString(0));
// 3. Performance statistics
System.out.print(HORIZONTAL_RULE);
System.out.println(" Client Workload Statistics");
System.out.println(HORIZONTAL_RULE);
System.out.printf("Average throughput: %,9d txns/sec\n", stats.getTxnThroughput());
System.out.printf("Average latency: %,9.2f ms\n", stats.getAverageLatency());
System.out.printf("95th percentile latency: %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.95));
System.out.printf("99th percentile latency: %,9.2f ms\n", stats.kPercentileLatencyAsDouble(.99));
System.out.print("\n" + HORIZONTAL_RULE);
System.out.println(" System Server Statistics");
System.out.println(HORIZONTAL_RULE);
if (config.autotune) {
System.out.printf("Targeted Internal Avg Latency: %,9d ms\n", config.latencytarget);
}
System.out.printf("Reported Internal Avg Latency: %,9.2f ms\n", stats.getAverageInternalLatency());
// 4. Write stats to file if requested
client.writeSummaryCSV(stats, config.statsfile);
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class PassAllArgTypes method run.
public VoltTable[] run(byte b, byte[] bArray, short s, short[] sArray, int i, int[] iArray, long l, long[] lArray, String str, byte[] bString, TimestampType tst, java.util.Date utild, java.sql.Date sqld, java.sql.Timestamp ts) throws VoltAbortException {
if (b != 100)
throw new VoltAbortException();
if (bArray[0] != 100 || bArray[1] != 101 || bArray[2] != 102)
throw new VoltAbortException();
if (s != 32000)
throw new VoltAbortException();
if (sArray[0] != 32000 || sArray[1] != 32001 || sArray[2] != 32002)
throw new VoltAbortException();
if (i != 2147483640)
throw new VoltAbortException();
if (iArray[0] != 2147483640 || iArray[1] != 2147483641 || iArray[2] != 2147483642)
throw new VoltAbortException();
if (l != Long.MAX_VALUE - 10)
throw new VoltAbortException();
if (lArray[0] != Long.MAX_VALUE - 10 || lArray[1] != Long.MAX_VALUE - 9 || lArray[2] != Long.MAX_VALUE - 8)
throw new VoltAbortException();
if (!str.equals("foo"))
throw new VoltAbortException();
try {
if (!(new String(bString, "UTF-8").equals("bar")))
throw new VoltAbortException();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!tst.equals(new TimestampType(MILLISECONDS_SINCE_EPOCH_TEST_VALUE * 1000))) {
throw new VoltAbortException();
}
if (!utild.equals(new java.util.Date(MILLISECONDS_SINCE_EPOCH_TEST_VALUE))) {
throw new VoltAbortException();
}
if (!sqld.equals(new java.sql.Date(MILLISECONDS_SINCE_EPOCH_TEST_VALUE))) {
throw new VoltAbortException();
}
if (!ts.equals(new java.sql.Timestamp(MILLISECONDS_SINCE_EPOCH_TEST_VALUE))) {
throw new VoltAbortException();
}
VoltTable result0 = new VoltTable(new VoltTable.ColumnInfo("b", VoltType.typeFromClass(byte.class)), new VoltTable.ColumnInfo("bArray", VoltType.typeFromClass(byte[].class)), new VoltTable.ColumnInfo("s", VoltType.typeFromClass(short.class)), // new VoltTable.ColumnInfo("sArray", VoltType.typeFromClass(short[].class)),
new VoltTable.ColumnInfo("i", VoltType.typeFromClass(int.class)), // new VoltTable.ColumnInfo("iArray", VoltType.typeFromClass(int[].class)),
new VoltTable.ColumnInfo("l", VoltType.typeFromClass(long.class)), // new VoltTable.ColumnInfo("lArray", VoltType.typeFromClass(long[].class)),
new VoltTable.ColumnInfo("str", VoltType.typeFromClass(String.class)), new VoltTable.ColumnInfo("bString", VoltType.typeFromClass(byte[].class)), new VoltTable.ColumnInfo("tst", VoltType.typeFromClass(TimestampType.class)), new VoltTable.ColumnInfo("utild", VoltType.typeFromClass(java.util.Date.class)), new VoltTable.ColumnInfo("sqld", VoltType.typeFromClass(java.sql.Date.class)), new VoltTable.ColumnInfo("ts", VoltType.typeFromClass(java.sql.Timestamp.class)));
result0.addRow(b, bArray, s, /*sArray,*/
i, /*iArray,*/
l, /*lArray,*/
str, bString, tst, utild, sqld, ts);
VoltTable result1 = new VoltTable(new VoltTable.ColumnInfo("sArray", VoltType.typeFromClass(short.class)));
for (int j = 0; j < sArray.length; j++) {
result1.addRow(sArray[j]);
}
VoltTable result2 = new VoltTable(new VoltTable.ColumnInfo("iArray", VoltType.typeFromClass(int.class)));
for (int j = 0; j < iArray.length; j++) {
result2.addRow(iArray[j]);
}
VoltTable result3 = new VoltTable(new VoltTable.ColumnInfo("lArray", VoltType.typeFromClass(long.class)));
for (int j = 0; j < lArray.length; j++) {
result3.addRow(lArray[j]);
}
return new VoltTable[] { result0, result1, result2, result3 };
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class SelectEmptyTable method run.
public VoltTable[] run(int id) {
VoltTable empty1 = new VoltTable(new VoltTable.ColumnInfo("column1", VoltType.BIGINT), new VoltTable.ColumnInfo("column2", VoltType.BIGINT), new VoltTable.ColumnInfo("column3", VoltType.BIGINT), new VoltTable.ColumnInfo("column4", VoltType.BIGINT), new VoltTable.ColumnInfo("checktime", VoltType.BIGINT));
VoltTable empty2 = new VoltTable(new VoltTable.ColumnInfo("called_time_milliseconds", VoltType.BIGINT));
final VoltTable[] vtReturn = { empty1, empty2 };
return vtReturn;
}
Aggregations