Package org.apache.accumulo.core.client

Examples of org.apache.accumulo.core.client.ScannerBase


  }
 
  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here


  }
 
  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here

  }
 
  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here

  }
 
  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here

  }
 
  static class CloseScanner implements RemovalListener<UUID,ScannerPlusIterator> {
    @Override
    public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) {
      final ScannerBase base = notification.getValue().scanner;
      if (base instanceof BatchScanner) {
        final BatchScanner scanner = (BatchScanner) base;
        scanner.close();
      }
    }
View Full Code Here

      final String tableName,
      final ByteArrayId dataId,
      final ByteArrayId adapterId,
      final String... authorizations ) {

    ScannerBase scanner = null;
    try {

      scanner = accumuloOperations.createScanner(
          tableName,
          authorizations);

      scanner.fetchColumnFamily(new Text(
          adapterId.getBytes()));

      final IteratorSetting rowIteratorSettings = new IteratorSetting(
          SingleEntryFilterIterator.WHOLE_ROW_ITERATOR_PRIORITY,
          SingleEntryFilterIterator.WHOLE_ROW_ITERATOR_NAME,
          WholeRowIterator.class);
      scanner.addScanIterator(rowIteratorSettings);

      final IteratorSetting filterIteratorSettings = new IteratorSetting(
          SingleEntryFilterIterator.ENTRY_FILTER_ITERATOR_PRIORITY,
          SingleEntryFilterIterator.ENTRY_FILTER_ITERATOR_NAME,
          SingleEntryFilterIterator.class);

      filterIteratorSettings.addOption(
          SingleEntryFilterIterator.ADAPTER_ID,
          ByteArrayUtils.byteArrayToString(adapterId.getBytes()));

      filterIteratorSettings.addOption(
          SingleEntryFilterIterator.DATA_ID,
          ByteArrayUtils.byteArrayToString(dataId.getBytes()));
      scanner.addScanIterator(filterIteratorSettings);

      final Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator();
      if (iterator.hasNext()) {
        return iterator.next();
      }
    }
    catch (final TableNotFoundException e) {
      LOGGER.warn(
          "Unable to query table '" + tableName + "'.  Table does not exist.",
          e);
    }
    finally {
      if (scanner != null)
        scanner.close();
    }
    return null;
  }
View Full Code Here

      final String tableName,
      final ByteArrayId dataId,
      final ByteArrayId adapterId ) {

    if (accumuloOptions.isUseAltIndex() && accumuloOperations.tableExists(tableName)) {
      ScannerBase scanner = null;
      try {
        scanner = accumuloOperations.createScanner(tableName);

        ((Scanner) scanner).setRange(Range.exact(new Text(
            dataId.getBytes())));

        scanner.fetchColumnFamily(new Text(
            adapterId.getBytes()));

        final Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator();
        if (iterator.hasNext()) {
          return new ByteArrayId(
              iterator.next().getKey().getColumnQualifierData().getBackingArray());
        }

      }
      catch (final TableNotFoundException e) {
        LOGGER.warn(
            "Unable to query table '" + tableName + "'.  Table does not exist.",
            e);
      }
      finally {
        if (scanner != null) {
          scanner.close();
        }
      }
    }

    return null;
View Full Code Here

    final Map<NumericIndexStrategy, ScannerBase> scanners = getScanners(
        accumuloOperations,
        separateSubStrategies);
    final List<CloseableIterator<SimpleFeature>> iterators = new ArrayList<CloseableIterator<SimpleFeature>>();
    for (final Entry<NumericIndexStrategy, ScannerBase> entry : scanners.entrySet()) {
      final ScannerBase scanner = entry.getValue();
      addScanIteratorSettings(
          scanner,
          entry.getKey());
      iterators.add(new CloseableIteratorWrapper<SimpleFeature>(
          new Closeable() {

            @Override
            public void close()
                throws IOException {
              scanner.close();
            }
          },
          new RenderIteratorWrapper(
              scanner.iterator())));
    }
    return iterators;
  }
View Full Code Here

  public CloseableIterator<Boolean> query(
      final AccumuloOperations accumuloOperations,
      final AdapterStore adapterStore,
      final Integer limit ) {
    final ScannerBase scanner = getScanner(
        accumuloOperations,
        limit);
    addScanIteratorSettings(scanner);
    final String tableName = StringUtils.stringFromBinary(index.getId().getBytes());
    TransformerWriter writer = new TransformerWriter(
        scanner,
        tableName,
        accumuloOperations,
        transformer);
    writer.transform();
    scanner.close();

    return new CloseableIterator.Empty<Boolean>();
  }
View Full Code Here

  protected ScannerBase getScanner(
      final AccumuloOperations accumuloOperations,
      final Integer limit ) {
    final List<ByteArrayRange> ranges = getRanges();
    final String tableName = StringUtils.stringFromBinary(index.getId().getBytes());
    ScannerBase scanner;
    try {
      if ((ranges != null) && (ranges.size() == 1)) {
        scanner = accumuloOperations.createScanner(
            tableName,
            getAdditionalAuthorizations());
        final ByteArrayRange r = ranges.get(0);
        if (r.isSingleValue()) {
          ((Scanner) scanner).setRange(Range.exact(new Text(
              r.getStart().getBytes())));
        }
        else {
          ((Scanner) scanner).setRange(AccumuloUtils.byteArrayRangeToAccumuloRange(r));
        }
        if ((limit != null) && (limit > 0) && (limit < ((Scanner) scanner).getBatchSize())) {
          ((Scanner) scanner).setBatchSize(limit);
        }
      }
      else {
        scanner = accumuloOperations.createBatchScanner(
            tableName,
            getAdditionalAuthorizations());
        ((BatchScanner) scanner).setRanges(AccumuloUtils.byteArrayRangesToAccumuloRanges(ranges));
      }
    }
    catch (final TableNotFoundException e) {
      LOGGER.warn(
          "Unable to query table '" + tableName + "'.  Table does not exist.",
          e);
      return null;
    }
    if ((adapterIds != null) && !adapterIds.isEmpty()) {
      for (final ByteArrayId adapterId : adapterIds) {
        scanner.fetchColumnFamily(new Text(
            adapterId.getBytes()));
      }
    }
    return scanner;
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.ScannerBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.