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


Java Catalog.execute方法代码示例

本文整理汇总了Java中org.voltdb.catalog.Catalog.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Catalog.execute方法的具体用法?Java Catalog.execute怎么用?Java Catalog.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.voltdb.catalog.Catalog的用法示例。


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

示例1: compileCatalog

import org.voltdb.catalog.Catalog; //导入方法依赖的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

示例2: PlannerTestAideDeCamp

import org.voltdb.catalog.Catalog; //导入方法依赖的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,项目名称:s-store,代码行数:23,代码来源:PlannerTestAideDeCamp.java

示例3: compileToCatalog

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void compileToCatalog(Catalog catalog, Database db) throws VoltCompilerException {
    String hexDDL = Encoder.hexEncode(m_fullDDL);
    catalog.execute("set " + db.getPath() + " schema \"" + hexDDL + "\"");

    String xmlCatalog;
    try {
        xmlCatalog = m_hsql.getXMLFromCatalog();
    } catch (HSQLParseException e) {
        String msg = "DDL Error: " + e.getMessage();
        throw m_compiler.new VoltCompilerException(msg);
    }

    // output the xml catalog to disk
    PrintStream ddlXmlOutput = BuildDirectoryUtils.getDebugOutputPrintStream("schema-xml", "hsql-catalog-output.xml");
    ddlXmlOutput.println(xmlCatalog);
    ddlXmlOutput.close();

    // build the local catalog from the xml catalog
    fillCatalogFromXML(catalog, db, xmlCatalog);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:21,代码来源:DDLCompiler.java

示例4: createTPCCSchemaCatalog

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public Catalog createTPCCSchemaCatalog(boolean fkeys) throws IOException {
    // compile a catalog
    String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
    String catalogJar = testDir + File.separator + this.getJarName(true);

    addSchema(this.getDDLURL(fkeys));
    addDefaultPartitioning();
    addDefaultProcedures();
    //this.addProcedures(org.voltdb.benchmark.tpcc.procedures.InsertHistory.class);

    boolean status = compile(catalogJar);
    assert(status);

    // read in the catalog
    String serializedCatalog = CatalogUtil.loadCatalogFromJar(catalogJar, null);
    assert(serializedCatalog != null);

    // create the catalog (that will be passed to the ClientInterface
    Catalog catalog = new Catalog();
    catalog.execute(serializedCatalog);

    return catalog;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:TPCCProjectBuilder.java

示例5: testGetStats

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testGetStats() throws Exception {
    final Catalog catalog = new Catalog();
    catalog.execute(LoadCatalogToString.THE_CATALOG);
    sourceEngine.loadCatalog(catalog.serialize());

    final int WAREHOUSE_TABLEID = catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("WAREHOUSE").getRelativeIndex();
    final int STOCK_TABLEID = catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("STOCK").getRelativeIndex();
    final int locators[] = new int[] { WAREHOUSE_TABLEID, STOCK_TABLEID };
    final VoltTable results[] = sourceEngine.getStats(SysProcSelector.TABLE, locators, false, 0L);
    assertNotNull(results);
    assertEquals(1, results.length);
    assertNotNull(results[0]);
    final VoltTable resultTable = results[0];
    assertEquals(2, resultTable.getRowCount());
    while (resultTable.advanceRow()) {
        String tn = resultTable.getString("TABLE_NAME");
        assertTrue(tn.equals("WAREHOUSE") || tn.equals("STOCK"));
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:TestExecutionEngine.java

示例6: testNonZeroReplicationFactor

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testNonZeroReplicationFactor()
    {
        ClusterConfig config = new ClusterConfig(3, 1, 2, "localhost");
        Catalog catalog = new Catalog();
        catalog.execute("add / clusters cluster");
        ClusterCompiler.compile(catalog, config);
        System.out.println(catalog.serialize());
        Cluster cluster = catalog.getClusters().get("cluster");
        Collection<Partition> partitions = CatalogUtil.getAllPartitions(cluster);
        // despite 3 hosts, should only have 1 partition with k-safety of 2
//        assertEquals(1, partitions.size());
//        // All the execution sites should have the same relative index
//        int part_guid = CatalogUtil.getPartitionById(cluster, 0).getRelativeIndex();
//        for (Site site : cluster.getSites())
//        {
////            if (site.getIsexec())
////            {
////                assertEquals(part_guid, site.getPartition().getRelativeIndex());
////            }
//        }
    }
 
开发者ID:s-store,项目名称:s-store,代码行数:22,代码来源:TestClusterCompiler.java

示例7: testSufficientHostsToReplicate

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testSufficientHostsToReplicate()
{
    // 2 hosts, 6 sites per host, 2 copies of each partition.
    // there are sufficient execution sites, but insufficient hosts
    ClusterConfig config = new ClusterConfig(2, 6, 2, "localhost");
    Catalog catalog = new Catalog();
    catalog.execute("add / clusters cluster");
    boolean caught = false;
    try
    {
        ClusterCompiler.compile(catalog, config);
    }
    catch (RuntimeException e)
    {
        if (e.getMessage().contains("Insufficient hosts"))
        {
            caught = true;
        }
    }
    assertTrue(caught);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:TestClusterCompiler.java

示例8: testSimplest

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testSimplest() {
    Catalog catalog1 = new Catalog();
    catalog1.execute(LoadCatalogToString.THE_CATALOG);

    String commands = catalog1.serialize();
    // System.out.println(commands);

    Catalog catalog2 = new Catalog();
    try {
        catalog2.execute(commands);
    } catch (Exception e) {
        e.printStackTrace();
    }
    String commands2 = catalog2.serialize();

    Catalog catalog3 = catalog2.deepCopy();
    String commands3 = catalog3.serialize();

    assertTrue(commands.equals(commands2));
    assertTrue(commands.equals(commands3));

    assertTrue(catalog1.equals(catalog2));
    assertTrue(catalog1.equals(catalog3));
}
 
开发者ID:s-store,项目名称:s-store,代码行数:25,代码来源:TestCatalogSerialization.java

示例9: testLoadTable

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testLoadTable() throws Exception {
    Catalog catalog = new Catalog();
    catalog.execute(LoadCatalogToString.THE_CATALOG);
    sourceEngine.loadCatalog(catalog.serialize());

    int WAREHOUSE_TABLEID = warehouseTableId(catalog);
    int STOCK_TABLEID = stockTableId(catalog);

    loadTestTables(catalog);

    assertEquals(200, sourceEngine.serializeTable(WAREHOUSE_TABLEID).getRowCount());
    assertEquals(1000, sourceEngine.serializeTable(STOCK_TABLEID).getRowCount());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:14,代码来源:TestExecutionEngine.java

示例10: update

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public CatalogContext update(String pathToNewJar, String diffCommands) {
    Catalog newCatalog = catalog.deepCopy();
    newCatalog.execute(diffCommands);
    CatalogContext retval = new CatalogContext(newCatalog, pathToNewJar);
    return retval;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:7,代码来源:CatalogContext.java

示例11: prepareApplicationCatalogDiff

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
private AsyncCompilerResult prepareApplicationCatalogDiff(CatalogChangeWork work) {
        // create the change result and set up all the boiler plate
        CatalogChangeResult retval = new CatalogChangeResult();
//        retval.clientData = work.clientData;
        retval.clientHandle = work.clientHandle;
//        retval.connectionId = work.connectionId;
//        retval.hostname = work.hostname;

        // catalog change specific boiler plate
        retval.catalogURL = work.catalogURL;

        // get the diff between catalogs
        try {
            // try to get the new catalog from the params
            String newCatalogCommands = CatalogUtil.loadCatalogFromJar(work.catalogURL, null);
            if (newCatalogCommands == null) {
                retval.errorMsg = "Unable to read from catalog at: " + work.catalogURL;
                return retval;
            }
            Catalog newCatalog = new Catalog();
            newCatalog.execute(newCatalogCommands);

            // get the current catalog
            CatalogContext context = VoltDB.instance().getCatalogContext();

            // store the version of the catalog the diffs were created against.
            // verified when / if the update procedure runs in order to verify
            // catalogs only move forward
            retval.expectedCatalogVersion = context.catalog.getCatalogVersion();

            // compute the diff in StringBuilder
            CatalogDiffEngine diff = new CatalogDiffEngine(context.catalog, newCatalog);
            if (!diff.supported()) {
                throw new Exception("The requested catalog change is not a supported change at this time. " + diff.errors());
            }

            // since diff commands can be stupidly big, compress them here
            retval.encodedDiffCommands = Encoder.compressAndBase64Encode(diff.commands());
            // check if the resulting string is small enough to fit in our parameter sets (about 2mb)
            if (retval.encodedDiffCommands.length() > (2 * 1000 * 1000)) {
                throw new Exception("The requested catalog change is too large for this version of VoltDB. " +
                                    "Try a series of smaller updates.");
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            retval.encodedDiffCommands = null;
            retval.errorMsg = e.getMessage();
        }

        return retval;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:53,代码来源:AsyncCompilerWorkThread.java

示例12: testLoadCatalogs

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testLoadCatalogs() throws Exception {
    Catalog catalog = new Catalog();
    catalog.execute(LoadCatalogToString.THE_CATALOG);
    sourceEngine.loadCatalog(catalog.serialize());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:6,代码来源:TestExecutionEngine.java

示例13: testStreamTables

import org.voltdb.catalog.Catalog; //导入方法依赖的package包/类
public void testStreamTables() throws Exception {
        final Catalog catalog = new Catalog();
        catalog.execute(LoadCatalogToString.THE_CATALOG);
        sourceEngine.loadCatalog(catalog.serialize());
        ExecutionEngine destinationEngine = new ExecutionEngineJNI(null, CLUSTER_ID, NODE_ID, 0, 0, "");
        destinationEngine.loadCatalog(catalog.serialize());

        int WAREHOUSE_TABLEID = warehouseTableId(catalog);
        int STOCK_TABLEID = stockTableId(catalog);

        loadTestTables(catalog);

        sourceEngine.activateTableStream( WAREHOUSE_TABLEID, TableStreamType.RECOVERY );
        sourceEngine.activateTableStream( STOCK_TABLEID, TableStreamType.RECOVERY );

        BBContainer origin = DBBPool.allocateDirect(1024 * 1024 * 2);
        try {
            origin.b.clear();
            long address = org.voltdb.utils.DBBPool.getBufferAddress(origin.b);
            BBContainer container = new BBContainer(origin.b, address){

                @Override
                public void discard() {
                }};

            int serialized = sourceEngine.tableStreamSerializeMore( container, WAREHOUSE_TABLEID, TableStreamType.RECOVERY);
            assertTrue(serialized > 0);
            container.b.limit(serialized);
            destinationEngine.processRecoveryMessage( container.b, container.address);


            serialized = sourceEngine.tableStreamSerializeMore( container, WAREHOUSE_TABLEID, TableStreamType.RECOVERY);
            assertEquals( 21, serialized);
            int id = container.b.get();
            assert(id >= 0);
//            assertEquals( RecoveryMessageType.Complete.ordinal(), container.b.get());
            assertEquals( WAREHOUSE_TABLEID, container.b.getInt());

            assertEquals( sourceEngine.tableHashCode(WAREHOUSE_TABLEID), destinationEngine.tableHashCode(WAREHOUSE_TABLEID));

            container.b.clear();
            serialized = sourceEngine.tableStreamSerializeMore( container, STOCK_TABLEID, TableStreamType.RECOVERY);
            assertTrue(serialized > 0);
            container.b.limit(serialized);
            destinationEngine.processRecoveryMessage( container.b, container.address);


            serialized = sourceEngine.tableStreamSerializeMore( container, STOCK_TABLEID, TableStreamType.RECOVERY);
            assertEquals( 21, serialized);
            id = container.b.get();
            assert(id >= 0);
//            assertEquals( RecoveryMessageType.Complete.ordinal(), container.b.get());
            assertEquals( STOCK_TABLEID, container.b.getInt());

            assertEquals( sourceEngine.tableHashCode(STOCK_TABLEID), destinationEngine.tableHashCode(STOCK_TABLEID));
        } finally {
            origin.discard();
        }
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:60,代码来源:TestExecutionEngine.java


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