Search in sources :

Example 6 with Catalog

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));
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 7 with Catalog

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;
}
Also used : Catalog(org.voltdb.catalog.Catalog)

Example 8 with 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());
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 9 with Catalog

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);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 10 with Catalog

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);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Aggregations

Catalog (org.voltdb.catalog.Catalog)44 File (java.io.File)21 Database (org.voltdb.catalog.Database)12 IOException (java.io.IOException)8 Table (org.voltdb.catalog.Table)7 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)6 CatalogContext (org.voltdb.CatalogContext)5 Procedure (org.voltdb.catalog.Procedure)5 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)5 DbSettings (org.voltdb.settings.DbSettings)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)4 Cluster (org.voltdb.catalog.Cluster)4 VoltCompiler (org.voltdb.compiler.VoltCompiler)4 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)4 FileInputStream (java.io.FileInputStream)3 HostMessenger (org.voltcore.messaging.HostMessenger)3 PlannerTool (org.voltdb.compiler.PlannerTool)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2