Class StoreFileWriter
java.lang.Object
org.apache.hadoop.hbase.regionserver.StoreFileWriter
- All Implemented Interfaces:
CellSink,ShipperListener
A StoreFile writer. Use this to read/write HBase Store Files. It is package local because it is
an implementation detail of the HBase regionserver.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BloomContextprivate byte[]private final BloomTypeprivate final Supplier<Collection<HStoreFile>>private static final Patternprivate BloomContextprivate final BloomFilterWriterprivate longprivate longprivate final BloomFilterWriterprivate static final org.slf4j.Loggerprivate final TimeRangeTrackerprotected HFile.Writer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateStoreFileWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, CacheConfig cacheConf, BloomType bloomType, long maxKeys, InetSocketAddress[] favoredNodes, HFileContext fileContext, boolean shouldDropCacheBehind, Supplier<Collection<HStoreFile>> compactedFilesSupplier) Creates an HFile.Writer that also write helpful meta data. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend the given cellprivate voidvoidappendFileInfo(byte[] key, byte[] value) private voidappendGeneralBloomfilter(Cell cell) voidappendMetadata(long maxSequenceId, boolean majorCompaction) Writes meta data.voidappendMetadata(long maxSequenceId, boolean majorCompaction, long mobCellsCount) Writes meta data.voidappendMetadata(long maxSequenceId, boolean majorCompaction, Collection<HStoreFile> storeFiles) Writes meta data.voidappendMobMetadata(org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName, String> mobRefSet) Appends MOB - specific metadata (even if it is empty)voidAdd TimestampRange and earliest put timestamp to MetadatavoidThe action that needs to be performed beforeShipper.shipped()is performedvoidclose()private booleanprivate booleanprivate boolean(package private) BloomFilterWriterFor unit testing only.(package private) HFile.WriterFor use in testing.org.apache.hadoop.fs.PathgetPath()longgetPos()static org.apache.hadoop.fs.PathgetUniqueFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) booleanprivate byte[]toCompactionEventTrackerBytes(Collection<HStoreFile> storeFiles) Used when writeHStoreFile.COMPACTION_EVENT_KEYto new file's file info.voidtrackTimestamps(Cell cell) Record the earlest Put timestamp.
-
Field Details
-
LOG
-
dash
-
generalBloomFilterWriter
-
deleteFamilyBloomFilterWriter
-
bloomType
-
bloomParam
-
earliestPutTs
-
deleteFamilyCnt
-
bloomContext
-
deleteFamilyBloomContext
-
timeRangeTracker
-
compactedFilesSupplier
-
writer
-
-
Constructor Details
-
StoreFileWriter
private StoreFileWriter(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf, CacheConfig cacheConf, BloomType bloomType, long maxKeys, InetSocketAddress[] favoredNodes, HFileContext fileContext, boolean shouldDropCacheBehind, Supplier<Collection<HStoreFile>> compactedFilesSupplier) throws IOException Creates an HFile.Writer that also write helpful meta data.- Parameters:
fs- file system to write topath- file name to createconf- user configurationbloomType- bloom filter settingmaxKeys- the expected maximum number of keys to be added. Was used for Bloom filter size inHFileformat version 1.favoredNodes- an array of favored nodes or possibly nullfileContext- The HFile contextshouldDropCacheBehind- Drop pages written to page cache after writing the store file.compactedFilesSupplier- Returns theHStorecompacted files which not archived- Throws:
IOException- problem writing to FS
-
-
Method Details
-
getPos
- Throws:
IOException
-
appendMetadata
Writes meta data. Call beforeclose()since its written as meta data to this file.- Parameters:
maxSequenceId- Maximum sequence id.majorCompaction- True if this file is product of a major compaction- Throws:
IOException- problem writing to FS
-
appendMetadata
public void appendMetadata(long maxSequenceId, boolean majorCompaction, Collection<HStoreFile> storeFiles) throws IOException Writes meta data. Call beforeclose()since its written as meta data to this file.- Parameters:
maxSequenceId- Maximum sequence id.majorCompaction- True if this file is product of a major compactionstoreFiles- The compacted store files to generate this new file- Throws:
IOException- problem writing to FS
-
toCompactionEventTrackerBytes
Used when writeHStoreFile.COMPACTION_EVENT_KEYto new file's file info. The compacted store files's name is needed. But if the compacted store file is a result of compaction, it's compacted files which still not archived is needed, too. And don't need to add compacted files recursively. If file A, B, C compacted to new file D, and file D compacted to new file E, will write A, B, C, D to file E's compacted files. So if file E compacted to new file F, will add E to F's compacted files first, then add E's compacted files: A, B, C, D to it. And no need to add D's compacted file, as D's compacted files has been in E's compacted files, too. See HBASE-20724 for more details.- Parameters:
storeFiles- The compacted store files to generate this new file- Returns:
- bytes of CompactionEventTracker
-
appendMetadata
public void appendMetadata(long maxSequenceId, boolean majorCompaction, long mobCellsCount) throws IOException Writes meta data. Call beforeclose()since its written as meta data to this file.- Parameters:
maxSequenceId- Maximum sequence id.majorCompaction- True if this file is product of a major compactionmobCellsCount- The number of mob cells.- Throws:
IOException- problem writing to FS
-
appendMobMetadata
public void appendMobMetadata(org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName, String> mobRefSet) throws IOExceptionAppends MOB - specific metadata (even if it is empty)- Parameters:
mobRefSet- - original table -> set of MOB file names- Throws:
IOException- problem writing to FS
-
appendTrackedTimestampsToMetadata
Add TimestampRange and earliest put timestamp to Metadata- Throws:
IOException
-
trackTimestamps
Record the earlest Put timestamp. If the timeRangeTracker is not set, update TimeRangeTracker to include the timestamp of this key -
appendGeneralBloomfilter
- Throws:
IOException
-
appendDeleteFamilyBloomFilter
- Throws:
IOException
-
append
Description copied from interface:CellSinkAppend the given cell- Specified by:
appendin interfaceCellSink- Parameters:
cell- the cell to be added- Throws:
IOException
-
beforeShipped
Description copied from interface:ShipperListenerThe action that needs to be performed beforeShipper.shipped()is performed- Specified by:
beforeShippedin interfaceShipperListener- Throws:
IOException
-
getPath
-
hasGeneralBloom
-
getGeneralBloomWriter
For unit testing only.- Returns:
- the Bloom filter used by this writer.
-
closeBloomFilter
- Throws:
IOException
-
closeGeneralBloomFilter
- Throws:
IOException
-
closeDeleteFamilyBloomFilter
- Throws:
IOException
-
close
- Throws:
IOException
-
appendFileInfo
- Throws:
IOException
-
getHFileWriter
For use in testing. -
getUniqueFile
public static org.apache.hadoop.fs.Path getUniqueFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) throws IOException - Parameters:
dir- Directory to create file in.- Returns:
- random filename inside passed
dir - Throws:
IOException
-