Package org.voltdb

Examples of org.voltdb.VoltTable


     * 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

        " WHERE custid = ?"
    );
 
    public VoltTable run(long acctId) {
        voltQueueSQL(GetAccount, acctId);
        VoltTable results[] = voltExecuteSQL();
       
        if (results[0].getRowCount() != 1) {
            String msg = "Invalid account '" + acctId + "'";
            throw new VoltAbortException(msg);
        }
        // long acctId = results[0].asScalarLong();
       
        voltQueueSQL(GetSavingsBalance, acctId);
        voltQueueSQL(GetCheckingBalance, acctId);
        results = voltExecuteSQL(true);
       
        if (results[0].getRowCount() != 1) {
            String msg = String.format("No %s for customer #%d",
                                       SmallBankConstants.TABLENAME_SAVINGS,
                                       acctId);
            throw new VoltAbortException(msg);
        }
        if (results[1].getRowCount() != 1) {
            String msg = String.format("No %s for customer #%d",
                                       SmallBankConstants.TABLENAME_CHECKING,
                                       acctId);
            throw new VoltAbortException(msg);
        }
        results[0].advanceRow();
        results[1].advanceRow();
        double total = results[0].getDouble(0) + results[1].getDouble(0);
       
        final VoltTable finalResult = new VoltTable(RESULT_COLS);
        finalResult.addRow(total);
        return (finalResult);
    }
View Full Code Here

        " WHERE custid = ?"
    );
   
    public VoltTable run(long acctId, double amount) {
        voltQueueSQL(GetAccount, acctId);
        VoltTable results[] = voltExecuteSQL();
       
        if (results[0].getRowCount() != 1) {
            String msg = "Invalid account '" + acctId + "'";
            LOG.error(msg);
            throw new VoltAbortException(msg);
View Full Code Here

   
    public VoltTable[] run(long sendAcct, long destAcct, double amount) {
        // Get Account Information
        voltQueueSQL(GetAccount, sendAcct);
        voltQueueSQL(GetAccount, destAcct);
        final VoltTable acctResults[] = voltExecuteSQL();
        if (acctResults[0].getRowCount() != 1) {
            String msg = "Invalid sender account '" + sendAcct + "'";
            LOG.error(this.getTransactionState() + " - " + msg + " / hash=" + TheHashinator.hashToPartition(sendAcct));
            throw new VoltAbortException(msg);
        }
        else if (acctResults[1].getRowCount() != 1) {
            String msg = "Invalid destination account '" + destAcct + "'";
            LOG.error(this.getTransactionState() + " - " + msg + " / hash=" + TheHashinator.hashToPartition(destAcct));
            throw new VoltAbortException(msg);
        }
       
        // Get the sender's account balance
        voltQueueSQL(GetCheckingBalance, sendAcct);
        final VoltTable balResults[] = voltExecuteSQL();
        if (balResults[0].getRowCount() != 1) {
            String msg = String.format("No %s for customer #%d",
                                       SmallBankConstants.TABLENAME_SAVINGS,
                                       sendAcct);
            LOG.error(msg);
View Full Code Here

        " WHERE custid = ?"
    );
   
    public VoltTable run(long acctId, double amount) {
        voltQueueSQL(GetAccount, acctId);
        VoltTable results[] = voltExecuteSQL();
       
        if (results[0].getRowCount() != 1) {
            String msg = "Invalid account name '" + acctId + "'";
            throw new VoltAbortException(msg);
        }
View Full Code Here

        " WHERE custid = ?"
    );
   
    public VoltTable run(long acctId, double amount) {
        voltQueueSQL(GetAccount, acctId);
        VoltTable results[] = voltExecuteSQL();
       
        if (results[0].getRowCount() != 1) {
            String msg = "Invalid account name '" + acctId + "'";
            throw new VoltAbortException(msg);
        }
View Full Code Here

   
    public VoltTable run(long acctId0, long acctId1) {
        // Get Account Information
        voltQueueSQL(GetAccount, acctId1);
        voltQueueSQL(GetAccount, acctId0);
        final VoltTable acctResults[] = voltExecuteSQL();
        if (acctResults[0].getRowCount() != 1) {
            String msg = "Invalid account '" + acctId0 + "'\n" + acctResults[0];
            LOG.error(this.getTransactionState() + " - " + msg + " / hash=" + TheHashinator.hashToPartition(acctId0));
            throw new VoltAbortException(msg);
        }
        if (acctResults[1].getRowCount() != 1) {
            String msg = "Invalid account '" + acctId1 + "'\n" + acctResults[1];
            LOG.error(this.getTransactionState() + " - " + msg + " / hash=" + TheHashinator.hashToPartition(acctId1));
            throw new VoltAbortException(msg);
        }
       
        // Get Balance Information
        voltQueueSQL(GetSavingsBalance, acctId0);
        voltQueueSQL(GetCheckingBalance, acctId1);
        final VoltTable balResults[] = voltExecuteSQL();
        if (balResults[0].getRowCount() != 1) {
            String msg = String.format("No %s for customer #%d",
                                       SmallBankConstants.TABLENAME_SAVINGS,
                                       acctId0);
            LOG.error(msg);
View Full Code Here

TOP

Related Classes of org.voltdb.VoltTable

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.