Search in sources :

Example 41 with VoltCompiler

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

the class RealVoltDB method stageSchemaFiles.

private void stageSchemaFiles(Configuration config) {
    if (config.m_userSchema == null) {
        // nothing to do
        return;
    }
    // this is validated during command line parsing and will be true unless disk faults
    assert (config.m_userSchema.isFile());
    File stagedCatalogFH = new VoltFile(getStagedCatalogPath(getVoltDBRootPath()));
    if (!config.m_forceVoltdbCreate && stagedCatalogFH.exists()) {
        VoltDB.crashLocalVoltDB("A previous database was initialized with a schema. You must init with --force to overwrite the schema.");
    }
    final boolean standalone = false;
    final boolean isXCDR = false;
    VoltCompiler compiler = new VoltCompiler(standalone, isXCDR);
    compiler.setInitializeDDLWithFiltering(true);
    if (!compiler.compileFromSchemaAndClasses(config.m_userSchema, config.m_stagedClassesPath, stagedCatalogFH)) {
        VoltDB.crashLocalVoltDB("Could not compile specified schema " + config.m_userSchema);
    }
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) VoltFile(org.voltdb.utils.VoltFile) VoltFile(org.voltdb.utils.VoltFile) File(java.io.File)

Example 42 with VoltCompiler

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

the class CatalogUtil method loadAndUpgradeCatalogFromJar.

/**
     * Load a catalog from the InMemoryJarfile.
     *
     * @param jarfile
     * @return Pair containing updated InMemoryJarFile and upgraded version (or null if it wasn't upgraded)
     * @throws IOException if there is no version information in the catalog.
     */
public static Pair<InMemoryJarfile, String> loadAndUpgradeCatalogFromJar(InMemoryJarfile jarfile, boolean isXDCR) throws IOException {
    // Let VoltCompiler do a version check and upgrade the catalog on the fly.
    // I.e. jarfile may be modified.
    VoltCompiler compiler = new VoltCompiler(isXDCR);
    String upgradedFromVersion = compiler.upgradeCatalogAsNeeded(jarfile);
    return new Pair<>(jarfile, upgradedFromVersion);
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) Pair(org.voltcore.utils.Pair)

Example 43 with VoltCompiler

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

the class TestInMemoryJarfile method createTestJarFile.

private Catalog createTestJarFile(String jarFileName, boolean adhoc) {
    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 schema2 = "partition table WAREHOUSE on column W_ID;\n" + "create procedure from class org.voltdb.compiler.procedures.TPCCTestProc;\n";
    if (adhoc) {
        schema2 += "create role default with sql, adhoc;";
    }
    final File schema2File = VoltProjectBuilder.writeStringToTempFile(schema2);
    final String schema2Path = schema2File.getPath();
    VoltCompiler compiler = new VoltCompiler(false);
    assertTrue(compiler.compileFromDDL(jarFileName, schemaPath, schema2Path));
    return compiler.getCatalog();
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) UnsupportedEncodingException(java.io.UnsupportedEncodingException) File(java.io.File) URL(java.net.URL)

Aggregations

VoltCompiler (org.voltdb.compiler.VoltCompiler)43 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)26 File (java.io.File)16 ClientResponse (org.voltdb.client.ClientResponse)15 ProcCallException (org.voltdb.client.ProcCallException)15 Test (org.junit.Test)13 Configuration (org.voltdb.VoltDB.Configuration)12 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)11 VoltDB (org.voltdb.VoltDB)9 IOException (java.io.IOException)5 FileInputStream (java.io.FileInputStream)4 VoltTable (org.voltdb.VoltTable)4 Catalog (org.voltdb.catalog.Catalog)4 URL (java.net.URL)3 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)3 VoltFile (org.voltdb.utils.VoltFile)3 PrintWriter (java.io.PrintWriter)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 UUID (java.util.UUID)2