Package org.voltdb.client

Examples of org.voltdb.client.Client


                                     4,
                                     2.0};
        String[] tables = {"P1", "R1"};
       
        for (String table : tables) {
            Client client = getClient();
            for (int i = 0; i < ROWS; ++i) {
                client.callProcedure("Insert", table, i, "desc",
                                     new BigDecimal(10.0), i / 2, 14.5);
            } // FOR
       
            String query = "SELECT ";
            for (int i = 0; i < aggs.length; ++i) {
                if (i > 0) query += ", ";
                query += String.format("%s(%s.NUM)", aggs[i], table);
            } // FOR
            query += "FROM " + table;
           
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(1, results.length);
            assertEquals(1, results[0].getRowCount());
            assertTrue(results[0].advanceRow());
            for (int i = 0; i < aggs.length; ++i) {
                // Do avg separately since the column is a float
View Full Code Here


                                   0,
                                   4};
        String[] tables = {"P1", "R1"};
        for (String table : tables)
        {
            Client client = getClient();
            for (int i = 0; i < ROWS; ++i)
            {
                client.callProcedure("Insert", table, i, "desc",
                                     new BigDecimal(10.0), i / 2, 14.5);
            }
            for (int i = 0; i < aggs.length; ++i)
            {
                String query = String.format("select %s(%s.NUM) from %s",
                                             aggs[i], table, table);
                VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
                assertEquals(expected_results[i], results[0].asScalarLong());
            }
            // Do avg separately since the column is a float and makes
            // asScalarLong() unhappy
            String query = String.format("select avg(%s.NUM) from %s",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            results[0].advanceRow();
            assertEquals(2.0,
                         ((Number)results[0].get(0, results[0].getColumnType(0))).doubleValue());
        }
    }
View Full Code Here

    public void testAggregatesOnEmptyTable() throws IOException, ProcCallException {
        String[] aggs = {"count", "sum", "min", "max"};
        String[] tables = {"P1", "R1"};
        for (String table : tables)
        {
            Client client = getClient();
            for (int i = 0; i < aggs.length; ++i)
            {
                String query = String.format("select %s(%s.NUM) from %s",
                                             aggs[i], table, table);
                VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
                if (aggs[i].equals("count")) {
                    assertEquals(0, results[0].asScalarLong());
                } else {
                    final VoltTableRow row = results[0].fetchRow(0);
                    row.get(0, results[0].getColumnType(0));
                    if (!isHSQL()) {
                        assertTrue(row.wasNull());
                    }
                }
            }
            // Do avg separately since the column is a float and makes
            // asScalarLong() unhappy
            String query = String.format("select avg(%s.NUM) from %s",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            results[0].advanceRow();
            @SuppressWarnings("unused")
            final double value = ((Number)results[0].get(0, results[0].getColumnType(0))).doubleValue();
            if (!isHSQL()) {
                assertTrue(results[0].wasNull());
View Full Code Here

    throws IOException, ProcCallException
    {
        String[] tables = {"P1", "R1"};
        for (String table : tables)
        {
            Client client = getClient();
            for (int i = 0; i < ROWS; ++i)
            {
                client.callProcedure("Insert", table, i, String.valueOf(i),
                                     new BigDecimal(10.0), i / 2, 14.5);
            }
            for (int i = ROWS; i < ROWS + 5; ++i)
            {
                client.callProcedure("Insert", table, i, VoltType.NULL_STRING,
                                     new BigDecimal(10.0), i / 2, 14.5);
            }
            String query = String.format("select MIN(%s.DESC) from %s",
                                         table, table);
            VoltTable[] results = client.callProcedure("@AdHoc", query).getResults();
            results[0].advanceRow();
            assertEquals("0", results[0].getString(0));
            query = String.format("select MAX(%s.DESC) from %s",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            results[0].advanceRow();
            assertEquals("9", results[0].getString(0));
            query = String.format("select COUNT(%s.DESC) from %s",
                                  table, table);
            results = client.callProcedure("@AdHoc", query).getResults();
            assertEquals(ROWS, results[0].asScalarLong());
        }
    }
View Full Code Here

       
        System.out.println("Starting testYCSB - Physical Recovery");               
      
        VoltTable results[] = null;
        ClientResponse cresponse = null;
        Client client = this.getClient();
        CatalogContext cc = this.getCatalogContext();      

        // Load database       
        try{
            //initializeYCSBDatabase(cc, client, YCSBConstants.NUM_RECORDS);
            initializeYCSBDatabase(cc, client, 10000);
        }
        catch(Exception e){
            e.printStackTrace();
        }       
       
        final String MOCK_ARGS[] = { "HOST=localhost", "NUMCLIENTS=1",
                // XXX HACK to find catalog jar
                "CATALOG=" + "./obj/release/testobjects/" + projectJAR, "" };

        MOCK_ARGS[MOCK_ARGS.length - 1] = HStoreConstants.BENCHMARK_PARAM_PREFIX;

        YCSBClient yscbClient = new YCSBClient(MOCK_ARGS);

        // Run transactions
        long k_itr = 0;
        long numTransactions = NUM_TRANSACTIONS;
        long period = numTransactions / 10;

        for (k_itr = 0; k_itr < numTransactions; k_itr++) {
            boolean response = yscbClient.runOnce();
            assertEquals(response, true);

            if (k_itr % period == 0)
                System.out.println(String.format("Transactions Processed: %6d / %d", k_itr, numTransactions));
        }           
               
        // Statistics
        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println("@Statistics before RESTART :");              
        System.out.println(results[0]);       
       
        // Kill and restart all the execution sites.
        m_config.shutDown();
        m_config.startUp();
        client = getClient();       

        results = client.callProcedure("@Statistics", "table", 0).getResults();
        System.out.println("@Statistics after PHYSICAL restore :");
        System.out.println(results[0]);     
       
        //checkYCSBTable(client, NUM_TUPLES);             
View Full Code Here

        // This checks that we get the execution order of queries correct.
        // In a single query batch we will first execute an update on a replicated
        // table and then execute a second query that will read from that table. The
        // second query should get the new value from the first query and not the
        // original value.
        Client client = this.getClient();
        CatalogContext catalogContext = this.getCatalogContext();
        Table catalog_tbl = catalogContext.getTableByName(TPCCConstants.TABLENAME_ITEM);
        assertTrue(catalog_tbl.getIsreplicated());
        int expectedNumItems = 10;
        VoltTable vt = CatalogUtil.getVoltTable(catalog_tbl);
        for (int i = 0; i < expectedNumItems; i++) {
            Object row[] = VoltTableUtil.getRandomRow(catalog_tbl);
            row[0] = i;
            vt.addRow(row);
        } // FOR
        RegressionSuiteUtil.load(client, catalog_tbl, vt);
       
        long numItems = RegressionSuiteUtil.getRowCount(client, catalog_tbl);
        assertEquals(expectedNumItems, numItems);
       
        String procName = UpdateItemName.class.getSimpleName();
        long itemId = this.getRandom().number(TPCCConstants.STARTING_ITEM, numItems);
        String itemName = "Tone Loc";
        ClientResponse cr = client.callProcedure(procName, itemId, itemName);
        assertEquals(cr.toString(), Status.OK, cr.getStatus());
        assertEquals(cr.toString(), 1, cr.getResults().length);
        try {
            if(cr.getResults()[0].getRowCount() != 0){
                assertTrue(cr.toString(), cr.getResults()[0].advanceRow());
View Full Code Here

        }       
    }
   
    public void testUpdates() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        Client client = getClient();

        try {
            client.callProcedure("InsertOrderLine", 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1.5, "poo");
            client.callProcedure("UpdateTests", 1L);
            VoltTable[] results = client.callProcedure("FeaturesSelectAll").getResults();

            assertEquals(5, results.length);

            // get the order line table
            VoltTable table = results[2];
View Full Code Here

        }
    }

    public void testSelfJoins() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        Client client = getClient();

        try {
            client.callProcedure("InsertNewOrder", 1L, 3L, 1L);
            VoltTable[] results = client.callProcedure("SelfJoinTest", 1L).getResults();

            assertEquals(results.length, 1);

            // get the new order table
            VoltTable table = results[0];
View Full Code Here

    }

    /** Verify that non-latin-1 characters can be stored and retrieved */
    public void testUTF8Storage() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        Client client = getClient();
        final String testString = "並丧";
        try {
            client.callProcedure("InsertOrderLine", 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1.5, testString);
            VoltTable[] results = client.callProcedure("FeaturesSelectAll").getResults();

            assertEquals(5, results.length);

            // get the order line table
            VoltTable table = results[2];
View Full Code Here

    }

    /** Verify that non-latin-1 characters can be used in expressions */
    public void testUTF8Predicate() throws IOException {
        System.err.println("CURRENT: " + ClassUtil.getCurrentMethodName());
        Client client = getClient();
        final String testString = "袪被";
        try {
            // Intentionally using a one byte string to make sure length preceded strings are handled correctly in the EE.
            client.callProcedure("InsertOrderLine", 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1.5, "a");
            client.callProcedure("InsertOrderLine", 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1.5, testString);
            client.callProcedure("InsertOrderLine", 3L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 1.5, "def");
            VoltTable[] results = client.callProcedure("SelectOrderLineByDistInfo", testString).getResults();
            assertEquals(1, results.length);
            VoltTable table = results[0];
            assertTrue(table.getRowCount() == 1);
            VoltTableRow row = table.fetchRow(0);
            String resultString = row.getString("OL_DIST_INFO");
View Full Code Here

TOP

Related Classes of org.voltdb.client.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.