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); } }
/** * @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(); }
/** * @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(); }
public ResultScanner getScanner(final TransactionState transactionState, final Scan scan) throws IOException { ClientScanner scanner = new TransactionalClientScanner(transactionState, scan); // scanner.initialize(); return scanner; }