/** * Write a compaction to {@code out}. * * @param out * stream to write the compacted tables to. Caller is responsible * for closing {@code out}. * @throws java.io.IOException * if tables cannot be read, or cannot be written. */ public void compact(OutputStream out) throws IOException { MergedReftable mr = new MergedReftable(new ArrayList<>(tables)); mr.setIncludeDeletes(includeDeletes); writer.setMinUpdateIndex(Math.max(minUpdateIndex, 0)); writer.setMaxUpdateIndex(maxUpdateIndex); writer.begin(out); mergeRefs(mr); mergeLogs(mr); writer.finish(); stats = writer.getStats(); }
MergedRefCursor() { queue = new PriorityQueue<>(queueSize(), RefQueueEntry::compare); }
private void mergeRefs(MergedReftable mr) throws IOException { try (RefCursor rc = mr.allRefs()) { while (rc.next()) { writer.writeRef(rc.getRef(), rc.getUpdateIndex()); } } }
/** * Obtain a handle to the merged reader. * * @return (possibly cached) handle to the merged reader. * @throws java.io.IOException * if tables cannot be opened. */ protected Reftable reader() throws IOException { lock.lock(); try { if (mergedTables == null) { mergedTables = new MergedReftable(stack().readers()); } return mergedTables; } finally { lock.unlock(); } }
try (LogCursor lc = mr.allLogs()) { while (lc.next()) { long updateIndex = lc.getUpdateIndex();
private void mergeRefs(MergedReftable mr) throws IOException { try (RefCursor rc = mr.allRefs()) { while (rc.next()) { writer.writeRef(rc.getRef(), rc.getUpdateIndex()); } } }
/** * Obtain a handle to the merged reader. * * @return (possibly cached) handle to the merged reader. * @throws java.io.IOException * if tables cannot be opened. */ protected Reftable reader() throws IOException { lock.lock(); try { if (mergedTables == null) { mergedTables = new MergedReftable(stack().readers()); } return mergedTables; } finally { lock.unlock(); } }
try (LogCursor lc = mr.allLogs()) { while (lc.next()) { long updateIndex = lc.getUpdateIndex();
/** * Write a compaction to {@code out}. * * @param out * stream to write the compacted tables to. Caller is responsible * for closing {@code out}. * @throws java.io.IOException * if tables cannot be read, or cannot be written. */ public void compact(OutputStream out) throws IOException { MergedReftable mr = new MergedReftable(new ArrayList<>(tables)); mr.setIncludeDeletes(includeDeletes); writer.setMinUpdateIndex(Math.max(minUpdateIndex, 0)); writer.setMaxUpdateIndex(maxUpdateIndex); writer.begin(out); mergeRefs(mr); mergeLogs(mr); writer.finish(); stats = writer.getStats(); }
MergedLogCursor() { queue = new PriorityQueue<>(queueSize(), LogQueueEntry::compare); }
MergedRefCursor() { queue = new PriorityQueue<>(queueSize(), RefQueueEntry::compare); }
MergedLogCursor() { queue = new PriorityQueue<>(queueSize(), LogQueueEntry::compare); }