use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class SchemaChangeUtility method maxId.
/**
* Find the largest pkey value in the table.
*/
static long maxId(Client client, VoltTable t, int timeout) {
if (t == null) {
return 0;
}
ClientResponse cr = callROProcedureWithRetry(client, "@AdHoc", timeout, String.format("select pkey from %s order by pkey desc limit 1;", TableHelper.getTableName(t)));
assert (cr.getStatus() == ClientResponse.SUCCESS);
VoltTable result = cr.getResults()[0];
return result.getRowCount() > 0 ? result.asScalarLong() : 0;
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class MaterializedViewBenchmark method printResults.
/**
* Prints the results and statistics about performance.
*
* @param procedure The name of the stored procedure that was tested.
* @throws Exception if anything unexpected happens.
*/
public synchronized void printResults(String procedure) throws Exception {
ClientStats stats = fullStatsContext.fetchAndResetBaseline().getStats();
double execTimeInMicroSec = 0.0;
// 1. Results and performance statistics
System.out.print(HORIZONTAL_RULE);
System.out.println(" Results");
System.out.println(HORIZONTAL_RULE);
System.out.printf("Average throughput: %,9d txns/sec\n", stats.getTxnThroughput());
VoltTable procStats = client.callProcedure("@Statistics", "procedureprofile", 0).getResults()[0];
while (procStats.advanceRow()) {
String procName = procStats.getString("PROCEDURE");
if (procName.equals(procedure)) {
execTimeInMicroSec = (procStats.getLong("AVG") / 1000.0);
System.out.printf("Average execution time: %,9f usec\n", execTimeInMicroSec);
break;
}
}
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class MaterializedViewBenchmark method printResults.
/**
* Prints the results and statistics about performance.
*
* @param procedure The name of the stored procedure that was tested. fw File writer object to write stats to.
* suffix Label for the row in the csv file.
* @throws Exception if anything unexpected happens.
*/
public synchronized void printResults(String procedure, FileWriter fw, String suffix) throws Exception {
ClientStats stats = fullStatsContext.fetchAndResetBaseline().getStats();
double execTimeInMicroSec = 0.0;
// 1. Results and performance statistics
System.out.print(HORIZONTAL_RULE);
System.out.println(" Results");
System.out.println(HORIZONTAL_RULE);
System.out.printf("Average throughput: %,9d txns/sec\n", stats.getTxnThroughput());
VoltTable procStats = client.callProcedure("@Statistics", "procedureprofile", 0).getResults()[0];
while (procStats.advanceRow()) {
String procName = procStats.getString("PROCEDURE");
if (procName.equals(procedure)) {
execTimeInMicroSec = (procStats.getLong("AVG") / 1000.0);
System.out.printf("Average execution time: %,9f usec\n", execTimeInMicroSec);
break;
}
}
// 3. Write stats to file if requested
fw.append(String.format("%s,%d,-1,%d,0,0,0,%.2f,0,0,0,0,0,0\n", suffix, stats.getStartTimestamp(), stats.getTxnThroughput(), execTimeInMicroSec));
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class CappedTableLoader method exceedsCappedLimit.
private boolean exceedsCappedLimit() throws NoConnectionsException, IOException, ProcCallException {
boolean ret = false;
VoltTable partitions = client.callProcedure("@GetPartitionKeys", "INTEGER").getResults()[0];
long count = TxnId2Utils.doAdHoc(client, "SELECT COUNT(*) FROM capr;").getResults()[0].fetchRow(0).getLong(0);
if (count > 10) {
log.error("Replicated table CAPR has more rows (" + count + ") than the limit set by capped collections (10)");
ret = true;
}
while (partitions.advanceRow()) {
long id = partitions.getLong(0);
long key = partitions.getLong(1);
count = client.callProcedure("CAPPCountPartitionRows", key).getResults()[0].fetchRow(0).getLong(0);
if (count > 10) {
log.error("Replicated table CAPP has more rows (" + count + ") than the limit set by capped collections (10) on partition " + id);
ret = true;
}
}
return ret;
}
use of org.voltdb.VoltTable in project voltdb by VoltDB.
the class ClientThread method runOne.
void runOne() throws Exception {
// 1/10th of txns roll back
byte shouldRollback = (byte) (m_random.nextInt(10) == 0 ? 1 : 0);
try {
String procName = null;
int expectedTables = 5;
switch(m_type) {
case PARTITIONED_SP:
procName = "UpdatePartitionedSP";
break;
case PARTITIONED_MP:
procName = "UpdatePartitionedMP";
expectedTables = 6;
break;
case REPLICATED:
procName = "UpdateReplicatedMP";
expectedTables = 6;
break;
case HYBRID:
procName = "UpdateBothMP";
expectedTables = 6;
break;
case ADHOC_MP:
procName = "UpdateReplicatedMPInProcAdHoc";
expectedTables = 6;
break;
}
byte[] payload = m_processor.generateForStore().getStoreValue();
ClientResponse response;
try {
response = m_client.callProcedure(procName, m_cid, m_nextRid, payload, shouldRollback);
} catch (Exception e) {
if (shouldRollback == 0) {
log.warn("ClientThread threw after " + m_txnsRun.get() + " calls while calling procedure: " + procName + " with args: cid: " + m_cid + ", nextRid: " + m_nextRid + ", payload: " + payload + ", shouldRollback: " + shouldRollback);
}
throw e;
}
// fake a proc call exception if we think one should be thrown
if (response.getStatus() != ClientResponse.SUCCESS) {
throw new UserProcCallException(response);
}
VoltTable[] results = response.getResults();
m_txnsRun.incrementAndGet();
if (results.length != expectedTables) {
hardStop(String.format("Client cid %d procedure %s returned %d results instead of %d", m_cid, procName, results.length, expectedTables), response);
}
VoltTable data = results[3];
VoltTable view = results[4];
try {
UpdateBaseProc.validateCIDData(data, view, "ClientThread:" + m_cid);
} catch (VoltAbortException vae) {
log.error("validateCIDData failed on: " + procName + ", shouldRollback: " + shouldRollback + " data: " + data);
throw vae;
}
} finally {
// ensure rid is incremented (if not rolled back intentionally)
if (shouldRollback == 0) {
m_nextRid++;
}
}
}
Aggregations