Search in sources :

Example 51 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testDDLWithLongStringInCharacters.

public void testDDLWithLongStringInCharacters() throws IOException {
    int length = VoltType.MAX_VALUE_LENGTH_IN_CHARACTERS + 10;
    String schema1 = "create table books (cash integer default 23, " + "title varchar(" + length + ") default 'foo', PRIMARY KEY(cash));";
    VoltCompiler compiler = new VoltCompiler(false);
    final boolean success = compileDDL(schema1, compiler);
    assertTrue(success);
    // Check warnings
    assertEquals(1, compiler.m_warnings.size());
    String warningMsg = compiler.m_warnings.get(0).getMessage();
    String expectedMsg = "The size of VARCHAR column TITLE in table BOOKS greater than " + "262144 will be enforced as byte counts rather than UTF8 character counts. " + "To eliminate this warning, specify \"VARCHAR(262154 BYTES)\"";
    assertEquals(expectedMsg, warningMsg);
    Database db = compiler.getCatalog().getClusters().get("cluster").getDatabases().get("database");
    Column var = db.getTables().get("BOOKS").getColumns().get("TITLE");
    assertTrue(var.getInbytes());
}
Also used : Column(org.voltdb.catalog.Column) Database(org.voltdb.catalog.Database)

Example 52 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompilerAlterDropTable method verifyIndexExists.

//Check given index exists
private void verifyIndexExists(VoltCompiler compiler, String tableName, String idxName) {
    Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
    Table table = db.getTables().get(tableName);
    Index idx = table.getIndexes().get(idxName);
    assertNotNull(idx);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) Index(org.voltdb.catalog.Index)

Example 53 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompilerAlterDropTable method verifyTableColumnType.

//Check given col type if catalog was compiled.
private void verifyTableColumnType(VoltCompiler compiler, String tableName, String colName, VoltType type) {
    Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
    Table table = db.getTables().get(tableName);
    Column col = table.getColumns().get(colName);
    assertNotNull(col);
    assertEquals(0, type.compareTo(VoltType.get((byte) col.getType())));
}
Also used : Table(org.voltdb.catalog.Table) Column(org.voltdb.catalog.Column) Database(org.voltdb.catalog.Database)

Example 54 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testValidAnnotatedProcedureDLL.

public void testValidAnnotatedProcedureDLL() throws Exception {
    String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "creAte PrOcEdUrE FrOm CLasS org.voltdb.compiler.procedures.AddBook;";
    VoltCompiler compiler = new VoltCompiler(false);
    final boolean success = compileDDL(schema, compiler);
    assertTrue(success);
    String catalogContents = VoltCompilerUtils.readFileFromJarfile(testout_jar, "catalog.txt");
    Catalog c2 = new Catalog();
    c2.execute(catalogContents);
    Database db = c2.getClusters().get("cluster").getDatabases().get("database");
    Procedure addBook = db.getProcedures().get("AddBook");
    assertTrue(addBook.getSinglepartition());
}
Also used : Database(org.voltdb.catalog.Database) Procedure(org.voltdb.catalog.Procedure) Catalog(org.voltdb.catalog.Catalog)

Example 55 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompiler method testOverrideNonAnnotatedProcInfo.

public void testOverrideNonAnnotatedProcInfo() throws IOException {
    String schema = "create table books" + " (cash integer default 23 not null," + " title varchar(3) default 'foo'," + " PRIMARY KEY(cash));" + "PARTITION TABLE books ON COLUMN cash;" + "create procedure from class org.voltdb.compiler.procedures.AddBook;" + "partition procedure AddBook ON TABLE books COLUMN cash;";
    ProcInfoData info = new ProcInfoData();
    info.singlePartition = true;
    info.partitionInfo = "BOOKS.CASH: 0";
    Map<String, ProcInfoData> overrideMap = new HashMap<>();
    overrideMap.put("AddBook", info);
    VoltCompiler compiler = new VoltCompiler(false);
    compiler.setProcInfoOverrides(overrideMap);
    final boolean success = compileDDL(schema, compiler);
    assertTrue(success);
    String catalogContents = VoltCompilerUtils.readFileFromJarfile(testout_jar, "catalog.txt");
    Catalog c2 = new Catalog();
    c2.execute(catalogContents);
    Database db = c2.getClusters().get("cluster").getDatabases().get("database");
    Procedure addBook = db.getProcedures().get("AddBook");
    assertTrue(addBook.getSinglepartition());
}
Also used : HashMap(java.util.HashMap) ProcInfoData(org.voltdb.ProcInfoData) Database(org.voltdb.catalog.Database) Procedure(org.voltdb.catalog.Procedure) Catalog(org.voltdb.catalog.Catalog)

Aggregations

Database (org.voltdb.catalog.Database)62 Table (org.voltdb.catalog.Table)22 Catalog (org.voltdb.catalog.Catalog)12 Cluster (org.voltdb.catalog.Cluster)10 File (java.io.File)9 Column (org.voltdb.catalog.Column)9 Procedure (org.voltdb.catalog.Procedure)9 IOException (java.io.IOException)5 VoltTable (org.voltdb.VoltTable)5 ArrayList (java.util.ArrayList)4 Group (org.voltdb.catalog.Group)4 Connector (org.voltdb.catalog.Connector)3 Constraint (org.voltdb.catalog.Constraint)3 Statement (org.voltdb.catalog.Statement)3 FileNotFoundException (java.io.FileNotFoundException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 JAXBException (javax.xml.bind.JAXBException)2