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
-
Field Summary
Modifier and TypeFieldDescriptionprivate BloomContext
private byte[]
private final BloomType
private final Supplier<Collection<HStoreFile>>
private static final Pattern
private BloomContext
private final BloomFilterWriter
private long
private long
private final BloomFilterWriter
private static final org.slf4j.Logger
private final TimeRangeTracker
protected HFile.Writer
-
Constructor Summary
ModifierConstructorDescriptionprivate
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) Creates an HFile.Writer that also write helpful meta data. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append the given cellprivate void
void
appendFileInfo
(byte[] key, byte[] value) private void
appendGeneralBloomfilter
(Cell cell) void
appendMetadata
(long maxSequenceId, boolean majorCompaction) Writes meta data.void
appendMetadata
(long maxSequenceId, boolean majorCompaction, long mobCellsCount) Writes meta data.void
appendMetadata
(long maxSequenceId, boolean majorCompaction, Collection<HStoreFile> storeFiles) Writes meta data.void
appendMobMetadata
(org.apache.hbase.thirdparty.com.google.common.collect.SetMultimap<TableName, String> mobRefSet) Appends MOB - specific metadata (even if it is empty)void
Add TimestampRange and earliest put timestamp to Metadatavoid
The action that needs to be performed beforeShipper.shipped()
is performedvoid
close()
private boolean
private boolean
private boolean
(package private) BloomFilterWriter
For unit testing only.(package private) HFile.Writer
For use in testing.org.apache.hadoop.fs.Path
getPath()
long
getPos()
static org.apache.hadoop.fs.Path
getUniqueFile
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) boolean
private byte[]
toCompactionEventTrackerBytes
(Collection<HStoreFile> storeFiles) Used when writeHStoreFile.COMPACTION_EVENT_KEY
to new file's file info.void
trackTimestamps
(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 inHFile
format 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 theHStore
compacted 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_KEY
to 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:CellSink
Append the given cell- Specified by:
append
in interfaceCellSink
- Parameters:
cell
- the cell to be added- Throws:
IOException
-
beforeShipped
Description copied from interface:ShipperListener
The action that needs to be performed beforeShipper.shipped()
is performed- Specified by:
beforeShipped
in 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
-