Java Code Examples for org.apache.hadoop.hbase.regionserver.ScannerContext

The following examples show how to use org.apache.hadoop.hbase.regionserver.ScannerContext. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hbase   Source File: TestRegionObserverInterface.java    License: Apache License 2.0 5 votes vote down vote up
@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();
    }
  };
}
 
Example 2
Source Project: hbase   Source File: TestStripeCompactionPolicy.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext)
    throws IOException {
  if (kvs.isEmpty()) {
    return false;
  }
  result.add(kvs.remove(0));
  return !kvs.isEmpty();
}
 
Example 3
Source Project: phoenix   Source File: BaseScannerRegionObserver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    overrideDelegate();
    boolean res = super.next(result);
    ScannerContextUtil.incrementSizeProgress(scannerContext, result);
    ScannerContextUtil.updateTimeProgress(scannerContext);
    return res;
}
 
Example 4
Source Project: phoenix   Source File: BaseScannerRegionObserver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    overrideDelegate();
    boolean res = super.nextRaw(result);
    ScannerContextUtil.incrementSizeProgress(scannerContext, result);
    ScannerContextUtil.updateTimeProgress(scannerContext);
    return res;
}
 
Example 5
Source Project: geowave   Source File: ScannerContextRowScanner.java    License: Apache License 2.0 5 votes vote down vote up
public ScannerContextRowScanner(
    final InternalScanner scanner,
    final List<Cell> cells,
    final ScannerContext scannerContext,
    final Scan scan) {
  this.scanner = scanner;
  this.cells = cells;
  this.scannerContext = scannerContext;
  this.scan = scan;
}
 
Example 6
Source Project: geowave   Source File: ScannerContextRowScanner.java    License: Apache License 2.0 5 votes vote down vote up
public ReflectionParams() {
  try {
    scannerState = ScannerContext.class.getDeclaredField("scannerState");
    scannerState.setAccessible(true);
    clearProgress = ScannerContext.class.getDeclaredMethod("clearProgress");
    clearProgress.setAccessible(true);
    setScannerState =
        ScannerContext.class.getDeclaredMethod("setScannerState", NextState.class);
    setScannerState.setAccessible(true);
  } catch (final Exception e) {
    LOGGER.warn("Unable to get accessible methods for ScannerContextRowScanner", e);
    exception = true;
  }
}
 
Example 7
Source Project: geowave   Source File: ScannerContextRowScanner.java    License: Apache License 2.0 5 votes vote down vote up
public NextState getScannerState(final ScannerContext instance) {
  if (!exception) {
    try {
      return (NextState) scannerState.get(instance);
    } catch (final Exception e) {
      LOGGER.warn("Unable to check partial result of scanner context", e);
      exception = true;
    }
  }
  return NextState.MORE_VALUES;
}
 
Example 8
Source Project: geowave   Source File: ScannerContextRowScanner.java    License: Apache License 2.0 5 votes vote down vote up
public void reset(final ScannerContext instance) {
  if (!exception) {
    try {
      clearProgress.invoke(instance);

      setScannerState.invoke(instance, NextState.MORE_VALUES);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
      LOGGER.warn("Unable to invoke reset of scanner context", e);
      exception = true;
    }
  }
}
 
Example 9
Source Project: geowave   Source File: ServerOpInternalScannerWrapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean next(final List<Cell> rowCells, final ScannerContext scannerContext)
    throws IOException {
  final boolean retVal = delegate.next(rowCells, scannerContext);
  if (!internalNextRow(rowCells, scannerContext)) {
    return false;
  }
  return retVal;
}
 
Example 10
Source Project: geowave   Source File: ServerOpRegionScannerWrapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean nextRaw(final List<Cell> rowCells, final ScannerContext scannerContext)
    throws IOException {
  final boolean retVal = ((RegionScanner) delegate).nextRaw(rowCells, scannerContext);
  if (!internalNextRow(rowCells, scannerContext)) {
    return false;
  }
  return retVal;
}
 
Example 11
Source Project: hbase   Source File: TestBlockEvictionFromClient.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
  return delegate.next(result, scannerContext);
}
 
Example 12
Source Project: hbase   Source File: TestCoprocessorInterface.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext)
    throws IOException {
  return delegate.next(result, scannerContext);
}
 
Example 13
Source Project: hbase   Source File: TestCoprocessorInterface.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext context)
    throws IOException {
  return delegate.nextRaw(result, context);
}
 
Example 14
Source Project: hbase   Source File: TestRegionObserverScannerOpenHook.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
  return false;
}
 
Example 15
Source Project: hbase   Source File: TestCompactor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
  if (kvs.isEmpty()) return false;
  result.add(kvs.remove(0));
  return !kvs.isEmpty();
}
 
Example 16
Source Project: hbase   Source File: DelegatingInternalScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
  return scanner.next(result, scannerContext);
}
 
Example 17
Source Project: hbase   Source File: WriteHeavyIncrementObserver.java    License: Apache License 2.0 4 votes vote down vote up
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();
    }
  };
}
 
Example 18
Source Project: phoenix   Source File: GlobalIndexChecker.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("next with scannerContext should not be called in Phoenix environment");
}
 
Example 19
Source Project: phoenix   Source File: GlobalIndexChecker.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("NextRaw with scannerContext should not be called in Phoenix environment");
}
 
Example 20
Source Project: phoenix   Source File: BaseRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("Next with scannerContext should not be called in Phoenix environment");
}
 
Example 21
Source Project: phoenix   Source File: BaseRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("NextRaw with scannerContext should not be called in Phoenix environment");
}
 
Example 22
Source Project: phoenix   Source File: DelegateRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("Next with scannerContext should not be called in Phoenix environment");
}
 
Example 23
Source Project: phoenix   Source File: DelegateRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("NextRaw with scannerContext should not be called in Phoenix environment");
}
 
Example 24
Source Project: phoenix   Source File: HashJoinRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext)
        throws IOException {
    throw new IOException("Next with scannerContext should not be called in Phoenix environment");
}
 
Example 25
Source Project: phoenix   Source File: HashJoinRegionScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    throw new IOException("Next with scannerContext should not be called in Phoenix environment");
}
 
Example 26
Source Project: phoenix   Source File: StatisticsScanner.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example 27
Source Project: geowave   Source File: ServerOpInternalScannerWrapper.java    License: Apache License 2.0 4 votes vote down vote up
protected boolean internalNextRow(final List<Cell> rowCells, final ScannerContext scannerContext)
    throws IOException {
  return internalNextRow(new ScannerContextRowScanner(delegate, rowCells, scannerContext, scan));
}
 
Example 28
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example 29
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return delegate.nextRaw(result, scannerContext);
}
 
Example 30
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return delegate.nextRaw(result, scannerContext);
}