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

The following examples show how to use org.apache.hadoop.hbase.regionserver.ScannerContext. 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 File: TestRegionObserverInterface.java    From hbase with 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 File: ScannerContextRowScanner.java    From geowave with 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 #3
Source File: ScannerContextRowScanner.java    From geowave with 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 #4
Source File: ScannerContextRowScanner.java    From geowave with 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 #5
Source File: ScannerContextRowScanner.java    From geowave with 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 File: ServerOpInternalScannerWrapper.java    From geowave with 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 #7
Source File: ServerOpRegionScannerWrapper.java    From geowave with 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 #8
Source File: BaseScannerRegionObserver.java    From phoenix with 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 #9
Source File: BaseScannerRegionObserver.java    From phoenix with 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 #10
Source File: TestStripeCompactionPolicy.java    From hbase with 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 #11
Source File: HBaseClientSideRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public boolean next(List<Cell> cells, ScannerContext scannerContext) throws IOException {
    return false;
}
 
Example #12
Source File: HBaseClientSideRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
public boolean nextRaw(List<Cell> cells, ScannerContext scannerContext) throws IOException {
    return false;
}
 
Example #13
Source File: MemstoreKeyValueScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example #14
Source File: CountingRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return delegate.nextRaw(result, scannerContext);
}
 
Example #15
Source File: CountingRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return delegate.nextRaw(result, scannerContext);
}
 
Example #16
Source File: SICompactionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example #17
Source File: DummyScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return false;
}
 
Example #18
Source File: SplitRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return nextInternal(result);
}
 
Example #19
Source File: SplitRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return nextInternal(result);
}
 
Example #20
Source File: ServerOpInternalScannerWrapper.java    From geowave with 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 #21
Source File: IteratorRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean nextRaw(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example #22
Source File: IteratorRegionScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
    return next(result);
}
 
Example #23
Source File: TestBlockEvictionFromClient.java    From hbase with 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 #24
Source File: StubInternalScanner.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean next(List<Cell> cells, ScannerContext scannerContext) throws IOException {
    return false;
}
 
Example #25
Source File: StatisticsScanner.java    From phoenix with 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 #26
Source File: HashJoinRegionScanner.java    From phoenix with 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 #27
Source File: HashJoinRegionScanner.java    From phoenix with 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 #28
Source File: DelegateRegionScanner.java    From phoenix with 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 #29
Source File: DelegateRegionScanner.java    From phoenix with 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 #30
Source File: BaseRegionScanner.java    From phoenix with 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");
}