@Override public long bufferSize() { return getCurrent().dataSize(); }
private SortedBuffer<Integer> flipBuffer() { final SortedBuffer<Integer> sb; sb = getCurrent(); SortedBuffer<Integer> next = new SortedBuffer<Integer>( factory.getConfiguration(), bufferCount.incrementAndGet()); current.set(next); if (logger.fineEnabled()) { logger.fine(String.format("Switching from buffer %s to %s", sb, next)); } return sb; }
@Override public SortedStatistics getStatistics() throws IOException { List<SortedStatistics> stats = new ArrayList<SortedStatistics>(); Collection<TrackedReference<SortedOplogReader>> soplogs; // snapshot, this is expensive rwlock.readLock().lock(); try { stats.add(getCurrent().getStatistics()); for (SortedBuffer<Integer> sb : unflushed) { stats.add(sb.getStatistics()); } soplogs = compactor.getActiveReaders(null, null); } finally { rwlock.readLock().unlock(); } for (TrackedReference<SortedOplogReader> tr : soplogs) { stats.add(tr.get().getStatistics()); } return new MergedStatistics(stats, soplogs); }
if (getCurrent().mightContain(key)) { return true;
@Override public SortedIterator<ByteBuffer> scan( byte[] from, boolean fromInclusive, byte[] to, boolean toInclusive, boolean ascending, MetadataFilter filter) throws IOException { SerializedComparator sc = factory.getConfiguration().getComparator(); sc = ascending ? sc : ReversingSerializedComparator.reverse(sc); List<SortedIterator<ByteBuffer>> scans = new ArrayList<SortedIterator<ByteBuffer>>(); Collection<TrackedReference<SortedOplogReader>> soplogs; rwlock.readLock().lock(); try { scans.add(getCurrent().scan(from, fromInclusive, to, toInclusive, ascending, filter)); for (SortedBuffer<Integer> sb : unflushed) { scans.add(sb.scan(from, fromInclusive, to, toInclusive, ascending, filter)); } soplogs = compactor.getActiveReaders(from, to); } finally { rwlock.readLock().unlock(); } for (TrackedReference<SortedOplogReader> tr : soplogs) { scans.add(tr.get().scan(from, fromInclusive, to, toInclusive, ascending, filter)); } return new MergedIterator(sc, soplogs, scans); }
ByteBuffer val = getCurrent().read(key); if (val != null) { return val;
@Override public void put(byte[] key, byte[] value) { assert key != null; assert value != null; long start = factory.getConfiguration().getStatistics().getPut().begin(); getCurrent().put(key, value); factory.getConfiguration().getStatistics().getPut().end(value.length, start); }