本文整理汇总了Java中org.voltdb.VoltTable.addRow方法的典型用法代码示例。如果您正苦于以下问题:Java VoltTable.addRow方法的具体用法?Java VoltTable.addRow怎么用?Java VoltTable.addRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.VoltTable
的用法示例。
在下文中一共展示了VoltTable.addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrimaryKeys
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
{
assert(table != null && !table.isEmpty());
checkClosed();
this.sysCatalog.setString(1, "PRIMARYKEYS");
JDBC4ResultSet res = (JDBC4ResultSet) this.sysCatalog.executeQuery();
VoltTable vtable = res.getVoltTable().clone(0);
// Filter the primary keys based on table name
while (res.next()) {
if (res.getString("TABLE_NAME").equals(table.toUpperCase())) {
vtable.addRow(res.getRowData());
}
}
return new JDBC4ResultSet(sysCatalog, vtable);
}
示例2: getIndexInfo
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException
{
assert(table != null && !table.isEmpty());
checkClosed();
this.sysCatalog.setString(1, "INDEXINFO");
JDBC4ResultSet res = (JDBC4ResultSet) this.sysCatalog.executeQuery();
VoltTable vtable = res.getVoltTable().clone(0);
// Filter the indexes by table name
while (res.next()) {
if (res.getString("TABLE_NAME").equals(table.toUpperCase())) {
if (!unique || res.getShort("NON_UNIQUE") == 0) {
vtable.addRow(res.getRowData());
}
}
}
return new JDBC4ResultSet(sysCatalog, vtable);
}
示例3: createVerticalPartitionPlan
import org.voltdb.VoltTable; //导入方法依赖的package包/类
private SynthesizedPlanFragment[] createVerticalPartitionPlan(LocalTransaction ts, MaterializedViewInfo catalog_view, VoltTable table) {
Table virtual_tbl = catalog_view.getDest();
VoltTable vt = CatalogUtil.getVoltTable(virtual_tbl);
Collection<Column> virtual_cols = CatalogUtil.getColumns(catalog_view.getGroupbycols());
table.resetRowPosition();
while (table.advanceRow()) {
int i = 0;
Object row[] = new Object[virtual_cols.size()];
for (Column catalog_col : CatalogUtil.getSortedCatalogItems(virtual_cols, "index")) {
if (trace.val)
LOG.trace(String.format("Adding %s [%d] to virtual column %d",
table.getColumnName(catalog_col.getIndex()), catalog_col.getIndex(), i));
row[catalog_col.getIndex()] = table.get(catalog_col.getIndex());
} // FOR
vt.addRow(row);
} // WHILE
if (debug.val)
LOG.info(String.format("Vertical Partition %s -> %s\n",
catalog_view.getParent().getName(), virtual_tbl.getName()) + vt);
return (createReplicatedPlan(ts, virtual_tbl, vt));
}
示例4: formatFinalResults
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public String formatFinalResults(BenchmarkResults br) {
if (this.stop) return (null);
VoltTable vt = new VoltTable(this.columns);
for (Object row[] : this.results) {
vt.addRow(row);
}
try {
FileWriter writer = new FileWriter(this.outputPath);
VoltTableUtil.csv(writer, vt, true);
writer.close();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
LOG.info("Wrote CSV memory stats to '" + this.outputPath.getAbsolutePath() + "'");
return (null);
}
示例5: executePlanFragment
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public DependencySet executePlanFragment(Long txn_id,
Map<Integer, List<VoltTable>> dependencies,
int fragmentId,
ParameterSet params,
PartitionExecutor.SystemProcedureExecutionContext context) {
// Nothing to do
System.out.println("executePlanFragment!!! in get configuration");
assert(fragmentId == SysProcFragmentId.PF_getConfiguration);
HStoreConf hstore_conf = executor.getHStoreConf();
String confNames[] = (String[])params.toArray();
for (int i = 0; i < confNames.length; i++) {
if (hstore_conf.hasParameter((String)params.toArray()[i]) == false) {
String msg = String.format("Invalid configuration parameter '%s'", confNames[i]);
throw new VoltAbortException(msg);
}
} // FOR
VoltTable vt = new VoltTable(nodeResultsColumns);
TimestampType timestamp = new TimestampType();
for (int i = 0; i < confNames.length; i++) {
Object val = hstore_conf.get(confNames[i]);
vt.addRow(executor.getSiteId(),
confNames[i],
val.toString(),
timestamp);
} // FOR
DependencySet result = new DependencySet(SysProcFragmentId.PF_getConfiguration, vt);
return (result);
}
示例6: getCatalogs
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public ResultSet getCatalogs() throws SQLException
{
checkClosed();
VoltTable result = new VoltTable(new VoltTable.ColumnInfo("TABLE_CAT",VoltType.STRING));
result.addRow(new Object[] { catalogString });
return new JDBC4ResultSet(null, result);
}
示例7: loadTableByRandom
import org.voltdb.VoltTable; //导入方法依赖的package包/类
private void loadTableByRandom(AbstractTable at, VoltTable vt, Map<String, VoltTable> memory)
{
String sTblName = at.getName();
Column[] cols = TableEnv.getAllColumns(TableEnv.getTable(sTblName));
Object[] row = new Object[vt.getColumnCount()];
for (int iRow = 0; iRow < at.getCardinality(); iRow++)
{
for (Column col : cols)
{
final int iCol = col.getIndex();
Column referredCol = TableEnv.getReferredColumn(col);
if (referredCol != null)
{
VoltTable referredTbl = memory.get(referredCol.getParent().getName());
row[iCol] = pickRandomVal(referredTbl, referredCol);
}
else
{
row[iCol] = at.getColumnValGenerators()[iCol].genRandVal();
}
}
vt.addRow(row);
}
loadTable(sTblName, vt);
memory.put(sTblName, vt);
}
示例8: run
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public VoltTable[] run(String[] broker_list, String sector_name) throws VoltAbortException {
// it seems we should return only the volumes
VoltTable result = new VoltTable(new VoltTable.ColumnInfo("volume", VoltType.FLOAT));
List<Double> volumes = new ArrayList<Double>();
for (int i = 0; i < broker_list.length; i++) {
voltQueueSQL(getBrokerInfo, broker_list[i], sector_name);
VoltTable brok_res = voltExecuteSQL()[0];
if (brok_res.getRowCount() > 0) {
double vol = 0;
for (int j = 0; j < brok_res.getRowCount(); j++) {
vol += brok_res.fetchRow(j).getDouble(1);
}
volumes.add(vol);
}
}
// sort the values
Collections.sort(volumes);
// populating the result table in reverse order (since we need order by desc)
for (int i = volumes.size() - 1; i >= 0; i--) {
result.addRow(volumes.get(i));
}
return new VoltTable[] {result};
}
示例9: generateCustomers
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate customers table per benchmark spec.
*/
void generateCustomers() {
int cid = 0;
VoltTable customerTbl = initializeCustomerDataTable();
Object row[] = new Object[customerTbl.getColumnCount()];
while (cid < kMaxCustomers / m_scalefactor) {
int col = 0;
row[col++] = new Integer(cid++);
for (int j=0; j < 20; ++j) {
row[col++] = astring(6,8);
}
for (int j=0; j < 20; ++j) {
row[col++] = number(0, 1<<30);
}
assert (col == customerTbl.getColumnCount());
customerTbl.addRow(row);
if (customerTbl.getRowCount() >= kCustomerBatchSize) {
System.err.printf("CUSTOMERS: loading %d rows (cid %d of %d)\n",
customerTbl.getRowCount(), cid, (kMaxCustomers / m_scalefactor));
loadTable("CUSTOMERS", customerTbl);
customerTbl.clearRowData();
}
}
System.err.println("CUSTOMERS: loading final " + customerTbl.getRowCount() + " rows.");
loadTable("CUSTOMERS", customerTbl);
customerTbl.clearRowData();
}
示例10: testBuildPartitionResult
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* testBuildPartitionResult
*/
public void testBuildPartitionResult() throws Exception {
Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SPECIAL_FACILITY);
VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
assertNotNull(vt);
int num_rows = 50;
for (int i = 0; i < num_rows; i++) {
Object row[] = new Object[catalog_tbl.getColumns().size()];
for (int j = 0; j < row.length; j++) {
VoltType vtype = VoltType.get(catalog_tbl.getColumns().get(j).getType());
row[j] = VoltTypeUtil.getRandomValue(vtype, rand);
} // FOR
vt.addRow(row);
} // FOR
int dep_id = 10001;
DependencySet result = new DependencySet(new int[]{ dep_id }, new VoltTable[]{ vt });
RemoteTransaction ts = new RemoteTransaction(hstore_site);
WorkResult partitionResult = executor.buildWorkResult(ts, result, Status.OK, null);
assertNotNull(partitionResult);
assertEquals(result.size(), partitionResult.getDepDataCount());
assertEquals(1, partitionResult.getDepDataCount());
for (int i = 0; i < partitionResult.getDepDataCount(); i++) {
assertEquals(dep_id, partitionResult.getDepId(i));
ByteString bs = partitionResult.getDepData(i);
assertFalse(bs.isEmpty());
System.err.println("SIZE: " + StringUtil.md5sum(bs.asReadOnlyByteBuffer()));
byte serialized[] = bs.toByteArray();
VoltTable clone = FastDeserializer.deserialize(serialized, VoltTable.class);
assertNotNull(clone);
assertEquals(vt.getRowCount(), clone.getRowCount());
assertEquals(vt.getColumnCount(), clone.getColumnCount());
} // FOR
}
示例11: testAddResultsBeforeStart
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* testAddResultsBeforeStart
*/
public void testAddResultsBeforeStart() throws Exception {
this.ts.initFirstRound(UNDO_TOKEN, NUM_DUPLICATE_STATEMENTS);
this.addFragments();
// We need to test to make sure that we don't get a CountDownLatch with the wrong count
// if we start the round *after* a bunch of results have arrived.
// Add a bunch of fake results
Long marker = 1000l;
List<Long> markers = new ArrayList<Long>();
for (int dependency_id : this.dependency_ids) {
for (int partition = 0; partition < NUM_PARTITIONS; partition++) {
// If this dependency is meant to go back to the VoltProcedure, then
// we want to add a row so that we can figure out whether we are getting
// the results back in the right order
if (!this.internal_dependency_ids.contains(dependency_id)) {
// Skip anything that isn't our local partition
if (partition != LOCAL_PARTITION) continue;
VoltTable copy = new VoltTable(FAKE_RESULTS_COLUMNS);
copy.addRow(marker, "XXXX");
this.depTracker.addResult(this.ts, partition, dependency_id, copy);
markers.add(marker++);
// Otherwise just stuff in our fake result (if they actually need it)
} else if (this.dependency_partitions.get(dependency_id).contains(partition)) {
this.depTracker.addResult(this.ts, partition, dependency_id, FAKE_RESULT);
}
} // FOR (partition)
} // FOR (dependency ids)
assertEquals(NUM_DUPLICATE_STATEMENTS, markers.size());
this.ts.startRound(LOCAL_PARTITION);
CountDownLatch latch = this.depTracker.getDependencyLatch(this.ts);
assertNotNull(latch);
assertEquals(0, latch.getCount());
}
示例12: getStatusTable
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static VoltTable getStatusTable(boolean success) {
VoltTable vt = new VoltTable(statusColumns);
vt.addRow((success ? 1 : 0));
return (vt);
}
示例13: generateReservations
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Populate RESERVATIONS per benchmark spec
*/
void generateReservations() {
// iterate through the flights.
// pick 70-90% of the 150 seats in the flight.
// pick a customer (who is not booked for this flight).
// create a reservation row.
// assign cids to fids in a deterministic way so
// that (cid, fid) pairs can be generated by the
// benchmark for the ChangeSeat procedure.
/* Creates a table of cids like this (using 6
* seats per aircraft, 10 total customers)
SEAT
1 2 3 4 5 6
FID
1 1 4 7 10 3 6
2 2 5 8 1 4 7
3 3 6 9 2 5 8
cid = f(fid,seat) = (maxfid * (seat -1) + fid) % maxcust
is in range to be on the flight.
(Actually, I think this gives a wrong answer (0 v. max) for
the maximum customer ID. 0 is an invalid cid so this can be
caught and fixed...)
*/
int maxcids = kMaxCustomers / m_scalefactor;
int maxfids = kMaxFlights / m_scalefactor;
int cid = 1;
int rid = 1;
VoltTable reservationTbl = initializeReservationDataTable();
Object row[] = new Object[reservationTbl.getColumnCount()];
for (int seatnum = 1; seatnum < 151; ++seatnum) {
for (int fid = 1; fid < maxfids + 1; ++fid) {
// always advance cid, even if seat is empty
cid = (cid++ % maxcids);
if (seatIsOccupied()) {
int col = 0;
row[col++] = new Integer(rid++);
row[col++] = new Integer(cid);
row[col++] = new Integer(fid);
row[col++] = new Integer(seatnum);
for (int j=0; j < 9; ++j) {
row[col++] = number(1, 1<<30);
}
reservationTbl.addRow(row);
if (reservationTbl.getRowCount() >= kReservationBatchSize) {
System.err.printf("RESERVATIONS: loading %d rows (fid %d of %d)\n",
reservationTbl.getRowCount(), fid, maxfids);
loadTable("RESERVATIONS", reservationTbl);
reservationTbl.clearRowData();
}
}
}
}
System.err.println("RESERVATIONS: loading final " + reservationTbl.getRowCount() + " rows.");
loadTable("RESERVATIONS", reservationTbl);
reservationTbl.clearRowData();
}
示例14: testQueryOrder
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* testQueryOrder
*/
public void testQueryOrder() throws Exception {
System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
// This checks that we get the execution order of queries correct.
// In a single query batch we will first execute an update on a replicated
// table and then execute a second query that will read from that table. The
// second query should get the new value from the first query and not the
// original value.
Client client = this.getClient();
CatalogContext catalogContext = this.getCatalogContext();
Table catalog_tbl = catalogContext.getTableByName(TPCCConstants.TABLENAME_ITEM);
assertTrue(catalog_tbl.getIsreplicated());
int expectedNumItems = 10;
VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
for (int i = 0; i < expectedNumItems; i++) {
Object row[] = VoltTableUtil.getRandomRow(catalog_tbl);
row[0] = i;
vt.addRow(row);
} // FOR
RegressionSuiteUtil.load(client, catalog_tbl, vt);
long numItems = RegressionSuiteUtil.getRowCount(client, catalog_tbl);
assertEquals(expectedNumItems, numItems);
String procName = UpdateItemName.class.getSimpleName();
long itemId = this.getRandom().number(TPCCConstants.STARTING_ITEM, numItems);
String itemName = "Tone Loc";
ClientResponse cr = client.callProcedure(procName, itemId, itemName);
assertEquals(cr.toString(), Status.OK, cr.getStatus());
assertEquals(cr.toString(), 1, cr.getResults().length);
try {
if(cr.getResults()[0].getRowCount() != 0){
assertTrue(cr.toString(), cr.getResults()[0].advanceRow());
assertEquals(itemName, cr.getResults()[0].getString(0));
}
} catch (Throwable ex) {
System.err.printf("TARGET: %d/%s\n", itemId, itemName);
cr = RegressionSuiteUtil.sql(client, "SELECT * FROM " + TPCCConstants.TABLENAME_ITEM);
System.err.println(VoltTableUtil.format(cr.getResults()));
throw new Exception(ex);
}
}
示例15: saveTest
import org.voltdb.VoltTable; //导入方法依赖的package包/类
private DependencySet saveTest(String file_path, String file_nonce, SystemProcedureExecutionContext context, String hostname) {
{
VoltTable result = constructNodeResultsTable();
// Choose the lowest site ID on this host to do the file scan
// All other sites should just return empty results tables.
Host catalog_host = context.getHost();
Site site = context.getSite();
CatalogMap<Partition> partition_map = site.getPartitions();
Integer lowest_partition_id = Integer.MAX_VALUE, p_id;
Integer lowest_site_id = Integer.MAX_VALUE, s_id;
for(Site st : CatalogUtil.getAllSites(catalog_host)){
s_id = st.getId();
lowest_site_id = Math.min(s_id, lowest_site_id);
}
for(Partition pt : partition_map){
p_id = pt.getId();
lowest_partition_id = Math.min(p_id, lowest_partition_id);
}
assert(lowest_partition_id != Integer.MAX_VALUE);
//LOG.trace("Partition id :" + context.getPartitionExecutor().getPartitionId());
//LOG.trace("Lowest Partition id :" + lowest_partition_id);
// Do it at partition with lowest partition id on site with lowest site id
// as we can have multiple partitions per site in HStore
if (context.getSite().getId() == lowest_site_id && context.getPartitionExecutor().getPartitionId() == lowest_partition_id) {
LOG.trace("Checking feasibility of save with path and nonce: " + file_path + ", " + file_nonce);
LOG.trace("ExecutionSitesCurrentlySnapshotting check : " + SnapshotSiteProcessor.ExecutionSitesCurrentlySnapshotting.get());
// CHANGE : Only 1 Site doing this
if (SnapshotSiteProcessor.ExecutionSitesCurrentlySnapshotting.get() != -1) {
result.addRow(Integer.parseInt(context.getSite().getHost().getTypeName().replaceAll("[\\D]", "")), hostname, "", "FAILURE", "SNAPSHOT IN PROGRESS");
return new DependencySet(DEP_saveTest, result);
}
for (Table table : SnapshotUtil.getTablesToSave(context.getDatabase())) {
File saveFilePath = SnapshotUtil.constructFileForTable(table, file_path, file_nonce,
String.valueOf(context.getHost().getId()),
String.valueOf(context.getHStoreSite().getSiteId()),
String.valueOf(context.getPartitionExecutor().getPartitionId())
);
LOG.trace("Host ID " + context.getSite().getHost().getTypeName() + " table: " + table.getTypeName() + " to path: " + saveFilePath);
String file_valid = "SUCCESS";
String err_msg = "";
if (saveFilePath.exists()) {
file_valid = "FAILURE";
err_msg = "SAVE FILE ALREADY EXISTS: " + saveFilePath;
} else if (!saveFilePath.getParentFile().canWrite()) {
file_valid = "FAILURE";
err_msg = "FILE LOCATION UNWRITABLE: " + saveFilePath;
} else {
try {
saveFilePath.createNewFile();
} catch (IOException ex) {
file_valid = "FAILURE";
err_msg = "FILE CREATION OF " + saveFilePath + "RESULTED IN IOException: " + ex.getMessage();
}
}
result.addRow(catalog_host.getId(), hostname, context.getHStoreSite().getSiteId(), context.getPartitionExecutor().getPartitionId(), table.getTypeName(), file_valid, err_msg);
}
}
//LOG.trace("Host ID " + context.getSite().getHost().getTypeName() + "\n" + new DependencySet(DEP_saveTest, result));
return new DependencySet(DEP_saveTest, result);
}
}