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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations