Search in sources :

Example 16 with VoltTableRow

use of org.voltdb.VoltTableRow in project voltdb by VoltDB.

the class TRUPTruncateTableMP method run.

public VoltTable[] run(long p, byte shouldRollback) {
    voltQueueSQL(truncate);
    voltQueueSQL(count);
    voltQueueSQL(scancount);
    VoltTable[] results = voltExecuteSQL(true);
    VoltTable data = results[1];
    VoltTableRow row = data.fetchRow(0);
    long optCount = row.getLong(0);
    if (optCount != 0) {
        throw new VoltAbortException("after truncate (opt) count not zero");
    }
    data = results[2];
    row = data.fetchRow(0);
    long scanCount = row.getLong(0);
    if (scanCount != 0) {
        throw new VoltAbortException("after truncate (scan) count not zero");
    }
    if (shouldRollback != 0) {
        throw new VoltAbortException("EXPECTED ROLLBACK");
    }
    return results;
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Example 17 with VoltTableRow

use of org.voltdb.VoltTableRow in project voltdb by VoltDB.

the class TRUPTruncateTableSP method run.

public VoltTable[] run(long p, byte shouldRollback) {
    voltQueueSQL(truncate);
    voltQueueSQL(count);
    voltQueueSQL(scancount);
    VoltTable[] results = voltExecuteSQL(true);
    VoltTable data = results[1];
    VoltTableRow row = data.fetchRow(0);
    long optCount = row.getLong(0);
    if (optCount != 0) {
        throw new VoltAbortException("after truncate (opt) count not zero");
    }
    data = results[2];
    row = data.fetchRow(0);
    long scanCount = row.getLong(0);
    if (scanCount != 0) {
        throw new VoltAbortException("after truncate (scan) count not zero");
    }
    if (shouldRollback != 0) {
        throw new VoltAbortException("EXPECTED ROLLBACK");
    }
    return results;
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Example 18 with VoltTableRow

use of org.voltdb.VoltTableRow in project voltdb by VoltDB.

the class ImportBaseProc method doWork.

protected VoltTable[] doWork(SQLStmt select, SQLStmt update, SQLStmt insert, SQLStmt select_bitmap, SQLStmt update_bitmap, SQLStmt insert_bitmap, byte cid, long ts, long cnt) {
    byte[] bitmap;
    // compute sequence and offsets
    long seq = cnt / 1024;
    int bb = (int) ((cnt - seq * 1024) % 1024);
    int B = bb / 8;
    int b = bb % 8;
    byte mask = (byte) Math.pow(2, 7 - b);
    voltQueueSQL(select, cid);
    voltQueueSQL(select_bitmap, cid, seq);
    VoltTable[] results = voltExecuteSQL();
    VoltTable data = results[0];
    int rowCount = data.getRowCount();
    if (rowCount != 0) {
        if (rowCount != 1)
            throw new VoltAbortException(getClass().getName() + "should get only one row per cid");
        VoltTableRow row = data.fetchRow(0);
        long fcid = row.getLong("cid");
        if (fcid != cid)
            throw new VoltAbortException(getClass().getName() + " serious error expected cid " + cid + " != fetched cid: " + fcid);
        long mts = Math.max(row.getLong("ts"), ts);
        long mcnt = Math.max(row.getLong("cnt"), cnt);
        voltQueueSQL(update, mts, mcnt, cid);
    } else {
        voltQueueSQL(insert, ts, cid, cnt, 1);
    }
    VoltTable bmdata = results[1];
    rowCount = bmdata.getRowCount();
    if (rowCount != 0) {
        VoltTableRow row = bmdata.fetchRow(0);
        bitmap = row.getVarbinary("bitmap");
        if ((bitmap[B] & mask) != 0) {
        // detect/report duplicates ?
        }
        bitmap[B] |= mask;
        voltQueueSQL(update_bitmap, bitmap, cid, seq);
    } else {
        bitmap = new byte[1024];
        bitmap[B] |= mask;
        voltQueueSQL(insert_bitmap, cid, seq, bitmap);
    }
    return voltExecuteSQL(true);
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 19 with VoltTableRow

use of org.voltdb.VoltTableRow in project voltdb by VoltDB.

the class PopulateDimension method run.

// INSERT one row per cid to the dimension table unless already exists
public VoltTable[] run(byte cid) {
    voltQueueSQL(d_getCount, cid);
    VoltTable[] results = voltExecuteSQL(false);
    VoltTable dim = results[0];
    long rowCount = dim.getRowCount();
    if (rowCount != 1) {
        throw new VoltAbortException(getClass().getName() + " invalid row count " + rowCount + " for count query" + " on dimension table for cid " + cid);
    }
    VoltTableRow row = dim.fetchRow(0);
    long c = row.getLong(0);
    switch((int) c) {
        case 0:
            voltQueueSQL(d_Insert, cid, cid);
            results = voltExecuteSQL(true);
        case 1:
            return new VoltTable[] {};
        default:
            throw new VoltAbortException(getClass().getName() + " invalid count " + c + " of dimension rows" + " for cid " + cid);
    }
}
Also used : VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Example 20 with VoltTableRow

use of org.voltdb.VoltTableRow in project voltdb by VoltDB.

the class paymentByCustomerNameW method run.

public VoltTable[] run(short w_id, byte d_id, double h_amount, short c_w_id, byte c_d_id, byte[] c_last, TimestampType timestamp) throws VoltAbortException {
    // retrieve c_id from replicated CUSTOMER_NAME table
    voltQueueSQL(getCidByLastName, c_last, c_d_id, c_w_id);
    final VoltTable result = voltExecuteSQL()[0];
    final int namecnt = result.getRowCount();
    if (namecnt == 0) {
        String c_lastString = null;
        try {
            c_lastString = new String(c_last, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        throw new VoltAbortException("paymentByCustomerNameW: no customers with last name: " + c_lastString + " in warehouse: " + c_w_id + " and in district " + c_d_id);
    }
    final int index = (namecnt - 1) / 2;
    final VoltTableRow customer = result.fetchRow(index);
    final long c_id = customer.getLong(0);
    return processPayment(w_id, d_id, h_amount, c_w_id, c_d_id, c_id, timestamp);
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow)

Aggregations

VoltTableRow (org.voltdb.VoltTableRow)65 VoltTable (org.voltdb.VoltTable)57 Client (org.voltdb.client.Client)23 ProcCallException (org.voltdb.client.ProcCallException)11 TimestampType (org.voltdb.types.TimestampType)7 NoConnectionsException (org.voltdb.client.NoConnectionsException)6 IOException (java.io.IOException)5 VoltAbortException (org.voltdb.VoltProcedure.VoltAbortException)5 Date (java.util.Date)4 WorkWithBigString (org.voltdb_testprocs.regressionsuites.sqlfeatureprocs.WorkWithBigString)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 ClientResponse (org.voltdb.client.ClientResponse)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 ByteBuilder (org.voltdb.benchmark.tpcc.procedures.ByteBuilder)1