Search in sources :

Example 61 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testChangeCompatibleWithElasticNoChange.

public void testChangeCompatibleWithElasticNoChange() throws IOException {
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
    builder.addStmtProcedure("the_requisite_procedure", "select * from A;");
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "elastic1.jar"));
    Catalog catOriginal = catalogForJar(testDir + File.separator + "elastic1.jar");
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "elastic2.jar"));
    Catalog catUpdated = catalogForJar(testDir + File.separator + "elastic2.jar");
    verifyDiff(catOriginal, catUpdated, null, true, false, false, true);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 62 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testShrinkUniqueNonCoveringTableIndexRejectedIfNonEmpty.

public void testShrinkUniqueNonCoveringTableIndexRejectedIfNonEmpty() throws IOException {
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    // start with a table
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1, C2));");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected1.jar"));
    Catalog catOriginal = catalogForJar(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected1.jar");
    // shrink the pkey index
    builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1));");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected2.jar"));
    Catalog catUpdated = catalogForJar(testDir + File.separator + "testAddUniqueNonCoveringTableIndexRejected2.jar");
    verifyDiffIfEmptyTable(catOriginal, catUpdated);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 63 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method testAddNonUniqueTableIndex.

public void testAddNonUniqueTableIndex() throws IOException {
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    // start with a table
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL, PRIMARY KEY(C1));");
    builder.addPartitionInfo("A", "C1");
    builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddNonUniqueTableIndex1.jar"));
    Catalog catOriginal = catalogForJar(testDir + File.separator + "testAddNonUniqueTableIndex1.jar");
    // add an index
    builder.addLiteralSchema("\nCREATE INDEX IDX ON A(C1,C2);");
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "testAddNonUniqueTableIndex2.jar"));
    Catalog catUpdated = catalogForJar(testDir + File.separator + "testAddNonUniqueTableIndex2.jar");
    verifyDiff(catOriginal, catUpdated);
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 64 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class TestCatalogDiffs method get2ColumnCatalogForTable.

// N.B. Some of the testcases assume this exact table structure .. if you change it,
// check the callers...
Catalog get2ColumnCatalogForTable(String tableName, String catname) throws IOException {
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema("CREATE TABLE " + tableName + " (C1 BIGINT NOT NULL, C2 BIGINT DEFAULT 0 NOT NULL, PRIMARY KEY(C1));");
    builder.addPartitionInfo(tableName, "C1");
    if (tableName.equals("A"))
        builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
    else
        builder.addProcedures(org.voltdb.catalog.ProcedureB.class);
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    assertTrue("Failed to compile schema", builder.compile(testDir + File.separator + "test-" + catname + ".jar"));
    Catalog cat = catalogForJar(testDir + File.separator + "test-" + catname + ".jar");
    return cat;
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder)

Example 65 with VoltProjectBuilder

use of org.voltdb.compiler.VoltProjectBuilder in project voltdb by VoltDB.

the class Runner method main.

public static void main(String[] args) throws Exception {
    // compile the catalog
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addLiteralSchema("create table items (id bigint not null, created bigint not null, primary key (id));");
    project.addLiteralSchema("create index idx_item_tree on items (created, id);");
    project.addStmtProcedure("CreateItem", "insert into items (id, created) values (?,?);", "items.id:0");
    project.addStmtProcedure("GetItems", "select id, created from items " + "where created <= ? and id < ? " + "order by created desc, id desc " + "limit ?;", "items.id:1");
    project.addPartitionInfo("items", "id");
    boolean success = project.compile(Configuration.getPathToCatalogForTest("poc.jar"));
    if (!success) {
        System.err.println("Failure to compile catalog.");
        System.exit(-1);
    }
    String pathToDeployment = project.getPathToDeployment();
    // start up voltdb
    ServerThread server = new ServerThread(Configuration.getPathToCatalogForTest("poc.jar"), pathToDeployment, BackendTarget.NATIVE_EE_JNI);
    server.start();
    server.waitForInitialization();
    final org.voltdb.client.Client voltclient = ClientFactory.createClient();
    voltclient.createConnection("localhost");
    // create initial items
    voltclient.callProcedure("CreateItem", 0, 10);
    voltclient.callProcedure("CreateItem", 1, 11);
    voltclient.callProcedure("CreateItem", 2, 12);
    // check that the query does the right thing
    VoltTable result = voltclient.callProcedure("GetItems", 11, 1, 1).getResults()[0];
    System.out.println(result.toJSONString());
    if (result.getRowCount() != 1) {
        System.err.printf("Call failed with %d rows\n", result.getRowCount());
    }
    // clean up / shutdown
    voltclient.close();
    server.shutdown();
    server.join();
}
Also used : VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) VoltTable(org.voltdb.VoltTable)

Aggregations

VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)269 Configuration (org.voltdb.VoltDB.Configuration)89 IOException (java.io.IOException)49 Test (org.junit.Test)45 File (java.io.File)40 ProcCallException (org.voltdb.client.ProcCallException)38 ClientResponse (org.voltdb.client.ClientResponse)37 VoltDB (org.voltdb.VoltDB)22 LocalCluster (org.voltdb.regressionsuites.LocalCluster)18 Client (org.voltdb.client.Client)17 Before (org.junit.Before)14 HashMap (java.util.HashMap)13 VoltTable (org.voltdb.VoltTable)13 ServerThread (org.voltdb.ServerThread)12 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)12 VoltCompiler (org.voltdb.compiler.VoltCompiler)11 HttpResponse (org.apache.http.HttpResponse)10 BeforeClass (org.junit.BeforeClass)8 ClientConfig (org.voltdb.client.ClientConfig)7 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)7