java/kudu-client/src/test/java/org/apache/kudu/util/ClientTestUtil.java
public static int countScanTokenRows(List<KuduScanToken> tokens, final String masterAddresses,
                                       final long operationTimeoutMs)
      throws IOException, InterruptedException {
    final AtomicInteger count = new AtomicInteger(0);
    List<Thread> threads = new ArrayList<>();
    for (final KuduScanToken token : tokens) {
      final byte[] serializedToken = token.serialize();
      Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
          try (KuduClient contextClient = new KuduClient.KuduClientBuilder(masterAddresses)
                   .defaultAdminOperationTimeoutMs(operationTimeoutMs)
                   .build()) {
            KuduScanner scanner = KuduScanToken.deserializeIntoScanner(serializedToken, contextClient);
            try {
              int localCount = 0;
              while (scanner.hasMoreRows()) {
                localCount += Iterators.size(scanner.nextRows());
              }
              count.addAndGet(localCount);
            } finally {
              scanner.close();
            }
          } catch (Exception e) {
            LOG.error("exception in parallel token scanner", e);
          }
        }
      });
      thread.run();
      threads.add(thread);
    }

    for (Thread thread : threads) {
      thread.join();
    }
    return count.get();
  }
/**
   * Counts the rows in the provided scan tokens.
   */
Counts the rows in the provided scan tokens.
Counts the rows in the provided scan tokens .
public static int countScanTokenRows(List<KuduScanToken> tokens, final String masterAddresses,
                                       final long operationTimeoutMs)
      throws IOException, InterruptedException {
    final AtomicInteger count = new AtomicInteger(0);
    List<Thread> threads = new ArrayList<>();
    for (final KuduScanToken token : tokens) {
      final byte[] serializedToken = token.serialize();
      Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
          try (KuduClient contextClient = new KuduClient.KuduClientBuilder(masterAddresses)
                   .defaultAdminOperationTimeoutMs(operationTimeoutMs)
                   .build()) {
            KuduScanner scanner = KuduScanToken.deserializeIntoScanner(serializedToken, contextClient);
            try {
              int localCount = 0;
              while (scanner.hasMoreRows()) {
                localCount += Iterators.size(scanner.nextRows());
              }
              count.addAndGet(localCount);
            } finally {
              scanner.close();
            }
          } catch (Exception e) {
            LOG.error("exception in parallel token scanner", e);
          }
        }
      });
      thread.run();
      threads.add(thread);
    }
    for (Thread thread : threads) {
      thread.join();
    }
    return count.get();
  }
public static int countScanTokenRows ( List < KuduScanToken > tokens , final String masterAddresses , final long operationTimeoutMs ) throws IOException , InterruptedException { final AtomicInteger count = new AtomicInteger ( 0 ) ; List < Thread > threads = new ArrayList < > ( ) ; for ( final KuduScanToken token : tokens ) { final byte [ ] serializedToken = token . serialize ( ) ; Thread thread = new Thread ( new Runnable ( ) { @ Override public void run ( ) { try ( KuduClient contextClient = new KuduClient . KuduClientBuilder ( masterAddresses ) . defaultAdminOperationTimeoutMs ( operationTimeoutMs ) . build ( ) ) { KuduScanner scanner = KuduScanToken . deserializeIntoScanner ( serializedToken , contextClient ) ; try { int localCount = 0 ; while ( scanner . hasMoreRows ( ) ) { localCount += Iterators . size ( scanner . nextRows ( ) ) ; } count . addAndGet ( localCount ) ; } finally { scanner . close ( ) ; } } catch ( Exception e ) { LOG . error ( "exception in parallel token scanner" , e ) ; } } } ) ; thread . run ( ) ; threads . add ( thread ) ; } for ( Thread thread : threads ) { thread . join ( ) ; } return count . get ( ) ; }
Counts the rows in the provided scan tokens.
Counts the rows in the provided scan tokens .