Java 类org.apache.hadoop.hbase.client.ClientScanner 实例源码

项目:themis    文件:ThemisScanner.java   
public ThemisScanner(final byte[] tableName, final Scan scan, final Transaction transaction)
    throws IOException {
  long beginTs = System.nanoTime();
  try {
    this.tableName = tableName;
    this.transaction = transaction;
    this.scan = scan;
    // we need to set startTs to the attribute named '_themisTransationStartTs_'. Then, the loaded
    // themis coprocessor could recognize this scanner from hbase scanners and do themis logics.
    // TODO(cuijianwei): how to avoid no-themis users set this attribute when doing hbase scan?
    setStartTsToScan(scan, transaction.startTs);
    this.scanner = new ClientScanner(transaction.getConf(), scan, tableName,
        transaction.getHConnection());
  } finally {
    ThemisStatistics.updateLatency(ThemisStatistics.getStatistics().getScannerLatency, beginTs);
  }
}
项目:ditb    文件:TestPartialResultsFromClientSide.java   
/**
 * @param resultSizeRowLimit The row limit that will be enforced through maxResultSize
 * @param cachingRowLimit The row limit that will be enforced through caching
 * @throws Exception
 */
public void testPartialResultsAndCaching(int resultSizeRowLimit, int cachingRowLimit)
    throws Exception {
  Scan scan = new Scan();
  scan.setAllowPartialResults(true);

  // The number of cells specified in the call to getResultSizeForNumberOfCells is offset to
  // ensure that the result size we specify is not an exact multiple of the number of cells
  // in a row. This ensures that partial results will be returned when the result size limit
  // is reached before the caching limit.
  int cellOffset = NUM_COLS / 3;
  long maxResultSize = getResultSizeForNumberOfCells(resultSizeRowLimit * NUM_COLS + cellOffset);
  scan.setMaxResultSize(maxResultSize);
  scan.setCaching(cachingRowLimit);

  ResultScanner scanner = TABLE.getScanner(scan);
  ClientScanner clientScanner = (ClientScanner) scanner;
  Result r = null;

  // Approximate the number of rows we expect will fit into the specified max rsult size. If this
  // approximation is less than caching, then we expect that the max result size limit will be
  // hit before the caching limit and thus partial results may be seen
  boolean expectToSeePartialResults = resultSizeRowLimit < cachingRowLimit;
  while ((r = clientScanner.next()) != null) {
    assertTrue(!r.isPartial() || expectToSeePartialResults);
  }

  scanner.close();
}
项目:hbase    文件:TestPartialResultsFromClientSide.java   
/**
 * @param resultSizeRowLimit The row limit that will be enforced through maxResultSize
 * @param cachingRowLimit The row limit that will be enforced through caching
 * @throws Exception
 */
public void testPartialResultsAndCaching(int resultSizeRowLimit, int cachingRowLimit)
    throws Exception {
  Scan scan = new Scan();
  scan.setAllowPartialResults(true);

  // The number of cells specified in the call to getResultSizeForNumberOfCells is offset to
  // ensure that the result size we specify is not an exact multiple of the number of cells
  // in a row. This ensures that partial results will be returned when the result size limit
  // is reached before the caching limit.
  int cellOffset = NUM_COLS / 3;
  long maxResultSize = getResultSizeForNumberOfCells(resultSizeRowLimit * NUM_COLS + cellOffset);
  scan.setMaxResultSize(maxResultSize);
  scan.setCaching(cachingRowLimit);

  ResultScanner scanner = TABLE.getScanner(scan);
  ClientScanner clientScanner = (ClientScanner) scanner;
  Result r = null;

  // Approximate the number of rows we expect will fit into the specified max rsult size. If this
  // approximation is less than caching, then we expect that the max result size limit will be
  // hit before the caching limit and thus partial results may be seen
  boolean expectToSeePartialResults = resultSizeRowLimit < cachingRowLimit;
  while ((r = clientScanner.next()) != null) {
    assertTrue(!r.mayHaveMoreCellsInRow() || expectToSeePartialResults);
  }

  scanner.close();
}
项目:hbase-secondary-index    文件:TransactionalTable.java   
public ResultScanner getScanner(final TransactionState transactionState, final Scan scan) throws IOException {
        ClientScanner scanner = new TransactionalClientScanner(transactionState, scan);
//        scanner.initialize();
        return scanner;
    }