本文整理汇总了Java中org.voltdb.utils.CatalogUtil类的典型用法代码示例。如果您正苦于以下问题:Java CatalogUtil类的具体用法?Java CatalogUtil怎么用?Java CatalogUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CatalogUtil类属于org.voltdb.utils包,在下文中一共展示了CatalogUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableDataIterable
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
/**
* Constructor
*
* @param catalog_tbl
* @param table_file
* @param has_header
* whether we expect the data file to include a header in the
* first row
* @param auto_generate_first_column
* TODO
* @throws Exception
*/
public TableDataIterable(Table catalog_tbl, File table_file, boolean has_header, boolean auto_generate_first_column) throws Exception {
this.catalog_tbl = catalog_tbl;
this.table_file = table_file;
this.auto_generate_first_column = auto_generate_first_column;
this.reader = new CSVReader(FileUtil.getReader(this.table_file));
// Throw away the first row if there is a header
if (has_header) {
this.reader.readNext();
this.line_ctr++;
}
// Column Types + Foreign Keys
// Determine whether the column references a foreign key, and thus will
// need to be converted to an integer field later
this.types = new VoltType[catalog_tbl.getColumns().size()];
this.fkeys = new boolean[this.types.length];
this.nullable = new boolean[this.types.length];
for (Column catalog_col : catalog_tbl.getColumns()) {
int idx = catalog_col.getIndex();
this.types[idx] = VoltType.get((byte) catalog_col.getType());
this.fkeys[idx] = (CatalogUtil.getForeignKeyParent(catalog_col) != null);
this.nullable[idx] = catalog_col.getNullable();
} // FOR
}
示例2: createSaveRestoreSchemaCatalog
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public Catalog createSaveRestoreSchemaCatalog() throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
String catalogJar = testDir + File.separator + "saverestore-jni.jar";
addDefaultSchema();
addDefaultPartitioning();
addDefaultProcedures();
addStmtProcedure("JumboInsert", "INSERT INTO JUMBO_ROW VALUES ( ?, ?, ?)", "JUMBO_ROW.PKEY: 0");
addStmtProcedure("JumboSelect", "SELECT * FROM JUMBO_ROW WHERE PKEY = ?", "JUMBO_ROW.PKEY: 0");
addStmtProcedure("JumboCount", "SELECT COUNT(*) FROM JUMBO_ROW");
boolean status = compile(catalogJar);
assert (status);
// read in the catalog
String serializedCatalog = CatalogUtil.loadCatalogFromJar(catalogJar, null);
assert (serializedCatalog != null);
// create the catalog (that will be passed to the ClientInterface
Catalog catalog = new Catalog();
catalog.execute(serializedCatalog);
return catalog;
}
示例3: createTPCCSchemaCatalog
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public Catalog createTPCCSchemaCatalog(boolean fkeys) throws IOException {
// compile a catalog
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
String catalogJar = testDir + File.separator + this.getJarName(true);
addSchema(this.getDDLURL(fkeys));
addDefaultPartitioning();
addDefaultProcedures();
//this.addProcedures(org.voltdb.benchmark.tpcc.procedures.InsertHistory.class);
boolean status = compile(catalogJar);
assert(status);
// read in the catalog
String serializedCatalog = CatalogUtil.loadCatalogFromJar(catalogJar, null);
assert(serializedCatalog != null);
// create the catalog (that will be passed to the ClientInterface
Catalog catalog = new Catalog();
catalog.execute(serializedCatalog);
return catalog;
}
示例4: setUp
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
Statement stmts[] = catalog_proc.getStatements().values();
for (int i = 0; i < NUM_OF_QUERIES; i++) {
int idx = rand.nextInt(stmts.length);
// System.out.println("idx=" + idx);
// System.out.println("num_of_stmts=" + num_of_stmts);
// System.out.println(catalog_proc.getStatements().size());
Statement catalog_stmt = stmts[idx];
assertNotNull(catalog_stmt);
List<StmtParameter> catalog_params = CatalogUtil.getSortedCatalogItems(catalog_stmt.getParameters(), "index");
Pair<Object[], boolean[]> param_pair = this.makeParams(catalog_params, "javatype");
this.query_params.add((Object[])param_pair.getFirst());
this.query_traces.add(new QueryTrace(catalog_stmt, query_params.get(i), 0));
this.xact.getQueries().add(this.query_traces.get(i));
} // FOR
}
示例5: populateExportSequenceNumbersForExecutionSite
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public static void populateExportSequenceNumbersForExecutionSite(SystemProcedureExecutionContext context) {
Database database = context.getDatabase();
for (Table t : database.getTables()) {
if (!CatalogUtil.isTableExportOnly(database, t))
continue;
Map<Integer, Pair<Long,Long>> sequenceNumbers = m_exportSequenceNumbers.get(t.getTypeName());
if (sequenceNumbers == null) {
sequenceNumbers = new HashMap<Integer, Pair<Long, Long>>();
m_exportSequenceNumbers.put(t.getTypeName(), sequenceNumbers);
}
long[] ackOffSetAndSequenceNumber =
context.getSiteProcedureConnection().getUSOForExportTable(t.getSignature());
sequenceNumbers.put(
context.getPartitionId(),
Pair.of(
ackOffSetAndSequenceNumber[0],
ackOffSetAndSequenceNumber[1]));
}
}
示例6: filter
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
static boolean filter(TransactionInfoBaseMessage tibm)
{
// don't log sysproc fragments or iv2 initiate task messages.
// this is all jealously; should be refactored to ask tibm
// if it wants to be filtered for rejoin and eliminate this
// horrible introspection. This implementation mimics the
// original live rejoin code for ExecutionSite...
// Multi part AdHoc Does not need to be chacked because its an alias and runs procedure as planned.
if (tibm instanceof FragmentTaskMessage && ((FragmentTaskMessage)tibm).isSysProcTask()) {
if (!SysProcFragmentId.isDurableFragment(((FragmentTaskMessage) tibm).getPlanHash(0))) {
return true;
}
}
else if (tibm instanceof Iv2InitiateTaskMessage) {
Iv2InitiateTaskMessage itm = (Iv2InitiateTaskMessage) tibm;
//All durable sysprocs and non-sysprocs should not get filtered.
return !CatalogUtil.isDurableProc(itm.getStoredProcedureName());
}
return false;
}
示例7: setupDefaultDeployment
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
/**
* Create default deployment.xml file in voltdbroot if the deployment path is null.
*
* @return path to default deployment file
* @throws IOException
*/
static String setupDefaultDeployment() throws IOException {
// Since there's apparently no deployment to override the path to voltdbroot it should be
// safe to assume it's under the working directory.
// CatalogUtil.getVoltDbRoot() creates the voltdbroot directory as needed.
File voltDbRoot = CatalogUtil.getVoltDbRoot(null);
String pathToDeployment = voltDbRoot.getPath() + File.separator + "deployment.xml";
File deploymentXMLFile = new File(pathToDeployment);
hostLog.info("Generating default deployment file \"" + deploymentXMLFile.getAbsolutePath() + "\"");
BufferedWriter bw = new BufferedWriter(new FileWriter(deploymentXMLFile));
for (String line : defaultDeploymentXML) {
bw.write(line);
bw.newLine();
}
bw.flush();
bw.close();
return deploymentXMLFile.getAbsolutePath();
}
示例8: getTablesToSave
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public static final List<Table> getTablesToSave(Database database)
{
CatalogMap<Table> all_tables = database.getTables();
ArrayList<Table> my_tables = new ArrayList<Table>();
for (Table table : all_tables)
{
// Make a list of all non-materialized, non-export only tables
if ((table.getMaterializer() != null) ||
(CatalogUtil.isTableExportOnly(database, table)))
{
continue;
}
my_tables.add(table);
}
return my_tables;
}
示例9: tableListIncludesExportOnly
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
/**
* Return true if tableList includes at least one export table.
*/
private boolean tableListIncludesExportOnly(List<Table> tableList) {
// list of all export tables (assume uppercase)
NavigableSet<String> exportTables = CatalogUtil.getExportTableNames(m_catalogDb);
// this loop is O(number-of-joins * number-of-export-tables)
// which seems acceptable if not great. Probably faster than
// re-hashing the export only tables for faster lookup.
for (Table table : tableList) {
if (exportTables.contains(table.getTypeName())) {
return true;
}
}
return false;
}
示例10: setGroupedTablePartitionColumn
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
private void setGroupedTablePartitionColumn(MaterializedViewInfo mvi, Column partitionColumn)
throws VoltCompilerException {
// A view of a replicated table is replicated.
// A view of a partitioned table is partitioned -- regardless of whether it has a partition key
// -- it certainly isn't replicated!
// If the partitioning column is grouped, its counterpart is the partitioning column of the view table.
// Otherwise, the view table just doesn't have a partitioning column
// -- it is seemingly randomly distributed,
// and its grouped columns are only locally unique but not globally unique.
Table destTable = mvi.getDest();
// Get the grouped columns in "index" order.
// This order corresponds to the iteration order of the MaterializedViewInfo's getGroupbycols.
List<Column> destColumnArray = CatalogUtil.getSortedCatalogItems(destTable.getColumns(), "index");
String partitionColName = partitionColumn.getTypeName(); // Note getTypeName gets the column name -- go figure.
int index = 0;
for (ColumnRef cref : CatalogUtil.getSortedCatalogItems(mvi.getGroupbycols(), "index")) {
Column srcCol = cref.getColumn();
if (srcCol.getName().equals(partitionColName)) {
Column destCol = destColumnArray.get(index);
destTable.setPartitioncolumn(destCol);
return;
}
++index;
}
}
示例11: FragIdAndText
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
@SuppressWarnings("deprecation")
FragIdAndText(String stmtName) {
Statement stmt = m_testProc.getStatements().getIgnoreCase(stmtName);
PlanFragment frag = null;
for (PlanFragment f : stmt.getFragments()) {
frag = f;
}
fragId = CatalogUtil.getUniqueIdForFragment(frag);
sqlText = stmt.getSqltext();
ActivePlanRepository.addFragmentForTest(
fragId,
Encoder.decodeBase64AndDecompressToBytes(frag.getPlannodetree()),
sqlText);
}
示例12: createSaveRestoreSchemaCatalog
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public Catalog createSaveRestoreSchemaCatalog() throws IOException
{
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
String catalogJar = testDir + File.separator + "saverestore-jni.jar";
addAllDefaults();
boolean status = compile(catalogJar);
assert(status);
// read in the catalog
byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
String serializedCatalog = CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(bytes).getFirst());
assert(serializedCatalog != null);
// create the catalog (that will be passed to the ClientInterface
Catalog catalog = new Catalog();
catalog.execute(serializedCatalog);
return catalog;
}
示例13: loadCatalog
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public static InMemoryJarfile loadCatalog(byte[] catalogBytes, boolean expectUpgrade)
throws IOException
{
InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(catalogBytes);
// Let VoltCompiler do a version check and upgrade the catalog on the fly.
// I.e. jarfile may be modified.
VoltCompiler compiler = new VoltCompiler();
String upgradeFromVersion = compiler.upgradeCatalogAsNeeded(jarfile);
if (expectUpgrade) {
TestCase.assertTrue(upgradeFromVersion!=null);
}
else {
TestCase.assertTrue(upgradeFromVersion==null);
}
return jarfile;
}
示例14: testMultiplePartitionStatements
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public void testMultiplePartitionStatements() throws Exception
{
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema =
"CREATE TABLE T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" +
"PARTITION TABLE T ON COLUMN C1;\n" +
"PARTITION TABLE T ON COLUMN C2;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler();
boolean success = compiler.compileFromDDL(jarOut.getPath(), schemaPath);
assertTrue("Compilation failed unexpectedly", success);
Catalog catalog = new Catalog();
catalog.execute(CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(MiscUtils.fileToBytes(new File(jarOut.getPath()))).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals("C2", t.getPartitioncolumn().getTypeName());
}
示例15: testDropPartitionedTable
import org.voltdb.utils.CatalogUtil; //导入依赖的package包/类
public void testDropPartitionedTable() throws Exception
{
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema =
"CREATE TABLE T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" +
"PARTITION TABLE T ON COLUMN C1;\n" +
"DROP TABLE T;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler();
boolean success = compiler.compileFromDDL(jarOut.getPath(), schemaPath);
assertTrue("Compilation failed unexpectedly", success);
Catalog catalog = new Catalog();
catalog.execute(CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(MiscUtils.fileToBytes(new File(jarOut.getPath()))).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals(null, t);
}