Search in sources :

Example 1 with DeletingIterator

use of org.apache.accumulo.core.iterators.system.DeletingIterator in project accumulo by apache.

the class Compactor method compactLocalityGroup.

private void compactLocalityGroup(String lgName, Set<ByteSequence> columnFamilies, boolean inclusive, FileSKVWriter mfw, CompactionStats majCStats) throws IOException, CompactionCanceledException {
    ArrayList<FileSKVIterator> readers = new ArrayList<>(filesToCompact.size());
    Span span = Trace.start("compact");
    try {
        long entriesCompacted = 0;
        List<SortedKeyValueIterator<Key, Value>> iters = openMapDataFiles(lgName, readers);
        if (imm != null) {
            iters.add(imm.compactionIterator());
        }
        CountingIterator citr = new CountingIterator(new MultiIterator(iters, extent.toDataRange()), entriesRead);
        DeletingIterator delIter = new DeletingIterator(citr, propogateDeletes);
        ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter);
        // if(env.getIteratorScope() )
        TabletIteratorEnvironment iterEnv;
        if (env.getIteratorScope() == IteratorScope.majc)
            iterEnv = new TabletIteratorEnvironment(IteratorScope.majc, !propogateDeletes, acuTableConf);
        else if (env.getIteratorScope() == IteratorScope.minc)
            iterEnv = new TabletIteratorEnvironment(IteratorScope.minc, acuTableConf);
        else
            throw new IllegalArgumentException();
        SortedKeyValueIterator<Key, Value> itr = iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(env.getIteratorScope(), cfsi, extent, acuTableConf, iterators, iterEnv));
        itr.seek(extent.toDataRange(), columnFamilies, inclusive);
        if (!inclusive) {
            mfw.startDefaultLocalityGroup();
        } else {
            mfw.startNewLocalityGroup(lgName, columnFamilies);
        }
        Span write = Trace.start("write");
        try {
            while (itr.hasTop() && env.isCompactionEnabled()) {
                mfw.append(itr.getTopKey(), itr.getTopValue());
                itr.next();
                entriesCompacted++;
                if (entriesCompacted % 1024 == 0) {
                    // Periodically update stats, do not want to do this too often since its volatile
                    entriesWritten.addAndGet(1024);
                }
            }
            if (itr.hasTop() && !env.isCompactionEnabled()) {
                // cancel major compaction operation
                try {
                    try {
                        mfw.close();
                    } catch (IOException e) {
                        log.error("{}", e.getMessage(), e);
                    }
                    fs.deleteRecursively(outputFile.path());
                } catch (Exception e) {
                    log.warn("Failed to delete Canceled compaction output file {}", outputFile, e);
                }
                throw new CompactionCanceledException();
            }
        } finally {
            CompactionStats lgMajcStats = new CompactionStats(citr.getCount(), entriesCompacted);
            majCStats.add(lgMajcStats);
            write.stop();
        }
    } finally {
        // close sequence files opened
        for (FileSKVIterator reader : readers) {
            try {
                reader.close();
            } catch (Throwable e) {
                log.warn("Failed to close map file", e);
            }
        }
        span.stop();
    }
}
Also used : FileSKVIterator(org.apache.accumulo.core.file.FileSKVIterator) ColumnFamilySkippingIterator(org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator) MultiIterator(org.apache.accumulo.core.iterators.system.MultiIterator) ArrayList(java.util.ArrayList) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) IOException(java.io.IOException) Span(org.apache.accumulo.core.trace.Span) IOException(java.io.IOException) TabletIteratorEnvironment(org.apache.accumulo.tserver.TabletIteratorEnvironment) Value(org.apache.accumulo.core.data.Value) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) DeletingIterator(org.apache.accumulo.core.iterators.system.DeletingIterator) Key(org.apache.accumulo.core.data.Key)

Example 2 with DeletingIterator

use of org.apache.accumulo.core.iterators.system.DeletingIterator in project accumulo by apache.

the class MockScannerBase method createFilter.

public SortedKeyValueIterator<Key, Value> createFilter(SortedKeyValueIterator<Key, Value> inner) throws IOException {
    byte[] defaultLabels = {};
    inner = new ColumnFamilySkippingIterator(new DeletingIterator(inner, false));
    SortedKeyValueIterator<Key, Value> cqf = ColumnQualifierFilter.wrap(inner, new HashSet<>(fetchedColumns));
    SortedKeyValueIterator<Key, Value> vf = VisibilityFilter.wrap(cqf, auths, defaultLabels);
    AccumuloConfiguration conf = new MockConfiguration(table.settings);
    MockIteratorEnvironment iterEnv = new MockIteratorEnvironment(auths);
    SortedKeyValueIterator<Key, Value> result = iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(IteratorScope.scan, vf, null, conf, serverSideIteratorList, serverSideIteratorOptions, iterEnv, false));
    return result;
}
Also used : ColumnFamilySkippingIterator(org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator) Value(org.apache.accumulo.core.data.Value) DeletingIterator(org.apache.accumulo.core.iterators.system.DeletingIterator) Key(org.apache.accumulo.core.data.Key) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration)

Example 3 with DeletingIterator

use of org.apache.accumulo.core.iterators.system.DeletingIterator in project accumulo by apache.

the class CollectTabletStats method createScanIterator.

private static SortedKeyValueIterator<Key, Value> createScanIterator(KeyExtent ke, Collection<SortedKeyValueIterator<Key, Value>> mapfiles, Authorizations authorizations, byte[] defaultLabels, HashSet<Column> columnSet, List<IterInfo> ssiList, Map<String, Map<String, String>> ssio, boolean useTableIterators, TableConfiguration conf) throws IOException {
    SortedMapIterator smi = new SortedMapIterator(new TreeMap<>());
    List<SortedKeyValueIterator<Key, Value>> iters = new ArrayList<>(mapfiles.size() + 1);
    iters.addAll(mapfiles);
    iters.add(smi);
    MultiIterator multiIter = new MultiIterator(iters, ke);
    DeletingIterator delIter = new DeletingIterator(multiIter, false);
    ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter);
    SortedKeyValueIterator<Key, Value> colFilter = ColumnQualifierFilter.wrap(cfsi, columnSet);
    SortedKeyValueIterator<Key, Value> visFilter = VisibilityFilter.wrap(colFilter, authorizations, defaultLabels);
    if (useTableIterators)
        return IteratorUtil.loadIterators(IteratorScope.scan, visFilter, ke, conf, ssiList, ssio, null);
    return visFilter;
}
Also used : ColumnFamilySkippingIterator(org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator) MultiIterator(org.apache.accumulo.core.iterators.system.MultiIterator) ArrayList(java.util.ArrayList) Value(org.apache.accumulo.core.data.Value) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) DeletingIterator(org.apache.accumulo.core.iterators.system.DeletingIterator) SortedMapIterator(org.apache.accumulo.core.iterators.SortedMapIterator) Key(org.apache.accumulo.core.data.Key)

Example 4 with DeletingIterator

use of org.apache.accumulo.core.iterators.system.DeletingIterator in project accumulo by apache.

the class IteratorUtil method setupSystemScanIterators.

public static SortedKeyValueIterator<Key, Value> setupSystemScanIterators(SortedKeyValueIterator<Key, Value> source, Set<Column> cols, Authorizations auths, byte[] defaultVisibility) throws IOException {
    DeletingIterator delIter = new DeletingIterator(source, false);
    ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter);
    SortedKeyValueIterator<Key, Value> colFilter = ColumnQualifierFilter.wrap(cfsi, cols);
    return VisibilityFilter.wrap(colFilter, auths, defaultVisibility);
}
Also used : ColumnFamilySkippingIterator(org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator) Value(org.apache.accumulo.core.data.Value) DeletingIterator(org.apache.accumulo.core.iterators.system.DeletingIterator) Key(org.apache.accumulo.core.data.Key)

Aggregations

Key (org.apache.accumulo.core.data.Key)4 Value (org.apache.accumulo.core.data.Value)4 ColumnFamilySkippingIterator (org.apache.accumulo.core.iterators.system.ColumnFamilySkippingIterator)4 DeletingIterator (org.apache.accumulo.core.iterators.system.DeletingIterator)4 ArrayList (java.util.ArrayList)2 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)2 MultiIterator (org.apache.accumulo.core.iterators.system.MultiIterator)2 IOException (java.io.IOException)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 FileSKVIterator (org.apache.accumulo.core.file.FileSKVIterator)1 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)1 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)1 Span (org.apache.accumulo.core.trace.Span)1 TabletIteratorEnvironment (org.apache.accumulo.tserver.TabletIteratorEnvironment)1