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