Search in sources :

Example 1 with CacheProvider

use of org.apache.accumulo.core.file.blockfile.impl.CacheProvider 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);
        CacheProvider cacheProvider = new BasicCacheProvider(indexCache, dataCache);
        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();
            CachableBuilder cb = new CachableBuilder().input(inputStream, "source-" + i).length(sources[i].getLength()).conf(opts.in.getConf()).cacheProvider(cacheProvider).cryptoService(cryptoService);
            readers.add(new RFile.Reader(cb));
        }
        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 = SystemIteratorUtil.setupSystemScanIterators(iterator, cols, getAuthorizations(), EMPTY_BYTES, tableConf);
        }
        try {
            if (opts.tableConfig != null && !opts.tableConfig.isEmpty()) {
                IterLoad il = IterConfigUtil.loadIterConf(IteratorScope.scan, serverSideIteratorList, serverSideIteratorOptions, tableConf);
                iterator = IterConfigUtil.loadIterators(iterator, il.iterEnv(new IterEnv()).useAccumuloClassLoader(true));
            } else {
                iterator = IterConfigUtil.loadIterators(iterator, new IterLoad().iters(serverSideIteratorList).iterOpts(serverSideIteratorOptions).iterEnv(new IterEnv()).useAccumuloClassLoader(false));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        iterator.seek(getRange() == null ? EMPTY_RANGE : getRange(), families, !families.isEmpty());
        return new IteratorAdapter(iterator);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) BasicCacheProvider(org.apache.accumulo.core.file.blockfile.impl.BasicCacheProvider) SamplerConfigurationImpl(org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl) ArrayList(java.util.ArrayList) RFile(org.apache.accumulo.core.file.rfile.RFile) Column(org.apache.accumulo.core.data.Column) CachableBuilder(org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile.CachableBuilder) MultiIterator(org.apache.accumulo.core.iteratorsImpl.system.MultiIterator) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) IOException(java.io.IOException) BasicCacheProvider(org.apache.accumulo.core.file.blockfile.impl.BasicCacheProvider) CacheProvider(org.apache.accumulo.core.file.blockfile.impl.CacheProvider) Reader(org.apache.accumulo.core.file.rfile.RFile.Reader) IterLoad(org.apache.accumulo.core.conf.IterLoad) 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)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IterLoad (org.apache.accumulo.core.conf.IterLoad)1 ByteSequence (org.apache.accumulo.core.data.ByteSequence)1 Column (org.apache.accumulo.core.data.Column)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 BasicCacheProvider (org.apache.accumulo.core.file.blockfile.impl.BasicCacheProvider)1 CachableBuilder (org.apache.accumulo.core.file.blockfile.impl.CachableBlockFile.CachableBuilder)1 CacheProvider (org.apache.accumulo.core.file.blockfile.impl.CacheProvider)1 RFile (org.apache.accumulo.core.file.rfile.RFile)1 Reader (org.apache.accumulo.core.file.rfile.RFile.Reader)1 IteratorAdapter (org.apache.accumulo.core.iterators.IteratorAdapter)1 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)1 MultiIterator (org.apache.accumulo.core.iteratorsImpl.system.MultiIterator)1 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1