当前位置: 首页>>代码示例>>Java>>正文


Java VoltCompiler类代码示例

本文整理汇总了Java中org.voltdb.compiler.VoltCompiler的典型用法代码示例。如果您正苦于以下问题:Java VoltCompiler类的具体用法?Java VoltCompiler怎么用?Java VoltCompiler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VoltCompiler类属于org.voltdb.compiler包,在下文中一共展示了VoltCompiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compileSQL

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public static AbstractPlanNode compileSQL(final Procedure catalog_proc, String name, String sql) throws Exception {
    VoltCompiler compiler = new VoltCompiler();
    HSQLInterface hsql = HSQLInterface.loadHsqldb();

    Database catalog_db = (Database) catalog_proc.getParent();
    Catalog catalog = catalog_db.getCatalog();
    Statement catalog_stmt = catalog_proc.getStatements().add(name);

    StatementCompiler.compile(compiler, hsql, catalog, catalog_db, new DatabaseEstimates(), catalog_stmt, sql, true);

    // HACK: For now just return the PlanNodeList from the first fragment
    System.err.println("CATALOG_STMT: " + CatalogUtil.debug(catalog_stmt.getFragments()));
    assert (catalog_stmt.getFragments().get(0) != null);
    String serialized = catalog_stmt.getFragments().get(0).getPlannodetree();
    String jsonString = Encoder.hexDecodeToString(serialized);
    PlanNodeList list = null; // FIXME
                              // (PlanNodeList)PlanNodeTree.fromJSONObject(new
                              // JSONObject(jsonString), catalog_db);
    return (list.getRootPlanNode());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:21,代码来源:CompilerUtil.java

示例2: compileCatalog

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
/**
 * Generate a new catalog object for the given schema
 * 
 * @param schema_file
 * @return
 * @throws Exception
 */
public static Catalog compileCatalog(String schema_file) throws Exception {

    HSQLInterface hzsql = HSQLInterface.loadHsqldb();
    String xmlSchema = null;
    hzsql.runDDLFile(schema_file);
    xmlSchema = hzsql.getXMLFromCatalog(true);

    //
    // Setup fake database connection. Pass stuff to database to get catalog
    // objects
    //
    Catalog catalog = new Catalog();
    catalog.execute("add / clusters " + CatalogUtil.DEFAULT_CLUSTER_NAME);
    catalog.execute("add /clusters[" + CatalogUtil.DEFAULT_CLUSTER_NAME + "] databases " + CatalogUtil.DEFAULT_DATABASE_NAME);
    Database catalog_db = catalog.getClusters().get(CatalogUtil.DEFAULT_CLUSTER_NAME).getDatabases().get(CatalogUtil.DEFAULT_DATABASE_NAME);

    VoltCompiler compiler = new VoltCompiler();
    DDLCompiler ddl_compiler = new DDLCompiler(compiler, hzsql);
    ddl_compiler.fillCatalogFromXML(catalog, catalog_db, xmlSchema);
    return (catalog);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:CompilerUtil.java

示例3: PlannerTestAideDeCamp

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
/**
 * Loads the schema at ddlurl and setups a voltcompiler / hsql instance.
 * @param ddlurl URL to the schema/ddl file.
 * @param basename Unique string, JSON plans [basename]-stmt-#_json.txt on disk
 * @throws Exception
 */
public PlannerTestAideDeCamp(URL ddlurl, String basename) throws Exception {
    catalog = new Catalog();
    catalog.execute("add / clusters cluster");
    catalog.execute("add /clusters[cluster] databases database");
    db = catalog.getClusters().get("cluster").getDatabases().get("database");
    proc = db.getProcedures().add(basename);

    String schemaPath = URLDecoder.decode(ddlurl.getPath(), "UTF-8");

    VoltCompiler compiler = new VoltCompiler();
    hsql = HSQLInterface.loadHsqldb();
    //hsql.runDDLFile(schemaPath);
    DDLCompiler ddl_compiler = new DDLCompiler(compiler, hsql);
    ddl_compiler.loadSchema(schemaPath);
    ddl_compiler.compileToCatalog(catalog, db);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:23,代码来源:PlannerTestAideDeCamp.java

示例4: testJarfileRemoveClassRemovesInnerClasses

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public void testJarfileRemoveClassRemovesInnerClasses() throws Exception
{
    InMemoryJarfile dut = new InMemoryJarfile();
    // Add a class file that we know has inner classes
    // Someday this seems like it should be an operation directly on InMemoryJarfile
    VoltCompiler comp = new VoltCompiler();
    // This will pull in all the inner classes (currently 4 of them), but check anyway
    comp.addClassToJar(dut, org.voltdb_testprocs.updateclasses.InnerClassesTestProc.class);
    JarLoader loader = dut.getLoader();
    assertEquals(5, loader.getClassNames().size());
    System.out.println(loader.getClassNames());
    assertTrue(loader.getClassNames().contains("org.voltdb_testprocs.updateclasses.InnerClassesTestProc$InnerNotPublic"));
    assertTrue(dut.get("org/voltdb_testprocs/updateclasses/InnerClassesTestProc$InnerNotPublic.class") != null);

    // Now, remove the outer class and verify that all the inner classes go away.
    dut.removeClassFromJar("org.voltdb_testprocs.updateclasses.InnerClassesTestProc");
    assertTrue(loader.getClassNames().isEmpty());
    assertTrue(dut.get("org/voltdb_testprocs/updateclasses/InnerClassesTestProc$InnerNotPublic.class") == null);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:20,代码来源:TestInMemoryJarfile.java

示例5: testGetClasses

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public void testGetClasses() throws Exception
{
    String schema =
        "create table Table1 (Column1 varchar(200) not null, Column2 integer);" +
        "partition table Table1 on column Column1;" +
        "create procedure proc1 as select * from Table1 where Column1=?;" +
        "partition procedure proc1 on table Table1 column Column1;" +
        "create procedure proc2 as select * from Table1 where Column2=?;" +
        "import class org.voltdb_testprocs.fullddlfeatures.*;" +
        "create procedure from class org.voltdb_testprocs.fullddlfeatures.testImportProc;";

    VoltCompiler c = compileForDDLTest2(schema);
    JdbcDatabaseMetaDataGenerator dut =
        new JdbcDatabaseMetaDataGenerator(c.getCatalog(), null, new InMemoryJarfile(testout_jar));
    VoltTable classes = dut.getMetaData("classes");
    System.out.println(classes);
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(classes, "CLASS_NAME", "org.voltdb_testprocs.fullddlfeatures.testImportProc"));
    assertEquals(1, classes.get("VOLT_PROCEDURE", VoltType.INTEGER));
    assertEquals(1, classes.get("ACTIVE_PROC", VoltType.INTEGER));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(classes, "CLASS_NAME", "org.voltdb_testprocs.fullddlfeatures.testCreateProcFromClassProc"));
    assertEquals(1, classes.get("VOLT_PROCEDURE", VoltType.INTEGER));
    assertEquals(0, classes.get("ACTIVE_PROC", VoltType.INTEGER));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(classes, "CLASS_NAME", "org.voltdb_testprocs.fullddlfeatures.NoMeaningClass"));
    assertEquals(0, classes.get("VOLT_PROCEDURE", VoltType.INTEGER));
    assertEquals(0, classes.get("ACTIVE_PROC", VoltType.INTEGER));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:27,代码来源:TestJdbcDatabaseMetaDataGenerator.java

示例6: setUp

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp(ProjectType.TPCC);

    if (isFirstSetup()) {
        this.addPartitions(NUM_PARTITIONS);
        VoltCompiler.addVerticalPartition(catalog_db, VERTICAL_PARTITION_TABLE, VERTICAL_PARTITION_COLUMNS, true);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:10,代码来源:TestCatalogCloner.java

示例7: getCRC

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public long getCRC() throws IOException {

        PureJavaCrc32 crc = new PureJavaCrc32();

        for (Entry<String, byte[]> e : super.entrySet()) {
            if (e.getKey().equals("buildinfo.txt") || e.getKey().equals("catalog-report.html")) {
                continue;
            }
            // Hacky way to skip the first line of the autogenerated ddl, which
            // has a date which changes and causes test failures
            if (e.getKey().equals(VoltCompiler.AUTOGEN_DDL_FILE_NAME)) {
                byte[] ddlbytes = e.getValue();
                int index = 0;
                while (ddlbytes[index] != '\n') {
                    index++;
                }
                byte[] newddlbytes = Arrays.copyOfRange(ddlbytes, index, ddlbytes.length);
                crc.update(e.getKey().getBytes("UTF-8"));
                crc.update(newddlbytes);
            }
            else {
                crc.update(e.getKey().getBytes("UTF-8"));
                crc.update(e.getValue());
            }
        }

        return crc.getValue();
    }
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:29,代码来源:InMemoryJarfile.java

示例8: loadAndUpgradeCatalogFromJar

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
/**
 * Load a catalog from the jar bytes.
 *
 * @param catalogBytes
 * @return Pair containing updated InMemoryJarFile and upgraded version (or null if it wasn't upgraded)
 * @throws IOException
 *             If the catalog cannot be loaded because it's incompatible, or
 *             if there is no version information in the catalog.
 */
public static Pair<InMemoryJarfile, String> loadAndUpgradeCatalogFromJar(byte[] catalogBytes)
    throws IOException
{
    // Throws IOException on load failure.
    InMemoryJarfile jarfile = loadInMemoryJarFile(catalogBytes);
    // Let VoltCompiler do a version check and upgrade the catalog on the fly.
    // I.e. jarfile may be modified.
    VoltCompiler compiler = new VoltCompiler();
    String upgradedFromVersion = compiler.upgradeCatalogAsNeeded(jarfile);
    return new Pair<InMemoryJarfile, String>(jarfile, upgradedFromVersion);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:21,代码来源:CatalogUtil.java

示例9: createTemporaryEmptyCatalogJarFile

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
/**
 * Build an empty catalog jar file.
 * @return jar file or null (on failure)
 * @throws IOException on failure to create temporary jar file
 */
public static File createTemporaryEmptyCatalogJarFile() throws IOException {
    File emptyJarFile = File.createTempFile("catalog-empty", ".jar");
    emptyJarFile.deleteOnExit();
    VoltCompiler compiler = new VoltCompiler();
    if (!compiler.compileEmptyCatalog(emptyJarFile.getAbsolutePath())) {
        return null;
    }
    return emptyJarFile;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:15,代码来源:CatalogUtil.java

示例10: compileAndGenerateCatalogReport

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
private static String compileAndGenerateCatalogReport(String ddl) throws IOException {
    // Let's try not to "drool" files into the current directory.
    // Generate random temporary names for the .jar and DDL files,
    // and delete them before we exit this method.  We will still
    // drool the catalog-report.html file, though (many tests seem
    // to do this).
    UUID uuid = UUID.randomUUID();
    String jarName = uuid + ".jar";
    String ddlName = uuid + ".sql";
    String report = null;
    PrintWriter ddlWriter = null;
    try {
        ddlWriter = new PrintWriter(ddlName);
        ddlWriter.println(ddl);
        ddlWriter.close();
        VoltCompiler vc = new VoltCompiler(true); // trick it into behaving like standalone
        boolean success = vc.compileFromDDL(jarName, ddlName);
        assertTrue("Catalog compilation failed!", success);
        report = new String(Files.readAllBytes(Paths.get("catalog-report.html")), Charsets.UTF_8);
    }
    catch (Exception e) {
    }
    finally {
        if (ddlWriter != null)
            ddlWriter.close();
        Path ddlPath = Paths.get(ddlName);
        if (ddlPath.toFile().exists()) {
            Files.delete(ddlPath);
        }

        Path jarPath = Paths.get(jarName);
        if (jarPath.toFile().exists()) {
            Files.delete(jarPath);
        }
    }

    return report;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:39,代码来源:TestReportMaker.java

示例11: createTestJarFile

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
private Catalog createTestJarFile(String jarFileName, boolean adhoc, String elemPfx)
{
    String schemaPath = "";
    try {
        URL url = TPCCProjectBuilder.class.getResource("tpcc-ddl.sql");
        schemaPath = URLDecoder.decode(url.getPath(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    String simpleProjectTmpl =
        "<?xml version=\"1.0\"?>\n" +
        "<project>" +
        "<database name='database'>" +
        "<%ss>" +
        "<%s adhoc='" + Boolean.toString(adhoc) + "' name='default' sysproc='false'/>" +
        "</%ss>" +
        "<schemas><schema path='" + schemaPath + "' /></schemas>" +
        "<procedures><procedure class='org.voltdb.compiler.procedures.TPCCTestProc' /></procedures>" +
        "<partitions><partition table='WAREHOUSE' column='W_ID' /></partitions>" +
        "</database>" +
        "</project>";
    String simpleProject = String.format(simpleProjectTmpl, elemPfx, elemPfx, elemPfx);
    System.out.println(simpleProject);
    File projectFile = VoltProjectBuilder.writeStringToTempFile(simpleProject);
    String projectPath = projectFile.getPath();
    VoltCompiler compiler = new VoltCompiler();
    assertTrue(compiler.compileWithProjectXML(projectPath, jarFileName));
    return compiler.getCatalog();
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:31,代码来源:TestInMemoryJarfile.java

示例12: PlannerTestAideDeCamp

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
/**
 * Loads the schema at ddlurl and setups a voltcompiler / hsql instance.
 * @param ddlurl URL to the schema/ddl file.
 * @param basename Unique string, JSON plans [basename]-stmt-#_json.txt on disk
 * @throws Exception
 */
public PlannerTestAideDeCamp(URL ddlurl, String basename) throws Exception {
    String schemaPath = URLDecoder.decode(ddlurl.getPath(), "UTF-8");
    VoltCompiler compiler = new VoltCompiler();
    hsql = HSQLInterface.loadHsqldb();
    VoltCompiler.DdlProceduresToLoad no_procs = DdlProceduresToLoad.NO_DDL_PROCEDURES;
    catalog = compiler.loadSchema(hsql, no_procs, schemaPath);
    db = compiler.getCatalogDatabase();
    proc = db.getProcedures().add(basename);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:16,代码来源:PlannerTestAideDeCamp.java

示例13: compileForDDLTest2

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
private VoltCompiler compileForDDLTest2(String ddl) throws Exception {
    String ddlPath = getPathForSchema(ddl);
    final VoltCompiler compiler = new VoltCompiler();
    boolean success = compiler.compileFromDDL(testout_jar, ddlPath);
    assertTrue("Catalog compile failed!", success);
    return compiler;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:8,代码来源:TestJdbcDatabaseMetaDataGenerator.java

示例14: testGetTables

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public void testGetTables() throws Exception
{
    String schema =
        "create table Table1 (Column1 varchar(10) not null, Column2 integer);" +
        "partition table Table1 on column Column1;" +
        "create table Table2 (Column1 integer);" +
        "create view View1 (Column1, num) as select Column1, count(*) from Table1 group by Column1;" +
        "create view View2 (Column2, num) as select Column2, count(*) from Table1 group by Column2;" +
        "create table Export1 (Column1 integer);" +
        "export table Export1;" +
        "create table Export2 (Column1 integer);" +
        "export table Export2 to stream foo;" +
        "create procedure sample as select * from Table1;";
    VoltCompiler c = compileForDDLTest2(schema);
    System.out.println(c.getCatalog().serialize());
    JdbcDatabaseMetaDataGenerator dut =
        new JdbcDatabaseMetaDataGenerator(c.getCatalog(), null, new InMemoryJarfile(testout_jar));
    VoltTable tables = dut.getMetaData("tables");
    System.out.println(tables);
    assertEquals(10, tables.getColumnCount());
    assertEquals(6, tables.getRowCount());
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "Table1"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("TABLE"));
    assertTrue(tables.get("REMARKS", VoltType.STRING).equals("{\"partitionColumn\":\"COLUMN1\"}"));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "Table2"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("TABLE"));
    assertEquals(null, tables.get("REMARKS", VoltType.STRING));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "View1"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("VIEW"));
    assertTrue(tables.get("REMARKS", VoltType.STRING).equals("{\"partitionColumn\":\"COLUMN1\",\"sourceTable\":\"TABLE1\"}"));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "View2"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("VIEW"));
    assertTrue(tables.get("REMARKS", VoltType.STRING).equals("{\"partitionColumn\":\"COLUMN1\",\"sourceTable\":\"TABLE1\"}"));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "Export1"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("EXPORT"));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "Export2"));
    assertTrue(tables.get("TABLE_TYPE", VoltType.STRING).equals("EXPORT"));
    assertFalse(VoltTableTestHelpers.moveToMatchingRow(tables, "TABLE_NAME", "NotATable"));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:40,代码来源:TestJdbcDatabaseMetaDataGenerator.java

示例15: testGetPrimaryKeys

import org.voltdb.compiler.VoltCompiler; //导入依赖的package包/类
public void testGetPrimaryKeys() throws Exception
{
    String schema =
        "create table Table1 (Column1 smallint not null, constraint primary1 primary key (Column1));" +
        "partition table Table1 on column Column1;" +
        "create table Table2 (Column2 smallint not null, Column3 smallint not null, Column4 smallint not null, " +
        "  constraint primary2 primary key (Column2, Column3, Column4));" +
        "create procedure sample as select * from Table1;";

    VoltCompiler c = compileForDDLTest2(schema);
    System.out.println(c.getCatalog().serialize());
    JdbcDatabaseMetaDataGenerator dut =
        new JdbcDatabaseMetaDataGenerator(c.getCatalog(), null, new InMemoryJarfile(testout_jar));
    VoltTable pkeys = dut.getMetaData("PrimaryKeys");
    System.out.println(pkeys);
    assertEquals(6, pkeys.getColumnCount());
    assertEquals(4, pkeys.getRowCount());
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(pkeys, "COLUMN_NAME", "Column1"));
    assertEquals("TABLE1", pkeys.get("TABLE_NAME", VoltType.STRING));
    assertEquals((short)1, pkeys.get("KEY_SEQ", VoltType.SMALLINT));
    assertEquals("PRIMARY1", pkeys.get("PK_NAME", VoltType.STRING));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(pkeys, "COLUMN_NAME", "Column2"));
    assertEquals("TABLE2", pkeys.get("TABLE_NAME", VoltType.STRING));
    assertEquals((short)1, pkeys.get("KEY_SEQ", VoltType.SMALLINT));
    assertEquals("PRIMARY2", pkeys.get("PK_NAME", VoltType.STRING));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(pkeys, "COLUMN_NAME", "Column3"));
    assertEquals("TABLE2", pkeys.get("TABLE_NAME", VoltType.STRING));
    assertEquals((short)2, pkeys.get("KEY_SEQ", VoltType.SMALLINT));
    assertEquals("PRIMARY2", pkeys.get("PK_NAME", VoltType.STRING));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(pkeys, "COLUMN_NAME", "Column4"));
    assertEquals("TABLE2", pkeys.get("TABLE_NAME", VoltType.STRING));
    assertEquals((short)3, pkeys.get("KEY_SEQ", VoltType.SMALLINT));
    assertEquals("PRIMARY2", pkeys.get("PK_NAME", VoltType.STRING));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:35,代码来源:TestJdbcDatabaseMetaDataGenerator.java


注:本文中的org.voltdb.compiler.VoltCompiler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。