/** * Try to add this reader at the bottom of the stack. * <p> * A reader may be rejected by returning {@code false} if the compactor is * already rewriting its {@link #setCompactBytesLimit(long)}. When this * happens the caller should stop trying to add tables, and execute the * compaction. * * @param reader * the reader to insert at the bottom of the stack. Caller is * responsible for closing the reader. * @return {@code true} if the compactor accepted this table; {@code false} * if the compactor has reached its limit. * @throws java.io.IOException * if size of {@code reader}, or its update indexes cannot be read. */ public boolean tryAddFirst(ReftableReader reader) throws IOException { long sz = reader.size(); if (compactBytesLimit > 0 && bytesToCompact + sz > compactBytesLimit) { return false; } bytesToCompact += sz; adjustUpdateIndexes(reader); tables.addFirst(reader); return true; }
private boolean canCompactTopOfStack(ReftableConfig cfg) throws IOException { ReftableStack stack = refdb.stack(); List<Reftable> readers = stack.readers(); if (readers.isEmpty()) { return false; } int lastIdx = readers.size() - 1; DfsReftable last = stack.files().get(lastIdx); DfsPackDescription desc = last.getPackDescription(); if (desc.getPackSource() != PackSource.INSERT || !packOnlyContainsReftable(desc)) { return false; } Reftable table = readers.get(lastIdx); int bs = cfg.getRefBlockSize(); return table instanceof ReftableReader && ((ReftableReader) table).size() <= 3 * bs; }
/** * Try to add this reader at the bottom of the stack. * <p> * A reader may be rejected by returning {@code false} if the compactor is * already rewriting its {@link #setCompactBytesLimit(long)}. When this * happens the caller should stop trying to add tables, and execute the * compaction. * * @param reader * the reader to insert at the bottom of the stack. Caller is * responsible for closing the reader. * @return {@code true} if the compactor accepted this table; {@code false} * if the compactor has reached its limit. * @throws java.io.IOException * if size of {@code reader}, or its update indexes cannot be read. */ public boolean tryAddFirst(ReftableReader reader) throws IOException { long sz = reader.size(); if (compactBytesLimit > 0 && bytesToCompact + sz > compactBytesLimit) { return false; } bytesToCompact += sz; adjustUpdateIndexes(reader); tables.addFirst(reader); return true; }
private boolean canCompactTopOfStack(ReftableConfig cfg) throws IOException { ReftableStack stack = refdb.stack(); List<Reftable> readers = stack.readers(); if (readers.isEmpty()) { return false; } int lastIdx = readers.size() - 1; DfsReftable last = stack.files().get(lastIdx); DfsPackDescription desc = last.getPackDescription(); if (desc.getPackSource() != PackSource.INSERT || !packOnlyContainsReftable(desc)) { return false; } Reftable table = readers.get(lastIdx); int bs = cfg.getRefBlockSize(); return table instanceof ReftableReader && ((ReftableReader) table).size() <= 3 * bs; }