Package org.iq80.leveldb.impl
Class DbImpl
java.lang.Object
org.iq80.leveldb.impl.DbImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Map.Entry<byte[],,byte[]>> DB
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprivate static classstatic classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Future<?> private final Conditionprivate Throwableprivate final ExecutorServiceprivate final Fileprivate final DbLockprivate MemTableprivate final InternalKeyComparatorprivate LogWriterprivate DbImpl.ManualCompactionprivate MemTableprivate final ReentrantLockprivate final Optionsprivate final AtomicBooleanprivate intprivate final Objectprivate final TableCacheprivate final VersionSet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidprivate FileMetaDatabuildTable(SeekingIterable<InternalKey, Slice> data, long fileNumber) voidprivate voidcleanupCompaction(DbImpl.CompactionState compactionState) voidclose()voidprivate voidvoidcompactRange(byte[] begin, byte[] end) Force a compaction of the specified key range.voidcompactRange(int level, Slice start, Slice end) voiddelete(byte[] key) delete(byte[] key, WriteOptions options) private voidprivate voiddoCompactionWork(DbImpl.CompactionState compactionState) private voidfinishCompactionOutputFile(DbImpl.CompactionState compactionState) voidbyte[]get(byte[] key) byte[]get(byte[] key, ReadOptions options) longgetApproximateSizes(Range range) long[]getApproximateSizes(Range... ranges) longgetProperty(String name) private SnapshotImplgetSnapshot(ReadOptions options) private void(package private) SeekingIterable<InternalKey, Slice> (package private) DbIteratoriterator()iterator(ReadOptions options) private voidmakeRoomForWrite(boolean force) private void(package private) intnumberOfFilesInLevel(int level) private voidopenCompactionOutputFile(DbImpl.CompactionState compactionState) voidput(byte[] key, byte[] value) put(byte[] key, byte[] value, WriteOptions options) private WriteBatchImplreadWriteBatch(SliceInput record, int updateSize) private longrecoverLogFile(long fileNumber, VersionEdit edit) voidResumes the background compaction threads.voidSuspends any background compaction threads.voidwrite(WriteBatch updates) write(WriteBatch updates, WriteOptions options) writeInternal(WriteBatchImpl updates, WriteOptions options) private voidwriteLevel0Table(MemTable mem, VersionEdit edit, Version base) private SlicewriteWriteBatch(WriteBatchImpl updates, long sequenceBegin) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
options
-
databaseDir
-
tableCache
-
dbLock
-
versions
-
shuttingDown
-
mutex
-
backgroundCondition
-
pendingOutputs
-
log
-
memTable
-
immutableMemTable
-
internalKeyComparator
-
backgroundException
-
compactionExecutor
-
backgroundCompaction
-
manualCompaction
-
suspensionMutex
-
suspensionCounter
private int suspensionCounter
-
-
Constructor Details
-
DbImpl
- Throws:
IOException
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getProperty
- Specified by:
getPropertyin interfaceDB
-
deleteObsoleteFiles
private void deleteObsoleteFiles() -
flushMemTable
public void flushMemTable() -
compactRange
-
maybeScheduleCompaction
private void maybeScheduleCompaction() -
checkBackgroundException
public void checkBackgroundException() -
backgroundCall
- Throws:
IOException
-
backgroundCompaction
- Throws:
IOException
-
cleanupCompaction
-
recoverLogFile
- Throws:
IOException
-
get
- Specified by:
getin interfaceDB- Throws:
DBException
-
get
- Specified by:
getin interfaceDB- Throws:
DBException
-
put
- Specified by:
putin interfaceDB- Throws:
DBException
-
put
- Specified by:
putin interfaceDB- Returns:
- null if options.isSnapshot()==false otherwise returns a snapshot of the DB after this operation.
- Throws:
DBException
-
delete
- Specified by:
deletein interfaceDB- Throws:
DBException
-
delete
- Specified by:
deletein interfaceDB- Returns:
- null if options.isSnapshot()==false otherwise returns a snapshot of the DB after this operation.
- Throws:
DBException
-
write
- Specified by:
writein interfaceDB- Throws:
DBException
-
write
- Specified by:
writein interfaceDB- Returns:
- null if options.isSnapshot()==false otherwise returns a snapshot of the DB after this operation.
- Throws:
DBException
-
writeInternal
- Throws:
DBException
-
createWriteBatch
- Specified by:
createWriteBatchin interfaceDB
-
iterator
-
iterator
-
internalIterable
SeekingIterable<InternalKey,Slice> internalIterable() -
internalIterator
DbIterator internalIterator() -
getSnapshot
- Specified by:
getSnapshotin interfaceDB
-
getSnapshot
-
makeRoomForWrite
private void makeRoomForWrite(boolean force) -
compactMemTable
- Throws:
IOException
-
compactMemTableInternal
- Throws:
IOException
-
writeLevel0Table
- Throws:
IOException
-
buildTable
private FileMetaData buildTable(SeekingIterable<InternalKey, Slice> data, long fileNumber) throws IOException- Throws:
IOException
-
doCompactionWork
- Throws:
IOException
-
openCompactionOutputFile
private void openCompactionOutputFile(DbImpl.CompactionState compactionState) throws FileNotFoundException - Throws:
FileNotFoundException
-
finishCompactionOutputFile
- Throws:
IOException
-
installCompactionResults
- Throws:
IOException
-
numberOfFilesInLevel
int numberOfFilesInLevel(int level) -
getApproximateSizes
- Specified by:
getApproximateSizesin interfaceDB
-
getApproximateSizes
-
getMaxNextLevelOverlappingBytes
public long getMaxNextLevelOverlappingBytes() -
readWriteBatch
- Throws:
IOException
-
writeWriteBatch
-
suspendCompactions
Description copied from interface:DBSuspends any background compaction threads. This methods returns once the background compactions are suspended.- Specified by:
suspendCompactionsin interfaceDB- Throws:
InterruptedException
-
resumeCompactions
public void resumeCompactions()Description copied from interface:DBResumes the background compaction threads.- Specified by:
resumeCompactionsin interfaceDB
-
compactRange
Description copied from interface:DBForce a compaction of the specified key range.- Specified by:
compactRangein interfaceDB- Parameters:
begin- if null then compaction start from the first keyend- if null then compaction ends at the last key- Throws:
DBException
-