Examples of VoltTableRow


Examples of org.voltdb.VoltTableRow

            throw new VoltAbortException("no customers with last name: " + c_last + " in warehouse: "
                    + c_w_id + " and in district " + c_d_id);
        }

        final int index = (namecnt-1)/2;
        final VoltTableRow customerIdRow = customersIds.fetchRow(index);
        final int c_id = (int)customerIdRow.getLong(C_ID_IDX);
       
        voltQueueSQL(getCustomersByCustomerId, c_id, c_d_id, c_w_id);
        final VoltTableRow customer = voltExecuteSQL()[0].fetchRow(0);
        return processPayment(w_id, d_id, c_w_id, c_d_id, c_id, h_amount, customer, timestamp);
    }
View Full Code Here

Examples of org.voltdb.VoltTableRow

        VoltTable customer = itemresults[item_id.length + 2];

        final double w_tax = itemresults[item_id.length].fetchRow(0).getDouble(0);
        final int D_TAX_COL = 0, D_NEXT_O_ID = 1;
        final int C_DISCOUNT = 0;
        final VoltTableRow tempRow = itemresults[item_id.length + 1].fetchRow(0);
        final double d_tax = tempRow.getDouble(D_TAX_COL);
        final double c_discount = itemresults[item_id.length + 2].fetchRow(0).getDouble(C_DISCOUNT);
        final long d_next_o_id = tempRow.getLong(D_NEXT_O_ID);
        final long ol_cnt = item_id.length;
        final long all_local = isAllLocal ? 1 : 0;

        voltQueueSQL(incrementNextOrderId, d_next_o_id + 1, d_id, w_id);
        voltQueueSQL(createOrder, d_next_o_id, d_id, w_id, c_id, timestamp,
                TPCCConstants.NULL_CARRIER_ID, ol_cnt, all_local);
        voltQueueSQL(createNewOrder, d_next_o_id, d_id, w_id);
        voltExecuteSQL();

        // values the client is missing: i_name, s_quantity, brand_generic, i_price, ol_amount
        final VoltTable item_data = item_data_template.clone(2048);

        for (int i = 0; i < item_id.length; ++i) {
            final long ol_number = i + 1;
            final long ol_supply_w_id = supware[i];
            final long ol_i_id = item_id[i];
            final long ol_quantity = quantity[i];

            assert stockresults[i].getRowCount() == 1 :
                String.format("%d rows were returned from STOCK for ITEM ; " +
                              "This should not happen with valid database (S_I_ID=%d / S_W_ID=%d)",
                              stockresults[i].getRowCount(), item_id[i], supware[i]);
            final VoltTableRow itemInfo = items[i];
            final VoltTableRow stockInfo = stockresults[i].fetchRow(0);

            final int I_PRICE = 0, I_NAME = 1, I_DATA = 2;
            final byte[] i_name = itemInfo.getStringAsBytes(I_NAME);
            final byte[] i_data = itemInfo.getStringAsBytes(I_DATA);
            final double i_price = itemInfo.getDouble(I_PRICE);

            final int S_QUANTITY = 0, S_DATA = 1, S_YTD = 2, S_ORDER_CNT = 3, S_REMOTE_CNT = 4, S_DIST_XX = S_REMOTE_CNT + d_id;
            long s_quantity = stockInfo.getLong(S_QUANTITY);
            long s_ytd = stockInfo.getLong(S_YTD);
            long s_order_cnt = stockInfo.getLong(S_ORDER_CNT);
            long s_remote_cnt = stockInfo.getLong(S_REMOTE_CNT);
            final byte[] s_data = stockInfo.getStringAsBytes(S_DATA);
            // Fetches data from the s_dist_[d_id] column
            final byte[] s_dist_xx = stockInfo.getStringAsBytes(S_DIST_XX);

            // Update stock
            s_ytd += ol_quantity;
            if (s_quantity >= ol_quantity + 10) {
                s_quantity = s_quantity - ol_quantity;
View Full Code Here

Examples of org.voltdb.VoltTableRow

        if (saveFileState.getRowCount() == 0)
        {
            String error = "No savefile state to restore";
            throw new IOException(error);
        }
        VoltTableRow a_row = saveFileState.fetchRow(0);
        m_clusterName = a_row.getString("CLUSTER");
        m_databaseName = a_row.getString("DATABASE");
        m_allowExport = allowExport;

        m_context = context;

        m_tableStateMap = new HashMap<String, TableSaveFileState>();
View Full Code Here

Examples of org.voltdb.VoltTableRow

    @Override
    public void reduce(Long key, Iterator<VoltTableRow> rows) {
        double sum_ol_amount = 0;
       
        VoltTableRow row = null;
        for (VoltTableRow r : CollectionUtil.iterable(rows)) {
            assert(r != null);
            row = r;
            sum_ol_amount += row.getDouble(3);
        } // FOR

        Object new_row[] = {
                key,
                row.getLong(1),
                row.getLong(2),
                sum_ol_amount,
                row.getTimestampAsTimestamp(4)
        };
        this.reduceEmit(new_row);
    }
View Full Code Here

Examples of org.voltdb.VoltTableRow

                continue;
            }
            assert otherresults[resultoffset + 0].getRowCount() == 1;
            assert otherresults[resultoffset + 1].getRowCount() == 1;
            final long c_id = (otherresults[resultoffset + 0].asScalarLong());
            final VoltTableRow row = otherresults[resultoffset + 1].fetchRow(0);
            final double ol_total = row.getDouble(0);
            final boolean ol_total_wasnull = row.wasNull();

            // If there are no order lines, SUM returns null. There should always be order lines.
            /* FIXME
            if (ol_total_wasnull) {
                throw new VoltAbortException(
View Full Code Here

Examples of org.voltdb.VoltTableRow

    }

    public VoltTable[] run(short w_id, byte d_id, double h_amount, short c_w_id, byte c_d_id, int c_id, TimestampType timestamp) {
        // assert (w_id == c_w_id); cross partition should be supported (at least in future)
        voltQueueSQL(getCustomersByCustomerId, c_id, c_d_id, c_w_id);
        final VoltTableRow customer = voltExecuteSQL()[0].fetchRow(0);
        return processPayment(w_id, d_id, c_w_id, c_d_id, c_id, h_amount, customer, timestamp);
    }
View Full Code Here

Examples of org.voltdb.VoltTableRow

        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));
    }
View Full Code Here

Examples of org.voltdb.VoltTableRow

                timestamp, items, warehouses, quantities).getResults();

        // Now to check returns are correct. We assume that inserts and such
        // within the actual transaction went through since it didn't rollback
        // and error out.
        VoltTableRow customerData = neworder[0].fetchRow(0);
        VoltTableRow miscData = neworder[1].fetchRow(0);
        assertEquals("Name", customerData.getString("C_LAST"));
        assertEquals("GC", customerData.getString("C_CREDIT"));
        assertEquals(.13, customerData.getDouble("C_DISCOUNT"));
        assertEquals(W_TAX, miscData.getDouble("w_tax"));
        assertEquals(D_TAX, miscData.getDouble("d_tax"));
        assertEquals(21L, miscData.getLong("o_id"));
        final double AMOUNT = PRICE * (3 + 5 + 1) * (1 - C_DISCOUNT) * (1 + D_TAX + W_TAX);
        assertEquals(AMOUNT, miscData.getDouble("total"), 0.001);

        // Check each item
        VoltTable itemResults = neworder[2];
        assertEquals(quantities.length, itemResults.getRowCount());
        for (int i = 0; i < itemResults.getRowCount(); ++i) {
            VoltTableRow itemRow = itemResults.fetchRow(i);
            assertEquals("ITEM" + (i + 1), itemRow.getString("i_name"));
            //~ assertEquals(quantities[i], itemRow.getLong("));
            long expected = s_quantities[i] - quantities[i];
            if (expected < 10) expected += 91;
            assertEquals(expected, itemRow.getLong("s_quantity"));
            if (i == 1) {
                assertEquals("B", itemRow.getString("brand_generic"));
            } else {
                assertEquals("G", itemRow.getString("brand_generic"));
            }
            assertEquals(PRICE, itemRow.getDouble("i_price"));
            assertEquals(PRICE * quantities[i], itemRow.getDouble("ol_amount"));
        }

        // verify that stock was updated correctly
        VoltTable[] allTables = client.callProcedure("SelectAll").getResults();
        VoltTable stock = allTables[TPCDataPrinter.nameMap.get("STOCK")];
        for (int i = 0; i < stock.getRowCount(); ++i) {
            VoltTableRow stockRow = stock.fetchRow(i);
            assertEquals(INITIAL_S_YTD + i*10 + quantities[i], stockRow.getLong("S_YTD"));
            assertEquals(INITIAL_S_ORDER_CNT + i*10 + 1, stockRow.getLong("S_ORDER_CNT"));
        }

        // New order with a missing item
        items = new int[] { Constants.NUM_ITEMS + 1 };
        warehouses = new short[] { W_ID };
View Full Code Here

Examples of org.voltdb.VoltTableRow

        VoltTable result = client.callProcedure(
                "@AdHoc", "select * FROM R1 LEFT JOIN R2 ON R1.A = R2.C")
                                 .getResults()[0];
        System.out.println(result.toString());
        assertEquals(4, result.getRowCount());
        VoltTableRow row = result.fetchRow(2);
        assertEquals(2, row.getLong(1));

        client.callProcedure("InsertR2", 1, 1);
        client.callProcedure("InsertR2", 1, 3);
        client.callProcedure("InsertR2", 3, null);
        // R1 1st joined with R2 1st
View Full Code Here

Examples of org.voltdb.VoltTableRow

        // R2 3rd joined with R3 null
        // R2 4th joined with R3 null
        VoltTable result = client.callProcedure(
                "@AdHoc", "select * FROM R2 LEFT JOIN R3 ON R3.A = R2.A")
                                 .getResults()[0];
        VoltTableRow row = result.fetchRow(2);
        assertEquals(3, row.getLong(1));
        System.out.println(result.toString());
        assertEquals(4, result.getRowCount());

        client.callProcedure("InsertR3", 1, 1);
        client.callProcedure("InsertR3", 2, 2);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.