private ResultScanner getScanner(ScanBuilder scanBuilder) throws IOException { return rowKeyDistributor == null ? hTable.getScanner(scanBuilder.build()) : DistributedScanner.create(hTable, scanBuilder.build(), rowKeyDistributor, scanExecutor); }
private ResultScanner getScanner(ScanBuilder scanBuilder) throws IOException { return rowKeyDistributor == null ? hTable.getScanner(scanBuilder.build()) : DistributedScanner.create(hTable, scanBuilder.build(), rowKeyDistributor, scanExecutor); }
@Override public QueueScanner createScanner(ConsumerConfig consumerConfig, HTable hTable, Scan scan, int numRows) throws IOException { // we should roughly divide by number of buckets, but don't want another RPC for the case we are not exactly right ScanBuilder distributedScan = tableUtil.buildScan(scan); int caching = (int) (1.1 * numRows / distributorBuckets); distributedScan.setCaching(caching); ResultScanner scanner = DistributedScanner.create(hTable, distributedScan.build(), rowKeyDistributor, scansExecutor); return new HBaseQueueScanner(scanner, numRows, rowKeyConverter); }
@Override public void rollback(byte[] startKey, byte[] stopKey, byte[] txWritePtr) throws IOException { Scan scan = tableUtil.buildScan() .setStartRow(startKey) .setStopRow(stopKey) .setCaching(scanCacheRows) .build(); List<Put> batchPuts = new ArrayList<>(); try (ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor)) { for (Result result : scanner) { // No need to turn the key back to the original row key because we want to put with the actual row key PutBuilder putBuilder = tableUtil.buildPut(result.getRow()); putBuilder.add(columnFamily, TX_COL, txWritePtr); batchPuts.add(putBuilder.build()); } } try { if (!batchPuts.isEmpty()) { hTable.put(batchPuts); if (!hTable.isAutoFlush()) { hTable.flushCommits(); } } } catch (IOException e) { throw exceptionHandler.handle(e); } }
@Override public void rollback(byte[] startKey, byte[] stopKey, byte[] txWritePtr) throws IOException { Scan scan = tableUtil.buildScan() .setStartRow(startKey) .setStopRow(stopKey) .setCaching(scanCacheRows) .build(); List<Put> batchPuts = new ArrayList<>(); try (ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor)) { for (Result result : scanner) { // No need to turn the key back to the original row key because we want to put with the actual row key PutBuilder putBuilder = tableUtil.buildPut(result.getRow()); putBuilder.add(columnFamily, TX_COL, txWritePtr); batchPuts.add(putBuilder.build()); } } try { if (!batchPuts.isEmpty()) { hTable.put(batchPuts); if (!hTable.isAutoFlush()) { hTable.flushCommits(); } } } catch (IOException e) { throw exceptionHandler.handle(e); } }
.build(); final ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor); return new AbstractCloseableIterator<RawPayloadTableEntry>() { private final RawPayloadTableEntry tableEntry = new RawPayloadTableEntry();
.build(); final ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor); return new AbstractCloseableIterator<RawPayloadTableEntry>() { private final RawPayloadTableEntry tableEntry = new RawPayloadTableEntry();
final ResultScanner scanner = DistributedScanner.create(hTable, scan, keyDistributor, scanExecutor); return new StateScanner() {
private void testSimpleScanInternal(long origKeyPrefix, Scan scan, int numValues, int startWithValue, int seekIntervalMinValue, int seekIntervalMaxValue) throws IOException { int valuesCountInSeekInterval = writeTestData(origKeyPrefix, numValues, startWithValue, seekIntervalMinValue, seekIntervalMaxValue); // TODO: add some filters to the scan for better testing ResultScanner distributedScanner = DistributedScanner.create(hTable, scan, keyDistributor, Executors.newFixedThreadPool(2)); Result previous = null; int countMatched = 0; for (Result current : distributedScanner) { countMatched++; if (previous != null) { byte[] currentRowOrigKey = keyDistributor.getOriginalKey(current.getRow()); byte[] previousRowOrigKey = keyDistributor.getOriginalKey(previous.getRow()); Assert.assertTrue(Bytes.compareTo(currentRowOrigKey, previousRowOrigKey) >= 0); int currentValue = Bytes.toInt(current.getValue(CF, QUAL)); Assert.assertTrue(currentValue >= seekIntervalMinValue); Assert.assertTrue(currentValue <= seekIntervalMaxValue); } previous = current; } Assert.assertEquals(valuesCountInSeekInterval, countMatched); }
final ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor); final RawMessageTableEntry tableEntry = new RawMessageTableEntry(); return new AbstractCloseableIterator<RawMessageTableEntry>() {
final ResultScanner scanner = DistributedScanner.create(hTable, scan, rowKeyDistributor, scanExecutor); final RawMessageTableEntry tableEntry = new RawMessageTableEntry(); return new AbstractCloseableIterator<RawMessageTableEntry>() {
private ResultScanner createHBaseScanner(ConsumerConfig consumerConfig, HTable hTable, Scan scan, int numRows) throws IOException { // Modify the scan with sharded key prefix ScanBuilder shardedScan = tableUtil.buildScan(scan); // we should roughly divide by number of buckets, but don't want another RPC for the case we are not exactly right int caching = (int) (1.1 * numRows / distributorBuckets); shardedScan.setCaching(caching); if (scan.getStartRow().length > 0) { byte[] rowKey = getShardedKey(consumerConfig, consumerConfig.getInstanceId(), scan.getStartRow()); shardedScan.setStartRow(rowKey); } if (scan.getStopRow().length > 0) { byte[] rowKey = getShardedKey(consumerConfig, consumerConfig.getInstanceId(), scan.getStopRow()); shardedScan.setStopRow(rowKey); } return DistributedScanner.create(hTable, shardedScan.build(), rowKeyDistributor, scansExecutor); }