Class DefaultMobStoreCompactor
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.regionserver.compactions.Compactor
Compactor.CellSinkFactory<S>, Compactor.FileDetails, Compactor.InternalScannerFactory -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean(package private) static ThreadLocal<Boolean>protected booleanprivate static final org.slf4j.Logger(package private) static ThreadLocal<HashMap<String,Long>> (package private) static ThreadLocal<org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName,String>> protected longprotected HMobStoreprivate final Compactor.InternalScannerFactory(package private) static ThreadLocal<Boolean>private final Compactor.CellSinkFactory<StoreFileWriter>Fields inherited from class org.apache.hadoop.hbase.regionserver.compactions.Compactor
COMPACTION_PROGRESS_LOG_INTERVAL, compactionKVMax, compactScannerSizeLimit, conf, defaultScannerFactory, dropCacheMajor, dropCacheMinor, keepSeqIdPeriod, MAJOR_COMPACTION_DROP_CACHE, majorCompactionCompression, MINOR_COMPACTION_DROP_CACHE, minorCompactionCompression, store -
Constructor Summary
ConstructorsConstructorDescriptionDefaultMobStoreCompactor(org.apache.hadoop.conf.Configuration conf, HStore store) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcalculateMobLengthMap(org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName, String> mobRefs) private voidprivate voidcommitOrAbortMobWriter(StoreFileWriter mobFileWriter, long maxSeqId, long mobCells, boolean major) protected List<org.apache.hadoop.fs.Path>commitWriter(StoreFileWriter writer, Compactor.FileDetails fd, CompactionRequestImpl request) List<org.apache.hadoop.fs.Path>compact(CompactionRequestImpl request, ThroughputController throughputController, User user) Do a minor/major compaction on an explicit set of storefiles from a Store.private voiddeleteCommittedMobFiles(List<String> fileNames) protected Stringprivate StoreFileWriternewMobWriter(Compactor.FileDetails fd, boolean major, Consumer<org.apache.hadoop.fs.Path> writerCreationTracker) protected booleanperformCompaction(Compactor.FileDetails fd, InternalScanner scanner, CellSink writer, long smallestReadPoint, boolean cleanSeqId, ThroughputController throughputController, CompactionRequestImpl request, CompactionProgress progress) Performs compaction on a column family with the mob flag enabled.protected ExtendedCellresolveMobCell(ExtendedCell reference) Resolves a MOB reference cell to its backing MOB value and returns an independent, heap-resident copy of the resolved cell.private StoreFileWriterswitchToNewMobWriter(StoreFileWriter mobFileWriter, Compactor.FileDetails fd, long mobCells, boolean major, CompactionRequestImpl request, List<String> committedMobWriterFileNames) Methods inherited from class org.apache.hadoop.hbase.regionserver.compactions.DefaultCompactor
abortWriterMethods inherited from class org.apache.hadoop.hbase.regionserver.compactions.Compactor
compact, createParams, createScanner, createScanner, createWriter, createWriter, decorateCells, getProgress, isCompacting
-
Field Details
-
LOG
-
mobSizeThreshold
-
mobStore
-
ioOptimizedMode
-
cacheMobBlocksOnCompaction
-
mobRefSet
static ThreadLocal<org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName,String>> mobRefSet -
userRequest
-
disableIO
-
mobLengthMap
-
scannerFactory
-
writerFactory
-
-
Constructor Details
-
DefaultMobStoreCompactor
-
-
Method Details
-
resolveMobCell
Resolves a MOB reference cell to its backing MOB value and returns an independent, heap-resident copy of the resolved cell.A MOB cell resolved from a MOB file is backed by a
StoreFileScanner; closing theMobCellcloses that scanner and may release/recycle the NIO buffers referenced by the returned cell. We close theMobCellhere to avoid leaking scanners/buffers while compacting many reference cells.The
KeyValueUtil.copyToNewKeyValue(ExtendedCell)call is required by this ownership model: HFile writers and encoders may retain references to appended cells (e.g.lastCell,firstCellInBlock, and the data block encoder'sprevCell) untilbeforeShipped(). Returning the scanner-backed cell directly would let those later reads access released buffers. Removing this copy would require changing the caller to retain eachMobCelland close it only after the writers have shipped their retained references.- Throws:
IOException
-
compact
public List<org.apache.hadoop.fs.Path> compact(CompactionRequestImpl request, ThroughputController throughputController, User user) throws IOException Description copied from class:DefaultCompactorDo a minor/major compaction on an explicit set of storefiles from a Store.- Overrides:
compactin classDefaultCompactor- Throws:
IOException
-
calculateMobLengthMap
private void calculateMobLengthMap(org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName, String> mobRefs) throws IOException- Parameters:
mobRefs- multimap of original table name -> mob hfile- Throws:
IOException
-
performCompaction
protected boolean performCompaction(Compactor.FileDetails fd, InternalScanner scanner, CellSink writer, long smallestReadPoint, boolean cleanSeqId, ThroughputController throughputController, CompactionRequestImpl request, CompactionProgress progress) throws IOException Performs compaction on a column family with the mob flag enabled. This works only when MOB compaction is explicitly requested (by User), or by Master There are two modes of a MOB compaction:
- 1. Full mode - when all MOB data for a region is compacted into a single MOB file.
- 2. I/O optimized mode - for use cases with no or infrequent updates/deletes of a
MOB data. The main idea behind i/o optimized compaction is to limit maximum size of a MOB file produced during compaction and to limit I/O write/read amplification.
1. If the Put cell has a mob reference tag, the cell's value is the path of the mob file.- If the value size of a cell is larger than the threshold, this cell is regarded as a mob, directly copy the (with mob tag) cell into the new store file.
- Otherwise, retrieve the mob cell from the mob file, and writes a copy of the cell into the new store file.
- If the value size of a cell is larger than the threshold, this cell is regarded as a mob, write this cell to a mob file, and write the path of this mob file to the store file.
- Otherwise, directly write this cell into the store file.
- Overrides:
performCompactionin classCompactor<StoreFileWriter>- Parameters:
fd- File detailsscanner- Where to read from.writer- Where to write to.smallestReadPoint- Smallest read point.cleanSeqId- When true, remove seqId(used to be mvcc) value which is <= smallestReadPointthroughputController- The compaction throughput controller.request- compaction request.progress- Progress reporter.- Returns:
- Whether compaction ended; false if it was interrupted for any reason.
- Throws:
IOException
-
getStoreInfo
-
clearThreadLocals
-
newMobWriter
private StoreFileWriter newMobWriter(Compactor.FileDetails fd, boolean major, Consumer<org.apache.hadoop.fs.Path> writerCreationTracker) throws IOException - Throws:
IOException
-
commitOrAbortMobWriter
private void commitOrAbortMobWriter(StoreFileWriter mobFileWriter, long maxSeqId, long mobCells, boolean major) throws IOException - Throws:
IOException
-
commitWriter
protected List<org.apache.hadoop.fs.Path> commitWriter(StoreFileWriter writer, Compactor.FileDetails fd, CompactionRequestImpl request) throws IOException - Overrides:
commitWriterin classDefaultCompactor- Throws:
IOException
-
switchToNewMobWriter
private StoreFileWriter switchToNewMobWriter(StoreFileWriter mobFileWriter, Compactor.FileDetails fd, long mobCells, boolean major, CompactionRequestImpl request, List<String> committedMobWriterFileNames) throws IOException - Throws:
IOException
-
deleteCommittedMobFiles
-