@Override public boolean nextRaw(final List<Cell> output, final ScannerContext scannerContext) throws IOException { final List<Cell> input = new ArrayList<>(); final boolean shouldContinue = getScanner().nextRaw(input); _next(input, output); return shouldContinue; }
@Override public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) { return new InternalScanner() { @Override public boolean next(List<Cell> results, ScannerContext scannerContext) throws IOException { List<Cell> internalResults = new ArrayList<>(); boolean hasMore; do { hasMore = scanner.next(internalResults, scannerContext); if (!internalResults.isEmpty()) { long row = Bytes.toLong(CellUtil.cloneValue(internalResults.get(0))); if (row % 2 == 0) { // return this row break; } // clear and continue internalResults.clear(); } } while (hasMore); if (!internalResults.isEmpty()) { results.addAll(internalResults); } return hasMore; } @Override public void close() throws IOException { scanner.close(); } }; }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { if (kvs.isEmpty()) return false; result.add(kvs.remove(0)); return !kvs.isEmpty(); }
public boolean internalNext(List<Cell> outResult,ScannerContext scannerContext) throws IOException { if (beginRow) { beginRow = false; if (LOG.isTraceEnabled()) SpliceLogUtils.trace(LOG, "Next: memstore begin"); return outResult.add(ClientRegionConstants.MEMSTORE_BEGIN); } if (endRowNeedsToBeReturned) { try { outResult.add(new KeyValue(Bytes.toBytes(counter), ClientRegionConstants.HOLD, ClientRegionConstants.HOLD, HConstants.LATEST_TIMESTAMP, ClientRegionConstants.HOLD)); return HBasePlatformUtils.scannerEndReached(scannerContext); } finally { counter++; } } if (didWeFlush()) { if (flushAlreadyReturned) { try { outResult.add(new KeyValue(Bytes.toBytes(counter), ClientRegionConstants.FLUSH, ClientRegionConstants.FLUSH, Long.MAX_VALUE, ClientRegionConstants.FLUSH)); return HBasePlatformUtils.scannerEndReached(scannerContext); } finally { counter++; } } else { flushAlreadyReturned = true; if (LOG.isTraceEnabled()) SpliceLogUtils.trace(LOG, "Next: returning begin flush "); outResult.add(ClientRegionConstants.MEMSTORE_BEGIN_FLUSH); } return HBasePlatformUtils.scannerEndReached(scannerContext); } return directInternalNext(outResult,scannerContext); }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return delegate.next(result, scannerContext); }
@Override public boolean nextRaw(List<Cell> result, ScannerContext context) throws IOException { return delegate.nextRaw(result, context); }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return next(result); }
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return next(result, scannerContext.getBatchLimit()); }
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException { return nextRaw(result, scannerContext.getBatchLimit()); }
@Override public boolean next(final List<Cell> output, final ScannerContext scannerContext) throws IOException { return next(output); }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return false; }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return scanner.next(result, scannerContext); }
private InternalScanner wrap(byte[] family, InternalScanner scanner) { return new InternalScanner() { private List<Cell> srcResult = new ArrayList<>(); private byte[] row; private byte[] qualifier; private long timestamp; private long sum; @Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { boolean moreRows = scanner.next(srcResult, scannerContext); if (srcResult.isEmpty()) { if (!moreRows && row != null) { result.add(createCell(row, family, qualifier, timestamp, sum)); } return moreRows; } Cell firstCell = srcResult.get(0); // Check if there is a row change first. All the cells will come from the same row so just // check the first one once is enough. if (row == null) { row = CellUtil.cloneRow(firstCell); qualifier = CellUtil.cloneQualifier(firstCell); } else if (!CellUtil.matchingRows(firstCell, row)) { result.add(createCell(row, family, qualifier, timestamp, sum)); row = CellUtil.cloneRow(firstCell); qualifier = CellUtil.cloneQualifier(firstCell); sum = 0; } srcResult.forEach(c -> { if (CellUtil.matchingQualifier(c, qualifier)) { sum += Bytes.toLong(c.getValueArray(), c.getValueOffset()); } else { result.add(createCell(row, family, qualifier, timestamp, sum)); qualifier = CellUtil.cloneQualifier(c); sum = Bytes.toLong(c.getValueArray(), c.getValueOffset()); } timestamp = c.getTimestamp(); }); if (!moreRows) { result.add(createCell(row, family, qualifier, timestamp, sum)); } srcResult.clear(); return moreRows; } @Override public void close() throws IOException { scanner.close(); } }; }
public boolean nextRaw(List<Cell> cells, ScannerContext scannerContext) throws IOException { return nextRaw(cells); }
public boolean next(List<Cell> cells, ScannerContext scannerContext) throws IOException { return nextRaw(cells); }
@Override public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException { return nextInternal(result); }
@Override public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException { return nextInternal(result); }
@Override public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException { return next(result); }
public boolean nextRaw(List<Cell> cells, ScannerContext scannerContext) throws IOException { return false; }
public boolean next(List<Cell> cells, ScannerContext scannerContext) throws IOException { return false; }
boolean directInternalNext(List<Cell> result, ScannerContext scannerContext) throws IOException { return super.next(result,scannerContext); }
@Override public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws IOException { return internalNext(outResult,scannerContext); }