Search in sources :

Example 16 with VoltCompiler

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

the class TestJdbcDatabaseMetaDataGenerator method testGetTypeInfo.

public void testGetTypeInfo() 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=?;";
    VoltCompiler c = compileForDDLTest2(schema);
    JdbcDatabaseMetaDataGenerator dut = new JdbcDatabaseMetaDataGenerator(c.getCatalog(), null, new InMemoryJarfile(testout_jar));
    VoltTable typeInfo = dut.getMetaData("typEINfo");
    System.out.println(typeInfo);
    // just do some minor sanity checks on size of table and that it contains the types
    // we expect
    HashMap<String, VoltType> expectedTypes = new HashMap<String, VoltType>();
    for (VoltType type : VoltType.values()) {
        if (type.isJdbcVisible()) {
            expectedTypes.put(type.toSQLString().toUpperCase(), type);
        }
    }
    assertEquals(expectedTypes.size(), typeInfo.getRowCount());
    assertEquals(18, typeInfo.getColumnCount());
    typeInfo.resetRowPosition();
    while (typeInfo.advanceRow()) {
        String gotName = typeInfo.getString("TYPE_NAME");
        VoltType expectedType = expectedTypes.remove(gotName);
        assertTrue(expectedType != null);
    }
    assertTrue(expectedTypes.isEmpty());
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) HashMap(java.util.HashMap) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile)

Example 17 with VoltCompiler

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

the class TestJdbcDatabaseMetaDataGenerator method testGetProcedureColumns.

public void testGetProcedureColumns() 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=?;";
    VoltCompiler c = compileForDDLTest2(schema);
    System.out.println(c.getCatalog().serialize());
    DefaultProcedureManager defaultProcs = new DefaultProcedureManager(c.getCatalogDatabase());
    JdbcDatabaseMetaDataGenerator dut = new JdbcDatabaseMetaDataGenerator(c.getCatalog(), defaultProcs, new InMemoryJarfile(testout_jar));
    VoltTable params = dut.getMetaData("ProcedureColumns");
    System.out.println(params);
    assertEquals(20, params.getColumnCount());
    // 2 real and 2 crud inserts
    assertEquals(4, params.getRowCount());
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(params, "PROCEDURE_NAME", "proc1"));
    assertEquals("param0", params.get("COLUMN_NAME", VoltType.STRING));
    assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("PRECISION", VoltType.INTEGER));
    assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("LENGTH", VoltType.INTEGER));
    assertEquals(VoltType.MAX_VALUE_LENGTH, params.get("CHAR_OCTET_LENGTH", VoltType.INTEGER));
    assertEquals("PARTITION_PARAMETER", params.get("REMARKS", VoltType.STRING));
    assertTrue(VoltTableTestHelpers.moveToMatchingRow(params, "PROCEDURE_NAME", "proc2"));
    assertEquals("param0", params.get("COLUMN_NAME", VoltType.STRING));
    assertEquals(VoltType.INTEGER.getLengthInBytesForFixedTypes() * 8 - 1, params.get("PRECISION", VoltType.INTEGER));
    assertEquals(VoltType.INTEGER.getLengthInBytesForFixedTypes(), params.get("LENGTH", VoltType.INTEGER));
    assertWithNullCheck(null, params.get("CHAR_OCTET_LENGTH", VoltType.INTEGER), params);
    assertWithNullCheck(null, params.get("REMARKS", VoltType.STRING), params);
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) InMemoryJarfile(org.voltdb.utils.InMemoryJarfile)

Example 18 with VoltCompiler

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

the class CatalogUtil method createTemporaryEmptyCatalogJarFile.

/**
     * Build an empty catalog jar file.
     * @return jar file or null (on failure)
     * @throws IOException on failure to create temporary jar file
     * @param isXDCR
     */
public static File createTemporaryEmptyCatalogJarFile(boolean isXDCR) throws IOException {
    File emptyJarFile = File.createTempFile("catalog-empty", ".jar");
    emptyJarFile.deleteOnExit();
    VoltCompiler compiler = new VoltCompiler(isXDCR);
    if (!compiler.compileEmptyCatalog(emptyJarFile.getAbsolutePath())) {
        return null;
    }
    return emptyJarFile;
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) File(java.io.File)

Example 19 with VoltCompiler

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

the class TestCanonicalDDLThroughSQLcmd method secondCanonicalDDLFromAdhoc.

private void secondCanonicalDDLFromAdhoc() throws Exception {
    String pathToCatalog = Configuration.getPathToCatalogForTest("emptyDDL.jar");
    String pathToDeployment = Configuration.getPathToCatalogForTest("emptyDDL.xml");
    VoltCompiler compiler = new VoltCompiler(false);
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.setUseDDLSchema(true);
    boolean success = builder.compile(pathToCatalog);
    assertTrue(success);
    MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = pathToCatalog;
    config.m_pathToDeployment = pathToDeployment;
    startSystem(config);
    m_client.callProcedure("@AdHoc", firstCanonicalDDL);
    // First line of canonical DDL differs thanks to creation time.  Avoid
    // it in the comparison
    // Sanity check that we're not trimming the entire fullddl.sql file away
    assertTrue(firstCanonicalDDL.indexOf('\n') < 100);
    String secondDDL = compiler.getCanonicalDDL();
    assertEquals(firstCanonicalDDL.substring(firstCanonicalDDL.indexOf('\n')), secondDDL.substring(secondDDL.indexOf('\n')));
    teardownSystem();
}
Also used : VoltDB(org.voltdb.VoltDB) VoltCompiler(org.voltdb.compiler.VoltCompiler) Configuration(org.voltdb.VoltDB.Configuration) SSLConfiguration(org.voltcore.utils.ssl.SSLConfiguration) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration)

Example 20 with VoltCompiler

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

the class TestCanonicalDDLThroughSQLcmd method getFirstCanonicalDDL.

private String getFirstCanonicalDDL() throws Exception {
    String pathToCatalog = Configuration.getPathToCatalogForTest("fullDDL.jar");
    VoltCompiler compiler = new VoltCompiler(false);
    final URL url = TestDDLFeatures.class.getResource("fullDDL.sql");
    String pathToSchema = URLDecoder.decode(url.getPath(), "UTF-8");
    boolean success = compiler.compileFromDDL(pathToCatalog, pathToSchema);
    assertTrue(success);
    return compiler.getCanonicalDDL();
}
Also used : VoltCompiler(org.voltdb.compiler.VoltCompiler) 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