本文整理汇总了Java中org.voltdb.catalog.Catalog类的典型用法代码示例。如果您正苦于以下问题:Java Catalog类的具体用法?Java Catalog怎么用?Java Catalog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Catalog类属于org.voltdb.catalog包,在下文中一共展示了Catalog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
static void compile(VoltCompiler compiler, HSQLInterface hsql, DatabaseEstimates estimates, Catalog catalog, Database db, ProcedureDescriptor procedureDescriptor)
throws VoltCompiler.VoltCompilerException {
assert (compiler != null);
assert (hsql != null);
assert (estimates != null);
if (procedureDescriptor.m_singleStmt == null) {
final String className = procedureDescriptor.m_className;
Class<?> procClass = null;
try {
procClass = Class.forName(className);
} catch (ClassNotFoundException e) {
String msg = "Cannot load class for procedure: " + className;
throw compiler.new VoltCompilerException(msg);
}
if (ClassUtil.getSuperClasses(procClass).contains(VoltTrigger.class)) {
compileTriggerProcedure(procClass, compiler, hsql, estimates, catalog, db, procedureDescriptor);
} else
compileJavaProcedure(compiler, hsql, estimates, catalog, db, procedureDescriptor);
} else
compileSingleStmtProcedure(compiler, hsql, estimates, catalog, db, procedureDescriptor);
}
示例2: testGetStats
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public void testGetStats() throws Exception {
final Catalog catalog = new Catalog();
catalog.execute(LoadCatalogToString.THE_CATALOG);
sourceEngine.loadCatalog(catalog.serialize());
final int WAREHOUSE_TABLEID = catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("WAREHOUSE").getRelativeIndex();
final int STOCK_TABLEID = catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("STOCK").getRelativeIndex();
final int locators[] = new int[] { WAREHOUSE_TABLEID, STOCK_TABLEID };
final VoltTable results[] = sourceEngine.getStats(SysProcSelector.TABLE, locators, false, 0L);
assertNotNull(results);
assertEquals(1, results.length);
assertNotNull(results[0]);
final VoltTable resultTable = results[0];
assertEquals(2, resultTable.getRowCount());
while (resultTable.advanceRow()) {
String tn = resultTable.getString("TABLE_NAME");
assertTrue(tn.equals("WAREHOUSE") || tn.equals("STOCK"));
}
}
示例3: cloneConstraints
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
/**
* @param src_db
* @param dest_db
*/
public static void cloneConstraints(Database src_db, Database dest_db) {
Catalog dest_catalog = dest_db.getCatalog();
for (Table src_tbl : src_db.getTables()) {
Table dest_tbl = dest_db.getTables().get(src_tbl.getName());
if (dest_tbl != null) {
for (Constraint src_cons : src_tbl.getConstraints()) {
// Only clone FKEY constraint if the other table is in the catalog
ConstraintType cons_type = ConstraintType.get(src_cons.getType());
if (cons_type != ConstraintType.FOREIGN_KEY || (cons_type == ConstraintType.FOREIGN_KEY && dest_db.getTables().get(src_cons.getForeignkeytable().getName()) != null)) {
Constraint dest_cons = clone(src_cons, dest_catalog);
assert (dest_cons != null);
}
} // FOR
}
} // FOR
}
示例4: createTPCCSchemaCatalog
import org.voltdb.catalog.Catalog; //导入依赖的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;
}
示例5: compileSQL
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public static AbstractPlanNode compileSQL(final Procedure catalog_proc, String name, String sql) throws Exception {
VoltCompiler compiler = new VoltCompiler();
HSQLInterface hsql = HSQLInterface.loadHsqldb();
Database catalog_db = (Database) catalog_proc.getParent();
Catalog catalog = catalog_db.getCatalog();
Statement catalog_stmt = catalog_proc.getStatements().add(name);
StatementCompiler.compile(compiler, hsql, catalog, catalog_db, new DatabaseEstimates(), catalog_stmt, sql, true);
// HACK: For now just return the PlanNodeList from the first fragment
System.err.println("CATALOG_STMT: " + CatalogUtil.debug(catalog_stmt.getFragments()));
assert (catalog_stmt.getFragments().get(0) != null);
String serialized = catalog_stmt.getFragments().get(0).getPlannodetree();
String jsonString = Encoder.hexDecodeToString(serialized);
PlanNodeList list = null; // FIXME
// (PlanNodeList)PlanNodeTree.fromJSONObject(new
// JSONObject(jsonString), catalog_db);
return (list.getRootPlanNode());
}
示例6: compileCatalog
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
/**
* Generate a new catalog object for the given schema
*
* @param schema_file
* @return
* @throws Exception
*/
public static Catalog compileCatalog(String schema_file) throws Exception {
HSQLInterface hzsql = HSQLInterface.loadHsqldb();
String xmlSchema = null;
hzsql.runDDLFile(schema_file);
xmlSchema = hzsql.getXMLFromCatalog(true);
//
// Setup fake database connection. Pass stuff to database to get catalog
// objects
//
Catalog catalog = new Catalog();
catalog.execute("add / clusters " + CatalogUtil.DEFAULT_CLUSTER_NAME);
catalog.execute("add /clusters[" + CatalogUtil.DEFAULT_CLUSTER_NAME + "] databases " + CatalogUtil.DEFAULT_DATABASE_NAME);
Database catalog_db = catalog.getClusters().get(CatalogUtil.DEFAULT_CLUSTER_NAME).getDatabases().get(CatalogUtil.DEFAULT_DATABASE_NAME);
VoltCompiler compiler = new VoltCompiler();
DDLCompiler ddl_compiler = new DDLCompiler(compiler, hzsql);
ddl_compiler.fillCatalogFromXML(catalog, catalog_db, xmlSchema);
return (catalog);
}
示例7: CatalogTreeModel
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public CatalogTreeModel(ArgumentsParser args, Catalog catalog, String catalog_path) {
super(new DefaultMutableTreeNode(catalog.getName() + " [" + catalog_path + "]"));
this.catalog = catalog;
// Procedures to exclude in Conflict Graph
if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES)) {
String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES);
Database catalog_db = CatalogUtil.getDatabase(this.catalog);
for (String procName : param.split(",")) {
Procedure catalog_proc = catalog_db.getProcedures().getIgnoreCase(procName);
if (catalog_proc != null) {
this.conflictGraphExcludes.add(catalog_proc);
} else {
LOG.warn("Invalid procedure name to exclude '" + procName + "'");
}
} // FOR
LOG.debug("Excluded ConflictGraph Procedures: " + this.conflictGraphExcludes);
}
this.buildModel();
}
示例8: testSufficientHostsToReplicate
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public void testSufficientHostsToReplicate()
{
// 2 hosts, 6 sites per host, 2 copies of each partition.
// there are sufficient execution sites, but insufficient hosts
ClusterConfig config = new ClusterConfig(2, 6, 2, "localhost");
Catalog catalog = new Catalog();
catalog.execute("add / clusters cluster");
boolean caught = false;
try
{
ClusterCompiler.compile(catalog, config);
}
catch (RuntimeException e)
{
if (e.getMessage().contains("Insufficient hosts"))
{
caught = true;
}
}
assertTrue(caught);
}
示例9: compileXMLRootNode
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
void compileXMLRootNode(ProjectType project) throws VoltCompilerException {
m_catalog = new Catalog();
temporaryCatalogInit();
SecurityType security = project.getSecurity();
if (security != null) {
m_catalog.getClusters().get("cluster").
setSecurityenabled(security.isEnabled());
}
DatabaseType database = project.getDatabase();
if (database != null) {
compileDatabaseNode(database);
}
}
示例10: compileToCatalog
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public void compileToCatalog(Catalog catalog, Database db) throws VoltCompilerException {
String hexDDL = Encoder.hexEncode(m_fullDDL);
catalog.execute("set " + db.getPath() + " schema \"" + hexDDL + "\"");
String xmlCatalog;
try {
xmlCatalog = m_hsql.getXMLFromCatalog();
} catch (HSQLParseException e) {
String msg = "DDL Error: " + e.getMessage();
throw m_compiler.new VoltCompilerException(msg);
}
// output the xml catalog to disk
PrintStream ddlXmlOutput = BuildDirectoryUtils.getDebugOutputPrintStream("schema-xml", "hsql-catalog-output.xml");
ddlXmlOutput.println(xmlCatalog);
ddlXmlOutput.close();
// build the local catalog from the xml catalog
fillCatalogFromXML(catalog, db, xmlCatalog);
}
示例11: testNonZeroReplicationFactor
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public void testNonZeroReplicationFactor()
{
ClusterConfig config = new ClusterConfig(3, 1, 2, "localhost");
Catalog catalog = new Catalog();
catalog.execute("add / clusters cluster");
ClusterCompiler.compile(catalog, config);
System.out.println(catalog.serialize());
Cluster cluster = catalog.getClusters().get("cluster");
Collection<Partition> partitions = CatalogUtil.getAllPartitions(cluster);
// despite 3 hosts, should only have 1 partition with k-safety of 2
// assertEquals(1, partitions.size());
// // All the execution sites should have the same relative index
// int part_guid = CatalogUtil.getPartitionById(cluster, 0).getRelativeIndex();
// for (Site site : cluster.getSites())
// {
//// if (site.getIsexec())
//// {
//// assertEquals(part_guid, site.getPartition().getRelativeIndex());
//// }
// }
}
示例12: addTriggerToCatalog
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
/**
* Add a trigger to the catalog
*
* @param compiler
* @param hsql
* @param parent
* @param triggers
* @param catalog
* @param db
* @param node
* @throws VoltCompilerException
*/
static void addTriggerToCatalog(VoltCompiler compiler, HSQLInterface hsql, Table parent, CatalogMap<Trigger> triggers, Catalog catalog, Database db, String[] stmt, StmtInfo[] stmtInfoArr,
int trigId) throws VoltCompilerException {
int type = 0; // insert
boolean forEach = false;
Trigger trigger = triggers.add("trig" + trigId);
trigger.setId(trigId);
trigger.setForeach(forEach);
trigger.setSourcetable(parent);
trigger.setTriggertype(type);
for (int i = 0; i < stmt.length; i++) {
Statement s = trigger.getStatements().add("trig" + trigId + "stmt" + i);
StmtInfo stmtInfo = (StmtInfo) stmtInfoArr[i];
if (stmtInfo != null)
s.setUpsertable(stmtInfo.upsertable());
else
s.setUpsertable(false);
StatementCompiler.compile(compiler, hsql, catalog, db, new DatabaseEstimates(), s, stmt[i], true);
}
}
示例13: testCreateSchemaCatalog
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
/**
* testCreateSchemaCatalog
*/
public void testCreateSchemaCatalog() throws Exception {
Catalog s_catalog = new TPCEProjectBuilder().getSchemaCatalog(false);
assertNotNull(s_catalog);
Database s_catalog_db = CatalogUtil.getDatabase(s_catalog);
assertNotNull(catalog_db);
// ADDRESS should point to ZIP_CODE
Table address = s_catalog_db.getTables().get(TPCEConstants.TABLENAME_ADDRESS);
assertNotNull(address);
Table zipcode = s_catalog_db.getTables().get(TPCEConstants.TABLENAME_ZIP_CODE);
assertNotNull(zipcode);
for (Constraint catalog_const : address.getConstraints()) {
if (catalog_const.getType() == ConstraintType.FOREIGN_KEY.getValue()) {
assertEquals(zipcode, catalog_const.getForeignkeytable());
assertEquals(1, catalog_const.getForeignkeycols().size());
break;
}
} // FOR
}
示例14: initializeCatalog
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
/**
* Update the catalog to include new hosts/sites/partitions
* @param num_hosts
* @param num_sites
* @param num_partitions
* @throws Exception
*/
protected final void initializeCatalog(int num_hosts, int num_sites, int num_partitions) throws Exception {
// HACK! If we already have this many partitions in the catalog, then we won't recreate it
// This fixes problems where we need to reference the same catalog objects in multiple test cases
if (catalogContext.numberOfHosts != num_hosts ||
catalogContext.numberOfSites != (num_hosts * num_sites) ||
catalogContext.numberOfPartitions != (num_hosts * num_sites * num_partitions)) {
// HACK
String hostFormat = (num_hosts == 1 ? "localhost" : "host%02d");
Catalog c = FixCatalog.cloneCatalog(catalog, hostFormat, num_hosts, num_sites, num_partitions);
CatalogContext cc = new CatalogContext(c, catalogContext.jarPath);
this.init(this.last_type, cc);
}
Cluster cluster = catalogContext.cluster;
assertEquals(num_hosts, catalogContext.numberOfHosts);
assertEquals((num_hosts * num_sites), catalogContext.numberOfSites);
assertEquals((num_hosts * num_sites * num_partitions), catalogContext.numberOfPartitions);
assertEquals((num_hosts * num_sites * num_partitions), cluster.getNum_partitions());
}
示例15: ConflictSetCalculator
import org.voltdb.catalog.Catalog; //导入依赖的package包/类
public ConflictSetCalculator(Catalog catalog) {
this.catalog_db = CatalogUtil.getDatabase(catalog);
for (Table catalog_tbl : CatalogUtil.getDataTables(catalog_db)) {
this.pkeysCache.put(catalog_tbl, CatalogUtil.getPrimaryKeyColumns(catalog_tbl));
} // FOR (table)
for (Procedure catalog_proc : catalog_db.getProcedures()) {
if (catalog_proc.getMapreduce() || catalog_proc.getSystemproc()) continue;
if (this.ignoredProcedures.contains(catalog_proc)) continue;
ProcedureInfo pInfo = new ProcedureInfo(catalog_proc);
for (Statement catalog_stmt : catalog_proc.getStatements()) {
if (this.ignoredStatements.contains(catalog_stmt)) continue;
QueryType qtype = QueryType.get(catalog_stmt.getQuerytype());
if (qtype == QueryType.SELECT) {
pInfo.readQueries.add(catalog_stmt);
} else {
pInfo.writeQueries.add(catalog_stmt);
}
} // FOR (statement)
this.procedures.put(catalog_proc, pInfo);
} // FOR (procedure)
}