Search in sources :

Example 1 with IteratorAdapter

use of org.apache.accumulo.core.iterators.IteratorAdapter in project accumulo by apache.

the class RFileScanner method iterator.

@Override
public Iterator<Entry<Key, Value>> iterator() {
    try {
        RFileSource[] sources = opts.in.getSources();
        List<SortedKeyValueIterator<Key, Value>> readers = new ArrayList<>(sources.length);
        for (int i = 0; i < sources.length; i++) {
            // TODO may have been a bug with multiple files and caching in older version...
            FSDataInputStream inputStream = (FSDataInputStream) sources[i].getInputStream();
            readers.add(new RFile.Reader(new CachableBlockFile.Reader("source-" + i, inputStream, sources[i].getLength(), opts.in.getConf(), dataCache, indexCache, DefaultConfiguration.getInstance())));
        }
        if (getSamplerConfiguration() != null) {
            for (int i = 0; i < readers.size(); i++) {
                readers.set(i, ((Reader) readers.get(i)).getSample(new SamplerConfigurationImpl(getSamplerConfiguration())));
            }
        }
        SortedKeyValueIterator<Key, Value> iterator;
        if (opts.bounds != null) {
            iterator = new MultiIterator(readers, opts.bounds);
        } else {
            iterator = new MultiIterator(readers, false);
        }
        Set<ByteSequence> families = Collections.emptySet();
        if (opts.useSystemIterators) {
            SortedSet<Column> cols = this.getFetchedColumns();
            families = LocalityGroupUtil.families(cols);
            iterator = IteratorUtil.setupSystemScanIterators(iterator, cols, getAuthorizations(), EMPTY_BYTES);
        }
        try {
            if (opts.tableConfig != null && opts.tableConfig.size() > 0) {
                ConfigurationCopy conf = new ConfigurationCopy(opts.tableConfig);
                iterator = IteratorUtil.loadIterators(IteratorScope.scan, iterator, null, conf, serverSideIteratorList, serverSideIteratorOptions, new IterEnv());
            } else {
                iterator = IteratorUtil.loadIterators(iterator, serverSideIteratorList, serverSideIteratorOptions, new IterEnv(), false, null);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        iterator.seek(getRange() == null ? EMPTY_RANGE : getRange(), families, families.size() == 0 ? false : true);
        return new IteratorAdapter(iterator);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : MultiIterator(org.apache.accumulo.core.iterators.system.MultiIterator) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) SamplerConfigurationImpl(org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl) ArrayList(java.util.ArrayList) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) Reader(org.apache.accumulo.core.file.rfile.RFile.Reader) RFile(org.apache.accumulo.core.file.rfile.RFile) IOException(java.io.IOException) Reader(org.apache.accumulo.core.file.rfile.RFile.Reader) Column(org.apache.accumulo.core.data.Column) Value(org.apache.accumulo.core.data.Value) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence)

Example 2 with IteratorAdapter

use of org.apache.accumulo.core.iterators.IteratorAdapter in project accumulo by apache.

the class ClientSideIteratorScanner method iterator.

@Override
public Iterator<Entry<Key, Value>> iterator() {
    smi.scanner.setBatchSize(size);
    smi.scanner.setTimeout(timeOut, TimeUnit.MILLISECONDS);
    smi.scanner.setBatchTimeout(batchTimeOut, TimeUnit.MILLISECONDS);
    smi.scanner.setReadaheadThreshold(readaheadThreshold);
    if (isolated)
        smi.scanner.enableIsolation();
    else
        smi.scanner.disableIsolation();
    smi.samplerConfig = getSamplerConfiguration();
    final TreeMap<Integer, IterInfo> tm = new TreeMap<>();
    for (IterInfo iterInfo : serverSideIteratorList) {
        tm.put(iterInfo.getPriority(), iterInfo);
    }
    SortedKeyValueIterator<Key, Value> skvi;
    try {
        skvi = IteratorUtil.loadIterators(smi, tm.values(), serverSideIteratorOptions, new ClientSideIteratorEnvironment(getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal()), false, null);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    final Set<ByteSequence> colfs = new TreeSet<>();
    for (Column c : this.getFetchedColumns()) {
        colfs.add(new ArrayByteSequence(c.getColumnFamily()));
    }
    try {
        skvi.seek(range, colfs, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return new IteratorAdapter(skvi);
}
Also used : IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) Column(org.apache.accumulo.core.data.Column) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence)

Aggregations

IOException (java.io.IOException)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 Column (org.apache.accumulo.core.data.Column)2 Key (org.apache.accumulo.core.data.Key)2 Value (org.apache.accumulo.core.data.Value)2 IteratorAdapter (org.apache.accumulo.core.iterators.IteratorAdapter)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)1 IterInfo (org.apache.accumulo.core.data.thrift.IterInfo)1 RFile (org.apache.accumulo.core.file.rfile.RFile)1 Reader (org.apache.accumulo.core.file.rfile.RFile.Reader)1 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)1 MultiIterator (org.apache.accumulo.core.iterators.system.MultiIterator)1 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1