本文整理汇总了Java中org.voltdb.VoltTable.get方法的典型用法代码示例。如果您正苦于以下问题:Java VoltTable.get方法的具体用法?Java VoltTable.get怎么用?Java VoltTable.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.VoltTable
的用法示例。
在下文中一共展示了VoltTable.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: storeTableInMap
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Store
*
* @param map
* @param vt
*/
public static void storeTableInMap(final Map<String, Object[]> map, final VoltTable vt) {
assert (vt != null);
assert (map != null);
int num_rows = vt.getRowCount();
while (vt.advanceRow()) {
int row_idx = vt.getActiveRowIndex();
for (int i = 0, cnt = vt.getColumnCount(); i < cnt; i++) {
String col_name = vt.getColumnName(i);
VoltType vtype = vt.getColumnType(i);
if (row_idx == 0) {
map.put(col_name, new Object[num_rows]);
}
map.get(col_name)[row_idx] = vt.get(col_name, vtype);
} // FOR
} // WHILE
}
示例3: testDistributedSum_View
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* distributed sums of a view
* select sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) from V
* @throws InterruptedException
*/
public void testDistributedSum_View() throws IOException, ProcCallException, InterruptedException {
VoltTable vt;
Client client = getClient();
loadF(client, 0);
// FIXME String qs = "select sum(V.SUM_v1), sum(V.SUM_V2), sum(V.SUM_V3) from V";
String qs = "select sum(V.SUM_v1), sum(V.SUM_V2) from V";
vt = client.callProcedure("@AdHoc", qs).getResults()[0];
System.out.println("testDistributedSum_View result: " + vt);
assertTrue(vt.getRowCount() == 1);
while (vt.advanceRow()) {
Integer sum1 = (Integer) vt.get(0, VoltType.INTEGER);
assertEquals(2000, sum1.intValue());
Integer sum2 = (Integer) vt.get(1, VoltType.INTEGER);
assertEquals(4995000, sum2.intValue());
// FIXME Integer sum3 = (Integer) vt.get(2, VoltType.INTEGER);
// FIXME assertEquals(500, sum3.intValue());
}
}
示例4: testSelectDistinctA
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/** select distinct a1 from t1 */
public void testSelectDistinctA() throws IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
loaderNxN(client, 0);
vt = client.callProcedure("@AdHoc", "select distinct a1 from t1").getResults()[0];
System.out.println("testSelectDistinctA result row("
+ vt.getColumnName(0) + ") " + vt);
// valid result is the set {1,2,...,11}
int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
while (vt.advanceRow()) {
Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
System.out.println("\tdistinct value: " + A1.intValue());
assertEquals("A1", vt.getColumnName(0));
assertTrue(A1 <= 11);
assertTrue(A1 > 0);
found[A1.intValue()] += 1;
}
assertEquals(0, found[0]);
for (int i = 1; i < 12; i++) {
assertEquals(1, found[i]);
}
}
示例5: testDistributedSum
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* distributed sums of a partitioned table
* select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F
* @throws InterruptedException
*/
public void testDistributedSum() throws IOException, ProcCallException, InterruptedException {
VoltTable vt;
Client client = getClient();
loadF(client, 0);
String qs = "select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F";
vt = client.callProcedure("@AdHoc", qs).getResults()[0];
System.out.println("testDistributedSum result: " + vt);
assertTrue(vt.getRowCount() == 1);
while (vt.advanceRow()) {
Integer sum1 = (Integer) vt.get(0, VoltType.INTEGER);
assertEquals(2000, sum1.intValue());
Integer sum2 = (Integer) vt.get(1, VoltType.INTEGER);
assertEquals(4995000, sum2.intValue());
Integer sum3 = (Integer) vt.get(2, VoltType.INTEGER);
assertEquals(500, sum3.intValue());
}
}
示例6: testSelectAGroubyA
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/** select A1 from T1 group by A1 */
public void testSelectAGroubyA() throws IOException, ProcCallException {
Client client = this.getClient();
VoltTable vt;
loaderNxN(client, 0);
vt = client.callProcedure("@AdHoc", "Select * from T1").getResults()[0];
System.out.println("T1-*:" + vt);
// execute the query
vt = client.callProcedure("@AdHoc", "SELECT A1 from T1 group by A1").getResults()[0];
// one row per unique value of A1
System.out.println("testSelectAGroubyA: " + vt);
assertTrue(vt.getRowCount() == 11);
// Selecting A1 - should get values 1 through 11
// once each. These results aren't necessarily ordered.
int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
while (vt.advanceRow()) {
Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
assertTrue(A1 <= 11);
assertTrue(A1 > 0);
found[A1.intValue()] += 1;
}
assertEquals(0, found[0]);
for (int i = 1; i < 12; i++) {
assertEquals(1, found[i]);
}
}
示例7: testSelectSumAGroupbyA
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/** select A1, sum(A1) from T1 group by A1 */
public void testSelectSumAGroupbyA() throws IOException, ProcCallException {
VoltTable vt;
Client client = this.getClient();
loaderNxN(client, 0);
String qs = "select A1, sum(A1) from T1 group by A1";
vt = client.callProcedure("@AdHoc", qs).getResults()[0];
System.out.println("testSelectSumAGroupbyA result: " + vt);
assertEquals(11, vt.getRowCount());
int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
while (vt.advanceRow()) {
Integer a1 = (Integer) vt.get(0, VoltType.INTEGER);
Integer sum = (Integer) vt.get(1, VoltType.INTEGER);
found[a1.intValue()] += 1;
// A1 = 11 is a special case
if (a1.intValue() == 11)
assertEquals(11, sum.intValue());
// every other n appears n times. The sum is therefore n x n.
else
assertEquals(a1.intValue() * a1.intValue(), sum.intValue());
}
assertEquals(0, found[0]);
for (int i = 1; i < 12; i++)
assertEquals(found[i], 1); // one result for each unique A1
}
示例8: testSelectCount
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/** select count(A1) from T1 */
public void testSelectCount() throws IOException, ProcCallException {
VoltTable vt;
Client client = getClient();
loaderNxN(client, 0);
vt = client.callProcedure("@AdHoc", "select count(A1) from T1").getResults()[0];
assertTrue(vt.getRowCount() == 1);
// there are 56 rows in the table 1 + 2 + 3 + .. + 10 + 1
while (vt.advanceRow()) {
Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
System.out.println("select count = " + A1.intValue());
assertEquals(56, A1.intValue());
}
}
示例9: testSelectCountDistinct
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/** select count(distinct A1) from T1 */
public void testSelectCountDistinct() throws IOException, ProcCallException {
VoltTable vt;
Client client = getClient();
loaderNxN(client, 0);
vt = client
.callProcedure("@AdHoc", "select count(distinct A1) from T1").getResults()[0];
assertTrue(vt.getRowCount() == 1);
// there are 11 distinct values for A1
while (vt.advanceRow()) {
Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
assertEquals(11, A1.intValue());
}
}
示例10: convertTable
import org.voltdb.VoltTable; //导入方法依赖的package包/类
public static VoltTable convertTable(VoltTable inputTable,
Table outputTableSchema)
throws VoltTypeException
{
VoltTable new_table =
CatalogUtil.getVoltTable(outputTableSchema);
Map<Integer, Integer> column_copy_index_map =
computeColumnCopyIndexMap(inputTable, new_table);
// Copy all the old tuples into the new table
while (inputTable.advanceRow())
{
Object[] coerced_values =
new Object[new_table.getColumnCount()];
for (int i = 0; i < new_table.getColumnCount(); i++)
{
if (column_copy_index_map.containsKey(i))
{
int orig_column_index = column_copy_index_map.get(i);
coerced_values[i] =
inputTable.get(orig_column_index,
inputTable.getColumnType(orig_column_index));
}
else
{
// otherwise if it's nullable, insert null,
Column catalog_column =
outputTableSchema.getColumns().
get(new_table.getColumnName(i));
VoltType default_type =
VoltType.get((byte)catalog_column.getDefaulttype());
if (default_type != VoltType.INVALID)
{
// if there is a default value for this table/column
// insert the default value
try
{
coerced_values[i] =
VoltTypeUtil.
getObjectFromString(default_type,
catalog_column.
getDefaultvalue());
}
catch (ParseException e)
{
String message = "Column: ";
message += new_table.getColumnName(i);
message += " has an unparseable default: ";
message += catalog_column.getDefaultvalue();
message += " for VoltType: ";
message += default_type.toString();
throw new VoltTypeException(message);
}
}
else if (catalog_column.getNullable())
{
coerced_values[i] = null;
}
else
{
throw new VoltTypeException("Column: " +
new_table.getColumnName(i) +
" has no default " +
"and null is not permitted");
}
}
}
new_table.addRow(coerced_values);
}
return new_table;
}
示例11: format
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* Pretty-printer for an array of VoltTables. This will reset
* each VoltTable's row position both before and after generating the
* formatted output
* @param results
* @return
*/
public static String format(VoltTable...results) {
StringBuilder sb = new StringBuilder();
final int num_results = results.length;
TableUtil.Format f = TableUtil.defaultTableFormat();
f.spacing_col = true;
f.trim_all = true;
f.delimiter_all = " | ";
// TABLE RESULTS
for (int result_idx = 0; result_idx < num_results; result_idx++) {
if (result_idx > 0) sb.append("\n\n");
VoltTable vt = results[result_idx];
vt.resetRowPosition();
String header[] = new String[vt.getColumnCount()];
for (int i = 0; i < header.length; i++) {
String colName = vt.getColumnName(i);
header[i] = (colName.isEmpty() ? "<empty>" : colName);
} // FOR
Object rows[][] = new Object[vt.getRowCount()][];
f.delimiter_rows = new String[rows.length];
for (int i = 0; i < rows.length; i++) {
rows[i] = new Object[header.length];
f.delimiter_rows[i] = "-";
boolean adv = vt.advanceRow();
assert(adv);
for (int j = 0; j < header.length; j++) {
rows[i][j] = vt.get(j);
if (vt.wasNull()) {
rows[i][j] = null;
}
} // FOR (cols)
} // FOR (rows)
sb.append(String.format("Result #%d / %d\n", result_idx+1, num_results));
String resultTable = TableUtil.table(f, header, rows);
resultTable = StringBoxUtil.box(resultTable,
StringBoxUtil.UNICODE_BOX_HORIZONTAL,
StringBoxUtil.UNICODE_BOX_VERTICAL,
null,
StringBoxUtil.UNICODE_BOX_CORNERS);
sb.append(StringUtil.prefix(resultTable, " "));
vt.resetRowPosition();
} // FOR
return (sb.toString());
}
示例12: testDistributedSumAndGroup
import org.voltdb.VoltTable; //导入方法依赖的package包/类
/**
* distributed sums of a view (REDUNDANT GROUP BY)
* select V.D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3)
* from V group by V.V_D1_PKEY
* @throws InterruptedException
*/
public void testDistributedSumAndGroup() throws NoConnectionsException,
ProcCallException, IOException, InterruptedException {
VoltTable vt;
Client client = getClient();
loadF(client, 0);
// FIXME String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) "
// + "from V group by V.V_D1_PKEY";
String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2) "
+ "from V group by V.V_D1_PKEY";
vt = client.callProcedure("@AdHoc", qs).getResults()[0];
System.out.println("testDistributedSumAndJoin result: " + vt);
assert (vt.getRowCount() == 10); // 10 unique values for dim1 which is
// the grouping col
int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
while (vt.advanceRow()) {
Integer d1 = (Integer) vt.get(0, VoltType.INTEGER);
Integer s1 = (Integer) vt.get(1, VoltType.INTEGER);
Integer s2 = (Integer) vt.get(2, VoltType.INTEGER);
// FIXME Integer s3 = (Integer) vt.get(3, VoltType.INTEGER);
// track that 10 dim1s are in the final group
found[d1.intValue()] += 1;
// sum1 is const 2. 100 dim1 instances / group
assertEquals(200, s1.intValue());
// sum of every 10th i * 10 in this range
assertTrue(495000 <= s2.intValue() && 504000 >= s2.intValue());
// FIXME
// sum3 alternates 0|1. There are 100 dim1 instances / group
// if ((d1.intValue() % 2) == 0)
// assertEquals(s3.intValue(), 0);
// else
// assertEquals(s3.intValue(), 100);
}
for (int i = 0; i < 10; i++)
assertEquals(1, found[i]);
}
示例13: evaluate
import org.voltdb.VoltTable; //导入方法依赖的package包/类
@Override
public <T> Object evaluate(T tuple) {
VoltTable row = (VoltTable) tuple;
VoltType type = row.getColumnType(row.getColumnIndex(m_name));
return row.get(m_name, type);
}