本文整理汇总了Java中org.voltdb.utils.CatalogUtil.getVoltTable方法的典型用法代码示例。如果您正苦于以下问题:Java CatalogUtil.getVoltTable方法的具体用法?Java CatalogUtil.getVoltTable怎么用?Java CatalogUtil.getVoltTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.utils.CatalogUtil
的用法示例。
在下文中一共展示了CatalogUtil.getVoltTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Generator
import org.voltdb.utils.CatalogUtil; //导入方法依赖的package包/类
public Generator(CatalogContext catalogContext, int start, int stop) {
this.acctsTable = CatalogUtil.getVoltTable(catalogContext.getTableByName(SmallBankConstants.TABLENAME_ACCOUNTS));
this.savingsTable = CatalogUtil.getVoltTable(catalogContext.getTableByName(SmallBankConstants.TABLENAME_SAVINGS));
this.checkingTable = CatalogUtil.getVoltTable(catalogContext.getTableByName(SmallBankConstants.TABLENAME_CHECKING));
this.start = start;
this.stop = stop;
this.randBalance = new Gaussian(this.rand,
SmallBankConstants.MIN_BALANCE,
SmallBankConstants.MAX_BALANCE);
}
示例2: convertTable
import org.voltdb.utils.CatalogUtil; //导入方法依赖的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;
}
示例3: testQueryOrder
import org.voltdb.utils.CatalogUtil; //导入方法依赖的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);
}
}
示例4: convertTable
import org.voltdb.utils.CatalogUtil; //导入方法依赖的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);
// For column we have in new table convert and make compatible value.
coerced_values[i] = ParameterConverter.tryToMakeCompatible(
new_table.getColumnType(i).classFromType(),
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;
}