Search in sources :

Example 66 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class NbboBenchmark method iterate.

public void iterate() throws Exception {
    Symbols.Symbol s = symbols.getRandom();
    int ask = Math.round(s.price * (1 + rand.nextFloat() / 20));
    int bid = Math.round(s.price * (1 - rand.nextFloat() / 20));
    String exch = exchanges[rand.nextInt(exchanges.length)];
    client.callProcedure(new BenchmarkCallback("ProcessTick"), "ProcessTick", s.symbol, new TimestampType(), //seq_number
    seq++, // exchange
    exch, //bid_price
    bid, //bid_size
    sizes[rand.nextInt(sizes.length)], //ask_price
    ask, //ask_size
    sizes[rand.nextInt(sizes.length)]);
}
Also used : TimestampType(org.voltdb.types.TimestampType)

Example 67 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestTPCCSuite method testOSTAT.

public void testOSTAT() throws IOException, ProcCallException {
    Client client = getClient();
    // create a District, Warehouse, and 4 Customers (multiple, since we
    // want to test for correct behavior of paymentByCustomerName.
    // long d_id, long d_w_id, String d_name, String d_street_1, String
    // d_street_2, String d_city, String d_state, String d_zip, double
    // d_tax, double d_ytd, long d_next_o_id
    VoltTable[] idresults = client.callProcedure("InsertDistrict", 7L, 3L, "A District", "Street Addy", "meh", "westerfield", "BA", "99999", .0825, 15241.45, 21L).getResults();
    // check that a district was inserted
    assertEquals(1L, idresults[0].asScalarLong());
    // long w_id, String w_name, String w_street_1, String w_street_2,
    // String w_city, String w_zip, double w_tax, long w_ytd
    VoltTable warehouse = client.callProcedure("InsertWarehouse", 3L, "EZ Street WHouse", "Headquarters", "77 Mass. Ave.", "Cambridge", "AZ", "12938", .1234, 18837.57).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, warehouse.asScalarLong());
    VoltTable customer = client.callProcedure("InsertCustomer", 5L, 7L, 3L, "We", "R", "Customer", "Random Department", "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, 15.75, 18832.45, 45L, 15L, "Some History").getResults()[0];
    // check for successful insertion.
    assertEquals(1L, customer.asScalarLong());
    VoltTable orders = client.callProcedure("InsertOrders", 9L, 7L, 3L, 5L, new TimestampType(), 10L, 5L, 6L).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, orders.asScalarLong());
    TPCDataPrinter.printAllData(client);
    VoltTable[] results = client.callProcedure("ostatByCustomerName", (byte) 3, (byte) 7, "Customer").getResults();
    assertEquals(3, results.length);
    results = client.callProcedure("ostatByCustomerId", (byte) 3, (byte) 7, 5).getResults();
    assertEquals(3, results.length);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 68 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestTPCCSuite method testInsertsAndSelects.

public void testInsertsAndSelects() throws IOException {
    Client client = getClient();
    try {
        VoltTable[] results = null;
        TimestampType timestamp = new TimestampType();
        results = client.callProcedure("InsertWarehouse", 8L, "EZ Street WHouse", "Headquarters", "77 Mass. Ave.", "Cambridge", "AZ", "12938", .1234, 18837.57).getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertDistrict", 7L, 3L, "A District", "Street Addy", "meh", "westerfield", "BA", "99999", .0825, 15241.45, 21L).getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertItem", 5L, 21L, "An Item", 7.33, "Some Data").getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertCustomer", 2L, 7L, 8L, "I", "Is", "Name", "Place", "Place2", "BiggerPlace", "AL", "91083", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, 15.75, 18832.45, 45L, 15L, "Some History").getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertHistory", 13L, 2L, 7L, 5L, 6L, timestamp, 23.334, "Some History").getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertStock", 5L, 3L, 45L, "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", 5582L, 152L, 32L, "DATA").getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertOrders", 2L, 7L, 5L, 6L, timestamp, 2L, 7L, 5L).getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertNewOrder", 7L, 5L, 6L).getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        results = client.callProcedure("InsertOrderLine", 6L, 7L, 3L, 1L, 4L, 3L, timestamp, 45L, 152.15, "blah blah blah").getResults();
        assertTrue(results[0].asScalarLong() == 1L);
        TPCDataPrinter.printAllData(client);
    } catch (ProcCallException e1) {
        e1.printStackTrace();
        assertTrue(false);
    } catch (IOException e1) {
        e1.printStackTrace();
        assertTrue(false);
    }
}
Also used : TimestampType(org.voltdb.types.TimestampType) IOException(java.io.IOException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 69 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestTPCCSuite method testSLEV.

public void testSLEV() throws IOException, ProcCallException {
    Client client = getClient();
    // call the insertDistrict procedure so we have a valid o_id
    // long d_id, long d_w_id, String d_name, String d_street_1, String
    // d_street_2, String d_city, String d_state, String d_zip, double
    // d_tax, double d_ytd, long d_next_o_id
    VoltTable[] idresults = client.callProcedure("InsertDistrict", 7L, 3L, "A District", "Street Addy", "meh", "westerfield", "BA", "99999", .0825, 15241.45, 21L).getResults();
    // check that a district was inserted
    assertEquals(1L, idresults[0].asScalarLong());
    // This tests case of stock level transaction being called when there
    // are no items with stock and no
    // long w_id, long d_id, long threshold
    VoltTable[] results = client.callProcedure(Constants.STOCK_LEVEL, (byte) 3, (byte) 7, 1).getResults();
    // check one table was returned
    assertEquals(1, results.length);
    // check one tuple was modified
    VoltTable result = results[0];
    assertNotNull(result);
    long stockCount = result.asScalarLong();
    // check count was 0 (should be, for we have empty stock and order-line
    // tables.
    assertEquals(0L, stockCount);
    // Now we repeat the same thing, but adding a valid order-line.
    // long ol_o_id, long ol_d_id, long ol_w_id, long ol_number, long
    // ol_i_id, long ol_supply_w_id, Date ol_delivery_d, long ol_quantity,
    // double ol_amount, String ol_dist_info
    TimestampType timestamp = new TimestampType();
    VoltTable[] olresults = client.callProcedure("InsertOrderLine", 4L, 7L, 3L, 1L, 4L, 3L, timestamp, 45L, 152.15, "blah blah blah").getResults();
    assertEquals(1L, olresults[0].asScalarLong());
    try {
        // We expect this to fail because the stock table is empty.
        results = client.callProcedure(Constants.STOCK_LEVEL, (byte) 3, (byte) 7, 1L).getResults();
        //
        if (Constants.STOCK_LEVEL.equals(slev.class.getSimpleName())) {
            // check one table was returned
            assertEquals(1, results.length);
            // check one tuple was modified
            result = results[0];
            assertNotNull(result);
            stockCount = result.asScalarLong();
            // check count was 0 (should be, for we have an empty stock table.
            assertEquals(0L, stockCount);
        //
        // Otherwise it's the "hand-crafted" SLEV, which should return an error
        //
        } else {
            fail("expected exception");
        }
    } catch (ProcCallException e) {
    }
    // Now we repeat the same thing, but adding a valid stock.
    // long pkey, long s_i_id, long s_w_id, long s_quantity, String
    // s_dist_01, String s_dist_02, String s_dist_03, String s_dist_04,
    // String s_dist_05, String s_dist_06, String s_dist_07, String
    // s_dist_08, String s_dist_09, String s_dist_10, long s_ytd, double
    // s_order_cnt, double s_remote_cnt, String s_data
    timestamp = new TimestampType();
    VoltTable[] isresults = client.callProcedure("InsertStock", 4L, 3L, 45L, "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", 5582L, 152L, 32L, "DATA").getResults();
    assertEquals(1L, isresults[0].asScalarLong());
    results = client.callProcedure(Constants.STOCK_LEVEL, (byte) 3, (byte) 7, 5000).getResults();
    // check one table was returned
    assertEquals(1, results.length);
    // check one tuple was modified
    result = results[0];
    assertNotNull(result);
    stockCount = result.asScalarLong();
    // check count is 1
    assertEquals(1L, stockCount);
    // On more test: this test that Distinct is working properly.
    VoltTable[] ol2results = client.callProcedure("InsertOrderLine", 5L, 7L, 3L, 1L, 5L, 3L, timestamp, 45L, 152.15, "blah blah blah").getResults();
    assertEquals(1L, ol2results[0].asScalarLong());
    VoltTable[] ol3results = client.callProcedure("InsertOrderLine", 6L, 7L, 3L, 1L, 4L, 3L, timestamp, 45L, 152.15, "blah blah blah").getResults();
    assertEquals(1L, ol3results[0].asScalarLong());
    VoltTable[] is2results = client.callProcedure("InsertStock", 5L, 3L, 45L, "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", 5582L, 152L, 32L, "DATA").getResults();
    assertEquals(1L, is2results[0].asScalarLong());
    results = client.callProcedure(Constants.STOCK_LEVEL, (byte) 3, (byte) 7, 5000).getResults();
    // check one table was returned
    assertEquals(1, results.length);
    // check one tuple was modified
    result = results[0];
    assertNotNull(result);
    stockCount = result.asScalarLong();
    // check count is 2, (not 3 or 1).
    assertEquals(2L, stockCount);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException) org.voltdb.benchmark.tpcc.procedures.slev(org.voltdb.benchmark.tpcc.procedures.slev)

Example 70 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestTPCCSuite method testDELIVERY.

public void testDELIVERY() throws IOException, ProcCallException {
    Client client = getClient();
    // create a District, Warehouse, and 4 Customers (multiple, since we
    // want to test for correct behavior of paymentByCustomerName.
    // long d_id, long d_w_id, String d_name, String d_street_1, String
    // d_street_2, String d_city, String d_state, String d_zip, double
    // d_tax, double d_ytd, long d_next_o_id
    VoltTable[] idresults = client.callProcedure("InsertDistrict", D_ID, W_ID, "A District", "Street Addy", "meh", "westerfield", "BA", "99999", .0825, 15241.45, 21L).getResults();
    // check that a district was inserted
    assertEquals(1L, idresults[0].asScalarLong());
    // long w_id, String w_name, String w_street_1, String w_street_2,
    // String w_city, String w_zip, double w_tax, long w_ytd
    VoltTable warehouse = client.callProcedure("InsertWarehouse", W_ID, "EZ Street WHouse", "Headquarters", "77 Mass. Ave.", "Cambridge", "AZ", "12938", .1234, 18837.57).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, warehouse.asScalarLong());
    VoltTable customer = client.callProcedure("InsertCustomer", 5L, D_ID, W_ID, "We", "R", "Customer", "Random Department", "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928", new TimestampType(), "GC", 19298943.12, .13, 15.75, 18832.45, 45L, 15L, "Some History").getResults()[0];
    // check for successful insertion.
    assertEquals(1L, customer.asScalarLong());
    final long O_OL_CNT = 1;
    VoltTable orders = client.callProcedure("InsertOrders", O_ID, D_ID, W_ID, 5L, new TimestampType(), 10L, O_OL_CNT, 1L).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, orders.asScalarLong());
    // Insert an order line for this order
    VoltTable line = client.callProcedure("InsertOrderLine", O_ID, D_ID, W_ID, 1L, I_ID, W_ID, new TimestampType(), 1L, 1.0, "ol_dist_info").getResults()[0];
    assertEquals(1L, line.asScalarLong());
    VoltTable newOrder = client.callProcedure("InsertNewOrder", O_ID, D_ID, W_ID).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, newOrder.asScalarLong());
    System.out.println("DATA before DELIVERY transaction");
    TPCDataPrinter.printAllData(client);
    VoltTable[] results = client.callProcedure("delivery", W_ID, 10, new TimestampType()).getResults();
    System.out.println("DATA after DELIVERY transaction");
    TPCDataPrinter.printAllData(client);
    assertEquals(1, results.length);
    assertEquals(1, results[0].getRowCount());
    VoltTableRow r = results[0].fetchRow(0);
    assertEquals(D_ID, r.getLong(0));
    assertEquals(O_ID, r.getLong(1));
}
Also used : TimestampType(org.voltdb.types.TimestampType) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Aggregations

TimestampType (org.voltdb.types.TimestampType)127 VoltTable (org.voltdb.VoltTable)37 BigDecimal (java.math.BigDecimal)30 Test (org.junit.Test)23 Client (org.voltdb.client.Client)19 ArrayList (java.util.ArrayList)16 IOException (java.io.IOException)11 GeographyValue (org.voltdb.types.GeographyValue)11 GeographyPointValue (org.voltdb.types.GeographyPointValue)10 Date (java.util.Date)9 File (java.io.File)7 VoltTableRow (org.voltdb.VoltTableRow)7 ProcCallException (org.voltdb.client.ProcCallException)7 ByteBuffer (java.nio.ByteBuffer)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)5 ClientResponse (org.voltdb.client.ClientResponse)5 Random (java.util.Random)4 VoltType (org.voltdb.VoltType)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2