예제 #1
0
  /**
   * Counts the rows from the {@code scanner} until exhaustion. It doesn't require the scanner to be
   * new, so it can be used to finish scanning a previously-started scan.
   */
  protected static int countRowsInScan(AsyncKuduScanner scanner) throws Exception {
    final AtomicInteger counter = new AtomicInteger();

    Callback<Object, RowResultIterator> cb =
        new Callback<Object, RowResultIterator>() {
          @Override
          public Object call(RowResultIterator arg) throws Exception {
            if (arg == null) return null;
            counter.addAndGet(arg.getNumRows());
            return null;
          }
        };

    while (scanner.hasMoreRows()) {
      Deferred<RowResultIterator> data = scanner.nextRows();
      data.addCallbacks(cb, defaultErrorCB);
      data.join(DEFAULT_SLEEP);
    }

    Deferred<RowResultIterator> closer = scanner.close();
    closer.addCallbacks(cb, defaultErrorCB);
    closer.join(DEFAULT_SLEEP);
    return counter.get();
  }
예제 #2
0
 /**
  * Returns if this scanner was configured to cache data blocks or not.
  *
  * @return true if this scanner will cache blocks, else else.
  */
 public boolean getCacheBlocks() {
   return asyncScanner.getCacheBlocks();
 }
예제 #3
0
 /**
  * Returns the maximum number of bytes returned by the scanner, on each batch.
  *
  * @return a long representing the maximum number of bytes that a scanner can receive at once from
  *     a tablet server
  */
 public long getBatchSizeBytes() {
   return asyncScanner.getBatchSizeBytes();
 }
예제 #4
0
 /**
  * Returns the maximum number of rows that this scanner was configured to return.
  *
  * @return a long representing the maximum number of rows that can be returned
  */
 public long getLimit() {
   return asyncScanner.getLimit();
 }
예제 #5
0
 /**
  * Closes this scanner (don't forget to call this when you're done with it!).
  *
  * <p>Closing a scanner already closed has no effect.
  *
  * @return a deferred object that indicates the completion of the request
  */
 public RowResultIterator close() throws Exception {
   Deferred<RowResultIterator> d = asyncScanner.close();
   return d.join(asyncScanner.scanRequestTimeout);
 }
예제 #6
0
 /**
  * Tells if the last rpc returned that there might be more rows to scan.
  *
  * @return true if there might be more data to scan, else false
  */
 public boolean hasMoreRows() {
   return asyncScanner.hasMoreRows();
 }
예제 #7
0
 /**
  * Returns the projection schema of this scanner. If specific columns were not specified during
  * scanner creation, the table schema is returned.
  *
  * @return the projection schema for this scanner
  */
 public Schema getProjectionSchema() {
   return asyncScanner.getProjectionSchema();
 }
예제 #8
0
 /**
  * Returns the ReadMode for this scanner.
  *
  * @return the configured read mode for this scanner
  */
 public ReadMode getReadMode() {
   return asyncScanner.getReadMode();
 }