Search in sources :

Example 1 with VoltDBTableSortedMergeWrangler

use of site.ycsb.db.voltdb.sortedvolttable.VoltDBTableSortedMergeWrangler in project YCSB by brianfrankcooper.

the class VoltClient4 method scan.

@Override
public Status scan(String keyspace, String lowerBound, int recordCount, Set<String> columns, Vector<HashMap<String, ByteIterator>> result) {
    try {
        if (useScanAll) {
            byte[] ks = keyspace.getBytes(UTF8);
            ClientResponse response = mclient.callProcedure("ScanAll", ks, lowerBound.getBytes(UTF8), recordCount);
            if (response.getStatus() != ClientResponse.SUCCESS) {
                return Status.ERROR;
            }
            result.ensureCapacity(recordCount);
            VoltTable outputTable = response.getResults()[0];
            outputTable.resetRowPosition();
            while (outputTable.advanceRow()) {
                result.add(unpackRowDataHashMap(outputTable, columns));
            }
        } else {
            byte[] ks = keyspace.getBytes(UTF8);
            ClientResponseWithPartitionKey[] response = mclient.callAllPartitionProcedure("Scan", ks, lowerBound.getBytes(UTF8), recordCount);
            for (int i = 0; i < response.length; i++) {
                if (response[i].response.getStatus() != ClientResponse.SUCCESS) {
                    return Status.ERROR;
                }
            }
            result.ensureCapacity(recordCount);
            VoltDBTableSortedMergeWrangler smw = new VoltDBTableSortedMergeWrangler(response);
            VoltTable outputTable = smw.getSortedTable(1, recordCount);
            outputTable.resetRowPosition();
            while (outputTable.advanceRow()) {
                result.add(unpackRowDataHashMap(outputTable, columns));
            }
        }
        return Status.OK;
    } catch (Exception e) {
        logger.error("Error while calling SCAN", e);
        return Status.ERROR;
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) ClientResponseWithPartitionKey(org.voltdb.client.ClientResponseWithPartitionKey) VoltDBTableSortedMergeWrangler(site.ycsb.db.voltdb.sortedvolttable.VoltDBTableSortedMergeWrangler) VoltTable(org.voltdb.VoltTable) NoConnectionsException(org.voltdb.client.NoConnectionsException) DBException(site.ycsb.DBException)

Aggregations

VoltTable (org.voltdb.VoltTable)1 ClientResponse (org.voltdb.client.ClientResponse)1 ClientResponseWithPartitionKey (org.voltdb.client.ClientResponseWithPartitionKey)1 NoConnectionsException (org.voltdb.client.NoConnectionsException)1 DBException (site.ycsb.DBException)1 VoltDBTableSortedMergeWrangler (site.ycsb.db.voltdb.sortedvolttable.VoltDBTableSortedMergeWrangler)1