Search in sources :

Example 16 with TimestampType

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

the class TestTPCCSuite method testPAYMENTMultiPartition.

public void testPAYMENTMultiPartition() throws IOException, ProcCallException {
    Client client = getClient();
    // create 2 Districts, 2 Warehouses, and 2 Customers on each Warehouse/District
    // 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
    final double initialYTD = 15241.45;
    VoltTable district1 = client.callProcedure("InsertDistrict", D_ID, W_ID, "A District", "Street Addy", "meh", "westerfield", "BA", "99999", .0825, initialYTD, 21L).getResults()[0];
    // check that a district was inserted
    assertEquals(1L, district1.asScalarLong());
    VoltTable district2 = client.callProcedure("InsertDistrict", D2_ID, W2_ID, "fdsdfaaaaa", "fsdfsdfasas", "fda", "asdasfddsds", "MA", "99999", .0825, initialYTD, 21L).getResults()[0];
    assertEquals(1L, district2.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 warehouse1 = client.callProcedure("InsertWarehouse", W_ID, "EZ Street WHouse", "Headquarters", "77 Mass. Ave.", "Cambridge", "AZ", "12938", .1234, initialYTD).getResults()[0];
    // check for successful insertion.
    assertEquals(1L, warehouse1.asScalarLong());
    VoltTable warehouse2 = client.callProcedure("InsertWarehouse", W2_ID, "easdsdfsdfddfdsd", "asfadasffass", "fdswwwwaafff", "Cambridge", "AZ", "12938", .1234, initialYTD).getResults()[0];
    assertEquals(1L, warehouse2.asScalarLong());
    // customer 1 and 2 are in district1, 3 and 4 are in district2
    // 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;
    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());
    client.callProcedure("InsertCustomerName", C_ID, D_ID, W_ID, "I", "lastname");
    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());
    client.callProcedure("InsertCustomerName", C_ID + 1, D_ID, W_ID, "We", "Customer");
    VoltTable customer3 = client.callProcedure("InsertCustomer", C_ID + 2, D2_ID, W2_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());
    client.callProcedure("InsertCustomerName", C_ID + 2, D2_ID, W2_ID, "Who", "Customer");
    VoltTable customer4 = client.callProcedure("InsertCustomer", C_ID + 3, D2_ID, W2_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());
    client.callProcedure("InsertCustomerName", C_ID + 3, D2_ID, W2_ID, "ICanBe", "Customer");
    final double paymentAmount = 500.25;
    // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
    // long c_d_id
    // w_id =Warehouse2 but c_w_id=warehouse1 !
    VoltTable[] results = client.callProcedure("paymentByCustomerName", W2_ID, D2_ID, paymentAmount, W_ID, D_ID, "Customer", new TimestampType()).getResults();
    assertEquals(3, results.length);
    assertTrue(results[0].getRowCount() > 0);
    // only customer2 should be returned as this is a query on warehouse1
    assertEquals(C_ID + 1, results[2].fetchRow(0).getLong("c_id"));
    assertEquals("", results[2].fetchRow(0).getString("c_data"));
    /* TODO : SelectAll doesn't work for multi-partition. how to check results?
        // Verify that both warehouse, district and customer were updated
        // correctly
        VoltTable[] allTables = client.callProcedure("SelectAll");
        warehouse = allTables[TPCDataPrinter.nameMap.get("WAREHOUSE")];
        assertEquals(1, warehouse.getRowCount());
        assertEquals(initialYTD + paymentAmount, warehouse.fetchRow(0)
                .getDouble("W_YTD"));
        district = allTables[TPCDataPrinter.nameMap.get("DISTRICT")];
        assertEquals(1, district.getRowCount());
        assertEquals(initialYTD + paymentAmount, district.fetchRow(0)
                .getDouble("D_YTD"));
        customer1 = allTables[TPCDataPrinter.nameMap.get("CUSTOMER")];
        assertEquals(4, customer1.getRowCount());
        assertEquals(C_ID + 1, customer1.fetchRow(1).getLong("C_ID"));
        assertEquals(initialBalance - paymentAmount, customer1.fetchRow(1)
                .getDouble("C_BALANCE"));
        assertEquals(initialYTD + paymentAmount, customer1.fetchRow(1)
                .getDouble("C_YTD_PAYMENT"));
        assertEquals(2, customer1.fetchRow(1).getLong("C_PAYMENT_CNT"));
        */
    // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
    // long c_d_id
    // w_id =Warehouse2 but c_w_id=warehouse1 !
    results = client.callProcedure("paymentByCustomerId", W2_ID, D2_ID, paymentAmount, W_ID, D_ID, C_ID, new TimestampType()).getResults();
    // Also tests badcredit case.
    assertEquals(3, results.length);
    assertEquals(C_ID, results[2].fetchRow(0).getLong("c_id"));
    // bad credit: insert history into c_data
    String data = results[2].fetchRow(0).getString("c_data");
    assertTrue(data.startsWith(new Long(C_ID).toString()));
/* TODO : SelectAll doesn't work for multi-partition. how to check results?
        // Verify that both warehouse and district's ytd values were incremented
        // correctly
        allTables = client.callProcedure("SelectAll");
        warehouse = allTables[TPCDataPrinter.nameMap.get("WAREHOUSE")];
        assertEquals(1, warehouse.getRowCount());
        assertEquals(initialYTD + paymentAmount * 2, warehouse.fetchRow(0)
                .getDouble("W_YTD"));
        district = allTables[TPCDataPrinter.nameMap.get("DISTRICT")];
        assertEquals(1, district.getRowCount());
        assertEquals(initialYTD + paymentAmount * 2, district.fetchRow(0)
                .getDouble("D_YTD"));
        customer1 = allTables[TPCDataPrinter.nameMap.get("CUSTOMER")];
        assertEquals(4, customer1.getRowCount());
        assertEquals(C_ID, customer1.fetchRow(0).getLong("C_ID"));
        assertEquals(initialBalance - paymentAmount, customer1.fetchRow(1)
                .getDouble("C_BALANCE"));
        assertEquals(initialYTD + paymentAmount, customer1.fetchRow(1)
                .getDouble("C_YTD_PAYMENT"));
        assertEquals(1, customer1.fetchRow(0).getLong("C_PAYMENT_CNT"));
        */
}
Also used : TimestampType(org.voltdb.types.TimestampType) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable)

Example 17 with TimestampType

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

the class TestCSVLoader method testUpsertSameBatch.

//Test using Upsert instead of insert.
// In the same batch, upsert allows lines with same primary key
@Test
public void testUpsertSameBatch() throws Exception {
    String[] myOptions = { "-f" + path_csv, "--reportdir=" + reportDir, "--maxerrors=50", "--user=", "--password=", "--port=", "--separator=,", "--quotechar=\"", "--escape=\\", "--skip=0", "--limitrows=100", "--update", "BlAh" };
    String currentTime = new TimestampType().toString();
    String[] myData = { "1 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"", "2,2,2,222222,second,3.30,NULL," + currentTime + ",POINT(2 2),\"POLYGON((0 0, 2 0, 0 2, 0 0))\"", "3,3,3,333333, third ,NULL, 3.33," + currentTime + ",POINT(3 3),\"POLYGON((0 0, 3 0, 0 3, 0 0))\"", // this should not fail:
    "2,4,4,444444, NULL ,4.40 ,4.44," + currentTime + ",POINT(4 4),\"POLYGON((0 0, 4 0, 0 4, 0 0))\"", // this should not fail, and should exist in the table:
    "2,5,5,5555555,  \"abcde\"g, 5.50, 5.55," + currentTime + ",POINT(5 5),\"POLYGON((0 0, 5 0, 0 5, 0 0))\"", // this should not fail, and should exist in the table:
    "1,6,NULL,666666, sixth, 6.60, 6.66," + currentTime + ",POINT(6 6),\"POLYGON((0 0, 6 0, 0 6, 0 0))\"" };
    String[] myValidTableData = { "3,3,3,333333, third ,NULL, 3.33," + currentTime + ",POINT(3 3),\"POLYGON((0 0, 3 0, 0 3, 0 0))\"", "2,5,5,5555555,  \"abcde\"g, 5.50, 5.55," + currentTime + ",POINT(5 5),\"POLYGON((0 0, 5 0, 0 5, 0 0))\"", "1,6,NULL,666666, sixth, 6.60, 6.66," + currentTime + ",POINT(6 6),\"POLYGON((0 0, 6 0, 0 6, 0 0))\"" };
    int invalidLineCnt = 0;
    int validLineCnt = myData.length;
    int validUpsertLineCnt = 3;
    test_Interface(myOptions, myData, invalidLineCnt, validLineCnt, validUpsertLineCnt, myValidTableData);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Test(org.junit.Test)

Example 18 with TimestampType

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

the class TestCSVLoader method testBatchOptionThatSplitsAndGetsViolationsAndDataIsSmall.

//Test batch option that splits and gets constraint violations.
@Test
public void testBatchOptionThatSplitsAndGetsViolationsAndDataIsSmall() throws Exception {
    String[] myOptions = { "-f" + path_csv, "--reportdir=" + reportDir, "--maxerrors=50", "--user=", "--password=", "--port=", "--separator=,", "--quotechar=\"", "--escape=\\", "--skip=0", "--limitrows=100", //Batch size is small so we dont have to generate large dataset.
    "--batch=2", "BlAh" };
    String currentTime = new TimestampType().toString();
    String[] myData = { "1 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"", "2 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"", "2 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"", "1 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"" };
    int invalidLineCnt = 2;
    int validLineCnt = 2;
    test_Interface(myOptions, myData, invalidLineCnt, validLineCnt);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Test(org.junit.Test)

Example 19 with TimestampType

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

the class TestCSVLoader method testHeaderColumnNumNotSame.

@Test
public void testHeaderColumnNumNotSame() throws Exception {
    String[] myOptions = { "-f" + path_csv, "--reportdir=" + reportDir, "--maxerrors=50", "--user=", "--password=", "--port=", "--separator=,", "--quotechar=\"", "--escape=\\", "--limitrows=100", "--header", "BlAh" };
    String currentTime = new TimestampType().toString();
    String[] myData = { "clm_integer,clm_tinyint,clm_smallint,clm_bigint,clm_string,clm_decimal,clm_float,clm_timestamp,clm_point,clm_geography,clm_other", "1 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\"", "2,2,2,222222,second,3.30,NULL," + currentTime + ",POINT(2 2),\"POLYGON((0 0, 2 0, 0 2, 0 0))\"", "3,3,3,333333, third ,NULL, 3.33," + currentTime + ",POINT(3 3),\"POLYGON((0 0, 3 0, 0 3, 0 0))\"", "4,4,4,444444, NULL ,4.40 ,4.44," + currentTime + ",POINT(4 4),\"POLYGON((0 0, 4 0, 0 4, 0 0))\"", "5,5,5,5555555,  \"abcde\"g, 5.50, 5.55," + currentTime + ",POINT(5 5),\"POLYGON((0 0, 5 0, 0 5, 0 0))\"", "6,6,NULL,666666, sixth, 6.60, 6.66," + currentTime + ",POINT(6 6),\"POLYGON((0 0, 6 0, 0 6, 0 0))\"", "7,NULL,7,7777777, seventh, 7.70, 7.77," + currentTime + ",POINT(7 7),\"POLYGON((0 0, 7 0, 0 7, 0 0))\"", "11, 1,1,\"1,000\",first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 8 0, 0 8, 0 0))\"" };
    int invalidLineCnt = 8;
    int validLineCnt = 0;
    test_Interface(myOptions, myData, invalidLineCnt, validLineCnt);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Test(org.junit.Test)

Example 20 with TimestampType

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

the class TestCSVLoader method testHeaderColumnWhitespace2.

@Test
public void testHeaderColumnWhitespace2() throws Exception {
    // ENG-12324: csvloader --header doesn't work if header has spaces. This is essentially the same test as testHeaderColumnNumNotSame, but with some
    // strategically placed whitespace in the header.
    String[] myOptions = { "-f" + path_csv, "--reportdir=" + reportDir, "--maxerrors=50", "--user=", "--password=", "--port=", "--separator=,", "--quotechar=\"", "--escape=\\", "--limitrows=100", "--header", "BlAh" };
    String currentTime = new TimestampType().toString();
    String[] myData = { "  clm_integer, clm_tinyint,clm_smallint,  clm_bigint  ,clm_string,clm_decimal,clm_float  , clm_timestamp,clm_point ,clm_geography", "1 ,1,1,11111111,first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 1 0, 0 1, 0 0))\",garbage", "2,2,2,222222,second,3.30,NULL," + currentTime + ",POINT(2 2),\"POLYGON((0 0, 2 0, 0 2, 0 0))\"", "3,3,3,333333, third ,NULL, 3.33," + currentTime + ",POINT(3 3),\"POLYGON((0 0, 3 0, 0 3, 0 0))\"", "4,4,4,444444, NULL ,4.40 ,4.44," + currentTime + ",POINT(4 4),\"POLYGON((0 0, 4 0, 0 4, 0 0))\"", "5,5,5,5555555,  \"abcde\"g, 5.50, 5.55," + currentTime + ",POINT(5 5),\"POLYGON((0 0, 5 0, 0 5, 0 0))\"", "6,6,NULL,666666, sixth, 6.60, 6.66," + currentTime + ",POINT(6 6),\"POLYGON((0 0, 6 0, 0 6, 0 0))\"", "7,NULL,7,7777777, seventh, 7.70, 7.77," + currentTime + ",POINT(7 7),\"POLYGON((0 0, 7 0, 0 7, 0 0))\"", "11, 1,1,\"1,000\",first,1.10,1.11," + currentTime + ",POINT(1 1),\"POLYGON((0 0, 8 0, 0 8, 0 0))\"" };
    int invalidLineCnt = 1;
    int validLineCnt = 7;
    test_Interface(myOptions, myData, invalidLineCnt, validLineCnt);
}
Also used : TimestampType(org.voltdb.types.TimestampType) Test(org.junit.Test)

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