use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestCatalogUtil method verifyDrTableSignature.
private void verifyDrTableSignature(boolean shouldEqual, String schemaA, String schemaB) throws IOException {
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
final File fileA = VoltFile.createTempFile("catA", ".jar", new File(testDir));
final File fileB = VoltFile.createTempFile("catB", ".jar", new File(testDir));
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(schemaA);
builder.compile(fileA.getPath());
Catalog catA = TestCatalogDiffs.catalogForJar(fileA.getPath());
builder = new VoltProjectBuilder();
builder.addLiteralSchema(schemaB);
builder.compile(fileB.getPath());
Catalog catB = TestCatalogDiffs.catalogForJar(fileB.getPath());
fileA.delete();
fileB.delete();
final Pair<Long, String> sigA = CatalogUtil.calculateDrTableSignatureAndCrc(catA.getClusters().get("cluster").getDatabases().get("database"));
final Pair<Long, String> sigB = CatalogUtil.calculateDrTableSignatureAndCrc(catB.getClusters().get("cluster").getDatabases().get("database"));
assertFalse(sigA.getFirst() == 0);
assertFalse(sigA.getSecond().isEmpty());
assertEquals(shouldEqual, sigA.equals(sigB));
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TPCCProjectBuilder method createTPCCSchemaCatalog.
/**
* Get a pointer to a compiled catalog for TPCC with all the procedures.
*/
public Catalog createTPCCSchemaCatalog() throws IOException {
// compile a catalog
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
String catalogJar = testDir + File.separator + "tpcc-jni.jar";
addDefaultSchema();
addDefaultPartitioning();
addDefaultProcedures();
Catalog catalog = compile(catalogJar, 1, 1, 0, null);
assert (catalog != null);
return catalog;
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testMultiplePartitionStatements.
// Test that multiple partition statements are accepted and that
// the final result is the final requested partitioning
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(false);
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())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals("C2", t.getPartitioncolumn().getTypeName());
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testDropExportTable.
public void testDropExportTable() throws Exception {
File jarOut = new File("partitionfun.jar");
jarOut.deleteOnExit();
String schema = "CREATE STREAM T (C1 INTEGER NOT NULL, C2 INTEGER NOT NULL, C3 INTEGER NOT NULL);\n" + "DROP STREAM T;\n";
File schemaFile = VoltProjectBuilder.writeStringToTempFile(schema);
String schemaPath = schemaFile.getPath();
VoltCompiler compiler = new VoltCompiler(false);
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())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals(null, t);
}
use of org.voltdb.catalog.Catalog in project voltdb by VoltDB.
the class TestLiveDDLCompiler method testDropPartitionedTable.
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(false);
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())), false).getFirst()));
Database db = catalog.getClusters().get("cluster").getDatabases().get("database");
Table t = db.getTables().get("T");
assertEquals(null, t);
}
Aggregations