public String createBatchScanner()

in src/main/java/org/apache/accumulo/proxy/ProxyServer.java [1217:1283]


  public String createBatchScanner(String sharedSecret, String tableName, BatchScanOptions opts)
      throws org.apache.accumulo.proxy.thrift.AccumuloException,
      org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
    try {
      AccumuloClient accumuloClient = getClient(sharedSecret);

      int threads = 10;
      Authorizations auth;
      if (opts != null && opts.isSetAuthorizations()) {
        auth = getAuthorizations(opts.authorizations);
      } else {
        auth = accumuloClient.securityOperations().getUserAuthorizations(accumuloClient.whoami());
      }
      if (opts != null && opts.threads > 0) {
        threads = opts.threads;
      }

      BatchScanner scanner = accumuloClient.createBatchScanner(tableName, auth, threads);

      if (opts != null) {
        if (opts.iterators != null) {
          for (org.apache.accumulo.proxy.thrift.IteratorSetting iter : opts.iterators) {
            IteratorSetting is = new IteratorSetting(iter.getPriority(), iter.getName(),
                iter.getIteratorClass(), iter.getProperties());
            scanner.addScanIterator(is);
          }
        }

        ArrayList<Range> ranges = new ArrayList<>();

        if (opts.ranges == null) {
          ranges.add(new Range());
        } else {
          for (org.apache.accumulo.proxy.thrift.Range range : opts.ranges) {
            Range aRange =
                new Range(range.getStart() == null ? null : Util.fromThrift(range.getStart()), true,
                    range.getStop() == null ? null : Util.fromThrift(range.getStop()), false);
            ranges.add(aRange);
          }
        }
        scanner.setRanges(ranges);

        if (opts.columns != null) {
          for (ScanColumn col : opts.columns) {
            if (col.isSetColQualifier()) {
              scanner.fetchColumn(ByteBufferUtil.toText(col.colFamily),
                  ByteBufferUtil.toText(col.colQualifier));
            } else {
              scanner.fetchColumnFamily(ByteBufferUtil.toText(col.colFamily));
            }
          }
        }
      }

      UUID uuid = UUID.randomUUID();

      ScannerPlusIterator spi = new ScannerPlusIterator();
      spi.scanner = scanner;
      spi.iterator = scanner.iterator();
      scannerCache.put(uuid, spi);
      return uuid.toString();
    } catch (Exception e) {
      handleExceptionTNF(e);
      return null;
    }
  }