本文整理汇总了Java中org.voltdb.VoltTableRow类的典型用法代码示例。如果您正苦于以下问题:Java VoltTableRow类的具体用法?Java VoltTableRow怎么用?Java VoltTableRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VoltTableRow类属于org.voltdb包,在下文中一共展示了VoltTableRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: storeData
import org.voltdb.VoltTableRow; //导入依赖的package包/类
/**
* Store Data from MapOutput table into reduceInput table
* ReduceInput table is the result of all incoming mapOutput table from other partitions
* @see edu.brown.hstore.txns.AbstractTransaction#storeData(int, org.voltdb.VoltTable)
*/
@Override
public synchronized Status storeData(int partition, VoltTable vt) {
VoltTable input = this.getReduceInputByPartition(partition);
assert(input != null);
if (debug.val)
LOG.debug(String.format("StoreData into Partition #%d: RowCount=%d ",
partition, vt.getRowCount()));
if (debug.val)
LOG.debug(String.format("<StoreData, change to ReduceInputTable> to Partition:%d>\n %s",partition,vt));
while (vt.advanceRow()) {
VoltTableRow row = vt.fetchRow(vt.getActiveRowIndex());
assert(row != null);
input.add(row);
}
vt.resetRowPosition();
return Status.OK;
}
示例2: addHostData
import org.voltdb.VoltTableRow; //导入依赖的package包/类
@Override
void addHostData(VoltTableRow row) throws IOException {
assert (row.getString("TABLE").equals(getTableName()));
if (m_totalPartitions == 0) {
// XXX this cast should be okay unless we exceed MAX_INT partitions
m_totalPartitions = (int) row.getLong("TOTAL_PARTITIONS");
}
checkSiteConsistency(row); // throws if inconsistent
int originalPartitionId = (int) row.getLong("PARTITION");
m_partitionsSeen.add(originalPartitionId);
int currentHostId = (int) row.getLong("CURRENT_HOST_ID");
Set<Pair<Integer, Integer>> partitions_at_host = null;
if (!(m_partitionsAtHost.containsKey(currentHostId))) {
partitions_at_host = new HashSet<Pair<Integer, Integer>>();
m_partitionsAtHost.put(currentHostId, partitions_at_host);
}
partitions_at_host = m_partitionsAtHost.get(currentHostId);
partitions_at_host.add(Pair.of(originalPartitionId, (int) row.getLong("ORIGINAL_HOST_ID")));
}
示例3: constructTableState
import org.voltdb.VoltTableRow; //导入依赖的package包/类
private TableSaveFileState constructTableState(
VoltTableRow row)
{
TableSaveFileState table_state = null;
String table_name = row.getString("TABLE");
if (row.getString("IS_REPLICATED").equals("TRUE"))
{
table_state = new ReplicatedTableSaveFileState(table_name, m_allowExport);
table_state.setSystemProcedureExecutionContext(this.m_context);
}
else if (row.getString("IS_REPLICATED").equals("FALSE"))
{
table_state = new PartitionedTableSaveFileState(table_name, m_allowExport);
table_state.setSystemProcedureExecutionContext(this.m_context);
}
else
{
// XXX not reached
assert(false);
}
return table_state;
}
示例4: hashToSnapshot
import org.voltdb.VoltTableRow; //导入依赖的package包/类
private void hashToSnapshot(VoltTableRow r, HashMap<String, Snapshot> aggregates) {
assert (r.getString("RESULT").equals("SUCCESS"));
assert ("TRUE".equals(r.getString("READABLE")));
final String path = r.getString("PATH");
final String nonce = r.getString("NAME").substring(0, r.getString("NAME").indexOf('-'));
final String combined = path + nonce;
Snapshot s = aggregates.get(combined);
if (s == null) {
s = new Snapshot(r);
aggregates.put(combined, s);
} else {
if (r.getLong("CREATED") != s.m_createTime) {
return;
}
s.processRow(r);
}
}
示例5: reduce
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public void reduce(String key, Iterator<VoltTableRow> rows) {
long count = 0;
for (VoltTableRow r : CollectionUtil.iterable(rows)) {
assert(r != null);
//Long ct = (Long)r.getLong(1);
long ct = (long)r.getLong(1);
count+=ct;
//System.out.println("....key is: " + key + " Value: "+count);
} // FOR
// while (rows.hasNext()) {
// System.out.println("[row]: "+ key);
// count++;
// }
Object new_row[] = {
key,
count
};
this.reduceOutput.addRow(new_row);
}
示例6: run
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public VoltTable[] run(long acct_id) throws VoltAbortException {
voltQueueSQL(getTradeStatus, acct_id);
voltQueueSQL(getName, acct_id);
// we need only the first table
VoltTable ts = voltExecuteSQL()[0];
VoltTable result = trade_status_ret_template.clone(256);
for (int i = 0; i < ts.getRowCount(); i++) {
VoltTableRow ts_row = ts.fetchRow(i);
String status_name = ts_row.getString("ST_NAME");
long trade_id = ts_row.getLong("T_ID");
result.addRow(status_name, trade_id);
}
return new VoltTable[] {result};
}
示例7: testLongStringUsage
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public void testLongStringUsage() throws IOException {
System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
final int STRLEN = 5000;
Client client = getClient();
String longStringPart = "volt!";
StringBuilder sb = new StringBuilder();
while(sb.length() < STRLEN)
sb.append(longStringPart);
String longString = sb.toString();
assertEquals(STRLEN, longString.length());
VoltTable[] results = null;
try {
results = client.callProcedure("WorkWithBigString", 1, longString).getResults();
} catch (ProcCallException e) {
e.printStackTrace();
fail();
}
assertEquals(1, results.length);
VoltTableRow row = results[0].fetchRow(0);
assertEquals(1, row.getLong(0));
assertEquals(0, row.getString(2).compareTo(longString));
}
示例8: run
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public long run(int partId, VoltTable sp2Data, long[] extraArgs) {
for (int i=0; i < sp2Data.getRowCount(); i++) {
VoltTableRow row = sp2Data.fetchRow(i);
String symbol = row.getString("T_S_SYMB");
voltQueueSQL(getSecurityID, symbol, partId);
VoltTable v[] = voltExecuteSQL();
long SK_SecurityID = v[0].fetchRow(0).getLong(0);
long SK_CompanyID = v[0].fetchRow(0).getLong(1);
voltQueueSQL(insertSP3Out, row.getLong("T_ID"), row.getLong("SK_CreateDateID"), row.getLong("SK_CreateTimeID"),
row.getLong("SK_CloseDateID"), row.getLong("SK_CloseTimeID"), row.getString("Status"), row.getString("Type"),
(short) row.getLong("T_IS_CASH"), SK_SecurityID, SK_CompanyID, (int) row.getLong("T_QTY"),
row.getDouble("T_BID_PRICE"), (int) row.getLong("T_CA_ID"), row.getString("T_EXEC_NAME"),
row.getDouble("T_TRADE_PRICE"), row.getDouble("T_CHRG"), row.getDouble("T_COMM"), row.getDouble("T_TAX"),
row.getLong("batch_id"), partId);
int destinationPartition = TPCDIUtil.hashCode(TPCDIConstants.DIMACCOUNT_TABLE,String.valueOf(row.getLong("T_CA_ID")));
voltExecuteSQLDownStream("SP3out", destinationPartition);
}
// Set the return value to 0: successful vote
return TPCDIConstants.PROC_SUCCESSFUL;
}
示例9: run
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public long run(int partId, VoltTable sp2Data, long[] extraArgs) {
for (int i=0; i < sp2Data.getRowCount(); i++) {
VoltTableRow row = sp2Data.fetchRow(i);
String symbol = row.getString("T_S_SYMB");
voltQueueSQL(getSecurityID, symbol, partId);
VoltTable v[] = voltExecuteSQL();
long SK_SecurityID = v[0].fetchRow(0).getLong(0);
long SK_CompanyID = v[0].fetchRow(0).getLong(1);
voltQueueSQL(insertSP3Out, row.getLong("T_ID"), row.getLong("SK_CreateDateID"), row.getLong("SK_CreateTimeID"),
row.getLong("SK_CloseDateID"), row.getLong("SK_CloseTimeID"), row.getString("Status"), row.getString("Type"),
(short) row.getLong("T_IS_CASH"), SK_SecurityID, SK_CompanyID, (int) row.getLong("T_QTY"),
row.getDouble("T_BID_PRICE"), (int) row.getLong("T_CA_ID"), row.getString("T_EXEC_NAME"),
row.getDouble("T_TRADE_PRICE"), row.getDouble("T_CHRG"), row.getDouble("T_COMM"), row.getDouble("T_TAX"),
row.getLong("batch_id"), partId);
int destinationPartition = TPCDIUtil.hashCode(String.valueOf(row.getLong("T_CA_ID")), TPCDIConstants.NUM_PARTITIONS);
voltExecuteSQLDownStream("SP3out", destinationPartition);
}
// Set the return value to 0: successful vote
return TPCDIConstants.PROC_SUCCESSFUL;
}
示例10: reduce
import org.voltdb.VoltTableRow; //导入依赖的package包/类
@Override
public void reduce(Long key, Iterator<VoltTableRow> rows) {
double sum_ol_amount = 0;
VoltTableRow row = null;
for (VoltTableRow r : CollectionUtil.iterable(rows)) {
assert(r != null);
row = r;
sum_ol_amount += row.getDouble(3);
} // FOR
Object new_row[] = {
key,
row.getLong(1),
row.getLong(2),
sum_ol_amount,
row.getTimestampAsTimestamp(4)
};
this.reduceEmit(new_row);
}
示例11: run
import org.voltdb.VoltTableRow; //导入依赖的package包/类
public VoltTable[] run(short w_id, byte d_id, double h_amount, short c_w_id, byte c_d_id, String c_last, TimestampType timestamp) throws VoltAbortException {
// voltQueueSQL(getCustomersByLastName, c_last, c_d_id, c_w_id);
voltQueueSQL(getCidByLastName, c_last, c_d_id, c_w_id);
final VoltTable customersIds = voltExecuteSQL()[0];
final int namecnt = customersIds.getRowCount();
if (namecnt == 0) {
throw new VoltAbortException("no customers with last name: " + c_last + " in warehouse: "
+ c_w_id + " and in district " + c_d_id);
}
final int index = (namecnt-1)/2;
final VoltTableRow customerIdRow = customersIds.fetchRow(index);
final int c_id = (int)customerIdRow.getLong(C_ID_IDX);
voltQueueSQL(getCustomersByCustomerId, c_id, c_d_id, c_w_id);
final VoltTableRow customer = voltExecuteSQL()[0].fetchRow(0);
return processPayment(w_id, d_id, c_w_id, c_d_id, c_id, h_amount, customer, timestamp);
}
示例12: reduce
import org.voltdb.VoltTableRow; //导入依赖的package包/类
@Override
public void reduce(Long key, Iterator<VoltTableRow> rows) {
long sum_high = 0;
long sum_low = 0;
for (VoltTableRow r : CollectionUtil.iterable(rows)) {
assert(r != null);
sum_high += rows.next().getLong(1);
sum_low += rows.next().getLong(2);
} // FOR
Object new_row[] = {
key,
sum_high,
sum_low
};
this.reduceEmit(new_row);
}
示例13: map
import org.voltdb.VoltTableRow; //导入依赖的package包/类
@Override
public void map(VoltTableRow row) {
long key = row.getLong(0); // A_NAME
long quantity = row.getLong(1);
double amount = row.getDouble(2);
double price = row.getDouble(3);
long ct = row.getLong(4);
Object new_row[] = {
key,
quantity, // FIXME row.getLong(1)
amount,
price,
ct
};
this.mapEmit(key, new_row);
}
示例14: compareTables
import org.voltdb.VoltTableRow; //导入依赖的package包/类
private void compareTables(VoltTable vt0, VoltTable vt1) {
assertEquals(vt0.getRowCount(), vt1.getRowCount());
assertEquals(vt0.getColumnCount(), vt1.getColumnCount());
assert(vt1.getColumnCount() > 0);
int rows = 0;
while (vt0.advanceRow() && vt1.advanceRow()) {
VoltTableRow row0 = vt0.fetchRow(vt0.getActiveRowIndex());
VoltTableRow row1 = vt1.fetchRow(vt1.getActiveRowIndex());
for (int i = 0; i < vt0.getColumnCount(); i++) {
// System.err.println(i + ": " + row1.get(i));
assertEquals(row0.get(i), row1.get(i));
} // FOR
rows++;
} // WHILE
assert(rows > 0);
}
示例15: compare
import org.voltdb.VoltTableRow; //导入依赖的package包/类
@Override
public int compare(Object arg0, Object arg1) {
VoltTableRow r1 = (VoltTableRow)arg0;
VoltTableRow r2 = (VoltTableRow)arg1;
String r1d1 = (String) r1.get(0, VoltType.STRING);
String r1d2 = (String) r1.get(1, VoltType.STRING);
String r2d1 = (String) r2.get(0, VoltType.STRING);
String r2d2 = (String) r2.get(1, VoltType.STRING);
int r1d1_pos = Integer.valueOf(r1d1.substring(3));
int r1d2_pos = Integer.valueOf(r1d2.substring(3));
int r2d1_pos = Integer.valueOf(r2d1.substring(3));
int r2d2_pos = Integer.valueOf(r2d2.substring(3));
System.out.printf("comparing (%s, %s) to (%s, %s)\n",
r1d1, r1d2, r2d1, r2d2);
if (r1d1_pos != r2d1_pos)
return r1d1_pos - r2d1_pos;
if (r1d2_pos != r2d2_pos)
return r1d2_pos - r2d2_pos;
return 0;
}