Package org.voltdb

Examples of org.voltdb.VoltTable$Row


        }
    }

    /** select A1, sum(A1) from T1 group by A1 */
    public void testSelectSumAGroupbyA() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = this.getClient();
        loaderNxN(client, 0);

        String qs = "select A1, sum(A1) from T1 group by A1";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testSelectSumAGroupbyA result: " + vt);
        assertEquals(11, vt.getRowCount());

        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
            Integer a1 = (Integer) vt.get(0, VoltType.INTEGER);
            Integer sum = (Integer) vt.get(1, VoltType.INTEGER);
            found[a1.intValue()] += 1;
            // A1 = 11 is a special case
            if (a1.intValue() == 11)
                assertEquals(11, sum.intValue());
            // every other n appears n times. The sum is therefore n x n.
View Full Code Here


            assertEquals(found[i], 1)// one result for each unique A1
    }

    /** select count(distinct A1) from T1 */
    public void testSelectCountDistinct() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = getClient();
        loaderNxN(client, 0);
        vt = client
        .callProcedure("@AdHoc", "select count(distinct A1) from T1").getResults()[0];
        assertTrue(vt.getRowCount() == 1);

        // there are 11 distinct values for A1
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertEquals(11, A1.intValue());
        }
    }
View Full Code Here

        }
    }

    /** select count(A1) from T1 */
    public void testSelectCount() throws IOException, ProcCallException {
        VoltTable vt;
        Client client = getClient();
        loaderNxN(client, 0);
        vt = client.callProcedure("@AdHoc", "select count(A1) from T1").getResults()[0];
        assertTrue(vt.getRowCount() == 1);

        // there are 56 rows in the table 1 + 2 + 3 + .. + 10 + 1
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
            System.out.println("select count = " + A1.intValue());
            assertEquals(56, A1.intValue());
        }
    }
View Full Code Here

    }

    /** select distinct a1 from t1 */
    public void testSelectDistinctA() throws IOException, ProcCallException {
        Client client = this.getClient();
        VoltTable vt;

        loaderNxN(client, 0);

        vt = client.callProcedure("@AdHoc", "select distinct a1 from t1").getResults()[0];
        System.out.println("testSelectDistinctA result row("
                + vt.getColumnName(0) + ") " + vt);

        // valid result is the set {1,2,...,11}
        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
            Integer A1 = (Integer) vt.get(0, VoltType.INTEGER);
            System.out.println("\tdistinct value: " + A1.intValue());
            assertEquals("A1", vt.getColumnName(0));
            assertTrue(A1 <= 11);
            assertTrue(A1 > 0);
            found[A1.intValue()] += 1;
        }
        assertEquals(0, found[0]);
View Full Code Here

     * distributed sums of a partitioned table
     * select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F
     * @throws InterruptedException
     */
    public void testDistributedSum() throws IOException, ProcCallException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        String qs = "select sum(F_VAL1), sum(F_VAL2), sum(F_VAL3) from F";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSum result: " + vt);
        assertTrue(vt.getRowCount() == 1);
        while (vt.advanceRow()) {
            Integer sum1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertEquals(2000, sum1.intValue());
            Integer sum2 = (Integer) vt.get(1, VoltType.INTEGER);
            assertEquals(4995000, sum2.intValue());
            Integer sum3 = (Integer) vt.get(2, VoltType.INTEGER);
            assertEquals(500, sum3.intValue());
        }
    }
View Full Code Here

     * distributed sums of a view
     * select sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) from V
     * @throws InterruptedException
     */
    public void testDistributedSum_View() throws IOException, ProcCallException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        // FIXME String qs = "select sum(V.SUM_v1), sum(V.SUM_V2), sum(V.SUM_V3) from V";
        String qs = "select sum(V.SUM_v1), sum(V.SUM_V2) from V";

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSum_View result: " + vt);
        assertTrue(vt.getRowCount() == 1);
        while (vt.advanceRow()) {
            Integer sum1 = (Integer) vt.get(0, VoltType.INTEGER);
            assertEquals(2000, sum1.intValue());
            Integer sum2 = (Integer) vt.get(1, VoltType.INTEGER);
            assertEquals(4995000, sum2.intValue());
            // FIXME Integer sum3 = (Integer) vt.get(2, VoltType.INTEGER);
            // FIXME assertEquals(500, sum3.intValue());
        }
    }
View Full Code Here

     * from V group by V.V_D1_PKEY
     * @throws InterruptedException
     */
    public void testDistributedSumAndGroup() throws NoConnectionsException,
    ProcCallException, IOException, InterruptedException {
        VoltTable vt;
        Client client = getClient();
        loadF(client, 0);

        // FIXME String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2), sum(V.SUM_V3) "
//            + "from V group by V.V_D1_PKEY";
        String qs = "select V.V_D1_PKEY, sum(V.SUM_V1), sum(V.SUM_V2) "
                + "from V group by V.V_D1_PKEY";
       

        vt = client.callProcedure("@AdHoc", qs).getResults()[0];
        System.out.println("testDistributedSumAndJoin result: " + vt);
        assert (vt.getRowCount() == 10); // 10 unique values for dim1 which is
        // the grouping col

        int found[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        while (vt.advanceRow()) {
            Integer d1 = (Integer) vt.get(0, VoltType.INTEGER);
            Integer s1 = (Integer) vt.get(1, VoltType.INTEGER);
            Integer s2 = (Integer) vt.get(2, VoltType.INTEGER);
            // FIXME Integer s3 = (Integer) vt.get(3, VoltType.INTEGER);

            // track that 10 dim1s are in the final group
            found[d1.intValue()] += 1;
            // sum1 is const 2. 100 dim1 instances / group
View Full Code Here

        "UPDATE TABLEA SET A_VALUE = ? WHERE A_ID = ?"
    );
   
    public VoltTable[] run(long a_id, long sleep) {
        voltQueueSQL(getLocal, a_id);
        final VoltTable a_results[] = voltExecuteSQL();
        assert(a_results.length == 1);

        System.err.printf("Sleeping for %.01f seconds\n", sleep / 1000d);
        ThreadUtil.sleep(sleep);
        System.err.println("Awake!");
       
        voltQueueSQL(getRemote, a_id);
        final VoltTable b_results[] = voltExecuteSQL();
        assert(b_results.length == 1);
        long sum = b_results[0].asScalarLong();
       
        voltQueueSQL(updateLocal, sum, a_id);
        return (voltExecuteSQL(true));
View Full Code Here

        System.err.printf("Sleeping for %.01f seconds\n", sleep / 1000d);
        ThreadUtil.sleep(sleep);
        System.err.println("Awake!");
       
        voltQueueSQL(getLocal, a_id);
        final VoltTable a_results[] = voltExecuteSQL();
        assert(a_results.length == 1);
        return (a_results);
    }
View Full Code Here

    public VoltTable[] run()
    {
        voltQueueSQL(insertBingoBoard, 0, 0, "INITIAL VALUE");
        voltQueueSQL(insertBingoBoard, 0, 1, "INITIAL VALUE");
        VoltTable results[] = voltExecuteSQL();
        if (results == null || results.length == 0) {
            return new VoltTable[0];
        }
        if (results[0].asScalarLong() != 1 ||
                results[1].asScalarLong() != 1) {
View Full Code Here

TOP

Related Classes of org.voltdb.VoltTable$Row

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.