Search in sources :

Example 1 with MetaBlockDoesNotExist

use of org.apache.accumulo.core.file.rfile.bcfile.MetaBlockDoesNotExist in project accumulo by apache.

the class SummaryReader method load.

private static List<SummarySerializer> load(BlockReader bcReader, Predicate<SummarizerConfiguration> summarySelector) throws IOException {
    try (DataInputStream in = bcReader.getMetaBlock(SummaryWriter.METASTORE_INDEX)) {
        List<SummarySerializer> stores = new ArrayList<>();
        readHeader(in);
        int numSummaries = WritableUtils.readVInt(in);
        for (int i = 0; i < numSummaries; i++) {
            SummarizerConfiguration conf = readConfig(in);
            boolean inline = in.readBoolean();
            if (inline) {
                if (summarySelector.test(conf)) {
                    stores.add(SummarySerializer.load(conf, in));
                } else {
                    SummarySerializer.skip(in);
                }
            } else {
                int block = WritableUtils.readVInt(in);
                int offset = WritableUtils.readVInt(in);
                if (summarySelector.test(conf)) {
                    try (DataInputStream summaryIn = bcReader.getMetaBlock(SummaryWriter.METASTORE_PREFIX + "." + block)) {
                        long skipped = in.skip(offset);
                        while (skipped < offset) {
                            skipped += in.skip(offset - skipped);
                        }
                        stores.add(SummarySerializer.load(conf, summaryIn));
                    } catch (MetaBlockDoesNotExist e) {
                        // this is unexpected
                        throw new IOException(e);
                    }
                }
            }
        }
        return stores;
    } catch (MetaBlockDoesNotExist e) {
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) MetaBlockDoesNotExist(org.apache.accumulo.core.file.rfile.bcfile.MetaBlockDoesNotExist) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) DataInputStream(java.io.DataInputStream) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration)

Aggregations

DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 ArrayList (java.util.ArrayList)1 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)1 MetaBlockDoesNotExist (org.apache.accumulo.core.file.rfile.bcfile.MetaBlockDoesNotExist)1