Package org.voltdb.compiler

Examples of org.voltdb.compiler.VoltProjectBuilder


    public void testDropTableWithIndexesAndProcedures() throws Exception {

        String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
        String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");

        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema(
            "create table BLAH (" +
            "ID int default 0 not null, " +
            "VAL varchar(32) default null," +
            "PRIMARY KEY(ID));\n" +
            "create table VIEWBASE (" +
            "ID int default 0 not null, " +
            "VAL varchar(32) default null," +
            "PRIMARY KEY(ID));\n" +
            "create table DROPME (" +
            "ID int default 0 not null, " +
            "VAL varchar(32) default null," +
            "PRIMARY KEY(ID));\n" +
            "create assumeunique index pkey_idx on DROPME(VAL);\n" +
            "create view BLAT (VAL, TOTAL) as select VAL, COUNT(*) from VIEWBASE group by VAL;\n"
            );
        builder.addPartitionInfo("BLAH", "ID");
        builder.addPartitionInfo("DROPME", "ID");
        builder.addStmtProcedure("BLERG", "select * from BLAH where ID = ?");
        builder.setUseDDLSchema(true);
        boolean success = builder.compile(pathToCatalog, 2, 1, 0);
        assertTrue("Schema compilation failed", success);
        MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);

        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = pathToCatalog;
        config.m_pathToDeployment = pathToDeployment;

View Full Code Here


import org.voltdb.utils.MiscUtils;


public class SimpleServer {
    public static void main(String[] args) throws NumberFormatException, Exception {
        VoltProjectBuilder builder = null;
        String[] arg;
        String schemaFileName = "DDL.sql"; // default
        ArrayList<String> host_manager_args = new ArrayList<String>();
        int hosts = 1;
        int sites = 1;
        int k_factor = 0;

        for (int i=0; i < args.length; ++i) {
            arg = args[i].split("=");
            if (arg[0].equals("schema")) {
                schemaFileName = arg[1];
            } else if (arg[0].equals("backend")) {
                host_manager_args.add(arg[1]);
            }
            else if (arg[0].equals("hosts"))
            {
                hosts = Integer.valueOf(arg[1]);
            }
            else if (arg[0].equals("sitesperhost"))
            {
                sites = Integer.valueOf(arg[1]);
            }
            else if (arg[0].equals("replicas"))
            {
                k_factor = Integer.valueOf(arg[1]);
            }
            else if (args[i] != null)
            {
                host_manager_args.add(args[i]);
            }
        }

        String[] hostargs = new String[host_manager_args.size()];

        VoltDB.Configuration config = new VoltDB.Configuration(host_manager_args.toArray(hostargs));

        if (config.m_backend != BackendTarget.NATIVE_EE_JNI)
        {
            sites = 1;
            hosts = 1;
            k_factor = 0;
        }

        builder = new VoltProjectBuilder();
        builder.addSchema(SimpleServer.class.getResource(schemaFileName));
        builder.setCompilerDebugPrintStream(System.out);

        if (!builder.compile(Configuration.getPathToCatalogForTest("simple.jar"), sites, hosts, k_factor)) {
            System.err.println("Compilation failed");
            System.exit(-1);
        }
        MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("simple.xml"));
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("simple.jar");
        System.out.println("catalog path: " + config.m_pathToCatalog);
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("simple.xml");
        System.out.println("deployment path: " + config.m_pathToDeployment);
        config.m_port = VoltDB.DEFAULT_PORT;
View Full Code Here

        VoltServerConfig config = null;
        MultiConfigSuiteBuilder builder =
            new MultiConfigSuiteBuilder(TestIndexOverflowSuite.class);

        VoltProjectBuilder project = new VoltProjectBuilder();
        project.addSchema(TestIndexOverflowSuite.class.getResource("indexoverflowsuite-ddl.sql"));
        project.addPartitionInfo("P1", "ID");
        project.addStmtProcedure("BasicEQParam",           "select * from P1 where ID = ?");
        project.addStmtProcedure("BasicGTParam",           "select * from P1 where ID > ?");
        project.addStmtProcedure("BasicLTParam",           "select * from P1 where ID < ?");

        project.addStmtProcedure("BasicUnderflowEQ",       "select * from P1 where ID = -6000000000");
        project.addStmtProcedure("BasicUnderflowGT",       "select * from P1 where ID > -6000000000");
        project.addStmtProcedure("BasicUnderflowLT",       "select * from P1 where ID < -6000000000");

        project.addStmtProcedure("BasicOverflowEQ",        "select * from P1 where ID = 6000000000");
        project.addStmtProcedure("BasicOverflowGT",        "select * from P1 where ID > 6000000000");
        project.addStmtProcedure("BasicOverflowLT",        "select * from P1 where ID < 6000000000");

        project.addStmtProcedure("TwoColUnderflowEQ",      "select * from P1 where ID = ? and TINY = -200");
        project.addStmtProcedure("TwoColUnderflowGT",      "select * from P1 where ID = ? and TINY > -200");
        project.addStmtProcedure("TwoColUnderflowLT",      "select * from P1 where ID = ? and TINY < -200");

        project.addStmtProcedure("TwoColOverflowEQ",       "select * from P1 where ID = ? and TINY = 200");
        project.addStmtProcedure("TwoColOverflowGT",       "select * from P1 where ID = ? and TINY > 200");
        project.addStmtProcedure("TwoColOverflowLT",       "select * from P1 where ID = ? and TINY < 200");

        project.addStmtProcedure("Join",                   "select * from P1, R1 where P1.ID = R1.TINY");
        project.addStmtProcedure("JoinReverse",            "select * from P1, R1 where P1.TINY = R1.ID");
        project.addStmtProcedure("JoinWithOrderOverflow""select * from P1, R1 where P1.ID = R1.ID and P1.TINY >= 200");
        project.addStmtProcedure("JoinWithOrderUnderflow", "select * from P1, R1 where P1.ID = R1.ID and P1.TINY >= -200");

        boolean success;

        // JNI
        config = new LocalCluster("testindexes-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
View Full Code Here

        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");

        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("cjk", "sval1");
        builder.addStmtProcedure("Insert", "insert into cjk values (?,?,?);");
        builder.addStmtProcedure("Select", "select * from cjk;");
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("cjk.jar"), 1, 1, 0);
        assertTrue(success);

        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("cjk.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        ServerThread server = new ServerThread(config);
        server.start();
        server.waitForInitialization();

        return server;
View Full Code Here

            "create table blah (" +
            "ival bigint default 0 not null, " +
            "sval varchar(255) not null, " +
            "PRIMARY KEY(ival));";

        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema(simpleSchema);
        builder.addPartitionInfo("blah", "ival");
        builder.addStmtProcedure("Insert", "insert into blah values (?, ?);", null);
        builder.addProcedures(CrushExpectations.class);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("expectations.jar"), 1, 1, 0);
        assert(success);
        MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("expectations.xml"));

        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("expectations.jar");
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("expectations.xml");
        ServerThread localServer = new ServerThread(config);
View Full Code Here

    }

    public void testDiffOfIdenticalCatalogs() throws IOException {
        String testDir = BuildDirectoryUtils.getBuildDirectoryPath();

        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
        builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " +
                                 "\n    SELECT C1, COUNT(*) FROM A GROUP BY C1;");
        builder.addPartitionInfo("A", "C1");
        builder.addProcedures(org.voltdb.catalog.ProcedureA.class);

        builder.compile(testDir + File.separator + "identical3.jar");
        Catalog c3 = catalogForJar(testDir + File.separator + "identical3.jar");
        builder = new VoltProjectBuilder();
        builder.addLiteralSchema("\nCREATE TABLE A (C1 BIGINT NOT NULL, C2 BIGINT NOT NULL);");
        builder.addLiteralSchema("\nCREATE VIEW MATVIEW(C1, NUM) AS " +
                                 "\n    SELECT C1, COUNT(*) FROM A GROUP BY C1;");
        builder.addPartitionInfo("A", "C1");
        builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
        builder.compile(testDir + File.separator + "identical4.jar");
        Catalog c4 = catalogForJar(testDir + File.separator + "identical4.jar");

        CatalogDiffEngine diff = new CatalogDiffEngine(c3, c4);
        // don't reach this point.
        c3.execute(diff.commands());
View Full Code Here

                             "A9 DECIMAL, PRIMARY KEY(A1));" +
            "CREATE UNIQUE INDEX UNIQUE_ORDERS_HASH ON ORDERS (A1, A2_ID); " +
            "CREATE INDEX IDX_ORDERS_HASH ON ORDERS (A2_ID);";


        pb = new VoltProjectBuilder();
        pb.addLiteralSchema(ddl);
        pb.addSchema(TestClientFeatures.class.getResource("clientfeatures.sql"));
        pb.addProcedures(ArbitraryDurationProc.class);
        pb.addPartitionInfo("TT", "A1");
        pb.addPartitionInfo("ORDERS", "A1");
View Full Code Here

    }

    // N.B. Some of the testcases assume this exact table structure... if you change it,
    // check the callers.
    Catalog getCatalogForTable(String tableName, String catname) throws IOException {
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema("CREATE TABLE " + tableName + " (C1 BIGINT 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();
        builder.compile(testDir + File.separator + "test-" + catname + ".jar");
        Catalog cat = catalogForJar(testDir + File.separator + "test-" + catname + ".jar");
        return cat;
    }
View Full Code Here


    // 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();
        builder.compile(testDir + File.separator + "test-" + catname + ".jar");
        Catalog cat = catalogForJar(testDir + File.separator + "test-" + catname + ".jar");
        return cat;
    }
View Full Code Here

    }


    public void testAddTable() throws IOException {
        // Start with table A.
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addLiteralSchema("CREATE TABLE A (C1 BIGINT NOT NULL, PRIMARY KEY(C1));");
        builder.addPartitionInfo("A", "C1");
        builder.addProcedures(org.voltdb.catalog.ProcedureA.class);
        String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
        builder.compile(testDir + File.separator + "testaddtable1.jar");
        Catalog catOriginal = catalogForJar(testDir + File.separator + "testaddtable1.jar");

        // Add table B and recompile
        builder.addLiteralSchema("CREATE TABLE B (C1 BIGINT NOT NULL, PRIMARY KEY(C1));");
        builder.addPartitionInfo("B", "C1");
        builder.addProcedures(org.voltdb.catalog.ProcedureB.class);
        builder.compile(testDir + File.separator + "testaddtable2.jar");
        Catalog catUpdated = catalogForJar(testDir + File.separator + "testaddtable2.jar");

        verifyDiff(catOriginal, catUpdated, false, null);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.compiler.VoltProjectBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.