Search in sources :

Example 66 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestSystemCatalogSuite method testTypeInfoSelector.

public void testTypeInfoSelector() throws IOException, ProcCallException {
    Client client = getClient();
    VoltTable[] results = client.callProcedure("@SystemCatalog", "TYPEINFO").getResults();
    // Will break if we add a type, hopefully gets
    assertEquals(14, results[0].getRowCount());
    // type-adder to double-check they've got things right
    assertEquals(18, results[0].getColumnCount());
    System.out.println(results[0]);
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 67 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestSystemCatalogSuite method testPrimaryKeysSelector.

public void testPrimaryKeysSelector() throws IOException, ProcCallException {
    Client client = getClient();
    VoltTable[] results = client.callProcedure("@SystemCatalog", "PRIMARYKEYS").getResults();
    assertEquals(6, results[0].getColumnCount());
    System.out.println(results[0]);
}
Also used : Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 68 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestBlobType method testTPCCCustomerLookup.

public void testTPCCCustomerLookup() throws Exception {
    // constants used int the benchmark
    final short W_ID = 3;
    final byte D_ID = 7;
    final int C_ID = 42;
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addSchema(TPCCProjectBuilder.ddlURL);
    for (String[] pair : TPCCProjectBuilder.partitioning) {
        builder.addPartitionInfo(pair[0], pair[1]);
    }
    builder.addStmtProcedure("InsertCustomer", "INSERT INTO CUSTOMER VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", "CUSTOMER.C_W_ID: 2");
    builder.addStmtProcedure("Fake1", "SELECT C_ID, C_FIRST, C_MIDDLE, C_LAST, C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_SINCE, C_CREDIT, C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_YTD_PAYMENT, C_PAYMENT_CNT, C_DATA FROM CUSTOMER WHERE C_LAST = ? AND C_D_ID = ? AND C_W_ID = ? ORDER BY C_FIRST;");
    builder.addProcedures(FakeCustomerLookup.class);
    boolean success = builder.compile(Configuration.getPathToCatalogForTest("binarytest2.jar"), 1, 1, 0);
    assert (success);
    MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("binarytest2.xml"));
    ServerThread localServer = null;
    Client client = null;
    try {
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = Configuration.getPathToCatalogForTest("binarytest2.jar");
        config.m_pathToDeployment = Configuration.getPathToCatalogForTest("binarytest2.xml");
        config.m_backend = BackendTarget.NATIVE_EE_JNI;
        localServer = new ServerThread(config);
        localServer.start();
        localServer.waitForInitialization();
        client = ClientFactory.createClient();
        client.createConnection("localhost");
        // insert data
        // long c_id, long c_d_id, long c_w_id, String c_first, String c_middle,
        // String c_last, String c_street_1, String c_street_2, String d_city,
        // String d_state, String d_zip, String c_phone, Date c_since, String
        // c_credit, double c_credit_lim, double c_discount, double c_balance,
        // double c_ytd_payment, double c_payment_cnt, double c_delivery_cnt,
        // String c_data
        final double initialBalance = 15.75;
        final double initialYTD = 15241.45;
        VoltTable customer1 = client.callProcedure("InsertCustomer", C_ID, D_ID, W_ID, "I", "Be", "lastname", "Place", "Place2", "BiggerPlace", "AL", "91083", "(193) 099 - 9082", new TimestampType(), "BC", 19298943.12, .13, initialBalance, initialYTD, 0L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer1.asScalarLong());
        VoltTable customer2 = client.callProcedure("InsertCustomer", C_ID + 1, D_ID, W_ID, "We", "R", "Customer", "Random Department", "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD, 1L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer2.asScalarLong());
        VoltTable customer3 = client.callProcedure("InsertCustomer", C_ID + 2, D_ID, W_ID, "Who", "Is", "Customer", "Receiving", "450 Mass F.X.", "BiggerPlace", "CI", "91083", "(541) 931 - 0928", new TimestampType(), "GC", 19899324.21, .13, initialBalance, initialYTD, 2L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer3.asScalarLong());
        VoltTable customer4 = client.callProcedure("InsertCustomer", C_ID + 3, D_ID, W_ID, "ICanBe", "", "Customer", "street", "place", "BiggerPlace", "MA", "91083", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD, 3L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer4.asScalarLong());
        // make sure strings as bytes works
        ClientResponse cr = client.callProcedure("Fake1", "Customer".getBytes("UTF-8"), D_ID, W_ID);
        assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
        assertEquals(3, cr.getResults()[0].getRowCount());
        cr = client.callProcedure("Fake1", "Customer", D_ID, W_ID);
        assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
        assertEquals(3, cr.getResults()[0].getRowCount());
        cr = client.callProcedure("FakeCustomerLookup", W_ID, W_ID, D_ID, "Customer".getBytes("UTF-8"));
        assertTrue(cr.getStatus() == ClientResponse.SUCCESS);
    } finally {
        // stop execution
        if (client != null) {
            client.close();
        }
        if (localServer != null) {
            localServer.shutdown();
            localServer.join();
        }
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Configuration(org.voltdb.VoltDB.Configuration) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) ServerThread(org.voltdb.ServerThread) Configuration(org.voltdb.VoltDB.Configuration) Client(org.voltdb.client.Client)

Example 69 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class TestBlobType method testBigFatBlobs.

public void testBigFatBlobs() throws Exception {
    String simpleSchema = "create table blah (" + "ival bigint default 0 not null, " + "b varbinary(256) default null, " + "s varchar(256) default null, " + "PRIMARY KEY(ival));";
    VoltProjectBuilder builder = new VoltProjectBuilder();
    builder.addLiteralSchema(simpleSchema);
    builder.addProcedures(BigFatBlobAndStringMD5.class);
    boolean success = builder.compile(Configuration.getPathToCatalogForTest("bigfatblobs.jar"), 1, 1, 0);
    assertTrue("Failed to compile catalog", success);
    MiscUtils.copyFile(builder.getPathToDeployment(), Configuration.getPathToCatalogForTest("bigfatblobs.xml"));
    VoltDB.Configuration config = new VoltDB.Configuration();
    config.m_pathToCatalog = Configuration.getPathToCatalogForTest("bigfatblobs.jar");
    config.m_pathToDeployment = Configuration.getPathToCatalogForTest("bigfatblobs.xml");
    config.m_backend = BackendTarget.NATIVE_EE_JNI;
    ServerThread localServer = null;
    Client client = null;
    try {
        localServer = new ServerThread(config);
        localServer.start();
        localServer.waitForInitialization();
        client = ClientFactory.createClient();
        client.createConnection("localhost");
        byte[] b = new byte[5000000];
        char[] c = new char[5000000];
        for (int i = 0; i < b.length; i++) {
            b[i] = (byte) (i % 256);
            c[i] = (char) (i % 128);
        }
        String s = new String(c);
        ClientResponse cr = client.callProcedure("BigFatBlobAndStringMD5", b, s);
        assertEquals(ClientResponse.SUCCESS, cr.getStatus());
        VoltTable t = cr.getResults()[0];
        assertEquals(1, t.getRowCount());
        assertTrue(t.advanceRow());
        // Validate MD5 sums instead of the actual data. The returned VoltTable
        // can't hold it anyway due to a 1 MB limit.
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        assertTrue(Arrays.equals(md5.digest(b), t.getVarbinary("b_md5")));
        assertTrue(Arrays.equals(md5.digest(s.getBytes()), t.getVarbinary("s_md5")));
    } finally {
        // stop execution
        if (client != null) {
            client.close();
        }
        if (localServer != null) {
            localServer.shutdown();
            localServer.join();
        }
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Configuration(org.voltdb.VoltDB.Configuration) VoltTable(org.voltdb.VoltTable) VoltDB(org.voltdb.VoltDB) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ServerThread(org.voltdb.ServerThread) Client(org.voltdb.client.Client) MessageDigest(java.security.MessageDigest)

Example 70 with VoltTable

use of org.voltdb.VoltTable in project voltdb by VoltDB.

the class BigFatBlobAndStringMD5 method run.

public VoltTable run(byte[] b, String s) {
    VoltTable t = new VoltTable(new ColumnInfo("b_md5", VoltType.VARBINARY), new ColumnInfo("s_md5", VoltType.VARBINARY));
    try {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        t.addRow(md5.digest(b), md5.digest(s.getBytes()));
    } catch (NoSuchAlgorithmException e) {
    // If the row wasn't added the test caller will consider it a failure.
    }
    return t;
}
Also used : ColumnInfo(org.voltdb.VoltTable.ColumnInfo) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest) VoltTable(org.voltdb.VoltTable)

Aggregations

VoltTable (org.voltdb.VoltTable)887 Client (org.voltdb.client.Client)497 ClientResponse (org.voltdb.client.ClientResponse)193 ProcCallException (org.voltdb.client.ProcCallException)144 IOException (java.io.IOException)100 VoltTableRow (org.voltdb.VoltTableRow)57 NoConnectionsException (org.voltdb.client.NoConnectionsException)52 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)42 TimestampType (org.voltdb.types.TimestampType)37 BigDecimal (java.math.BigDecimal)30 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)26 File (java.io.File)25 HashMap (java.util.HashMap)21 ClientResponseImpl (org.voltdb.ClientResponseImpl)20 Timestamp (java.sql.Timestamp)15 Date (java.util.Date)15 VoltDB (org.voltdb.VoltDB)15 DependencyPair (org.voltdb.DependencyPair)14 Configuration (org.voltdb.VoltDB.Configuration)14