@InterfaceAudience.Private public class StripeStoreFileManager extends Object implements StoreFileManager, StripeCompactionPolicy.StripeInformationProvider
Modifier and Type | Class and Description |
---|---|
private class |
StripeStoreFileManager.CompactionOrFlushMergeCopy
Non-static helper class for merging compaction or flush results.
|
private static class |
StripeStoreFileManager.KeyBeforeConcatenatedLists
An extension of ConcatenatedLists that has several peculiar properties.
|
private static class |
StripeStoreFileManager.State
The state class.
|
Modifier and Type | Field and Description |
---|---|
private int |
blockingFileCount |
private StripeStoreConfig |
config |
private HashMap<StoreFile,byte[]> |
fileEnds |
private HashMap<StoreFile,byte[]> |
fileStarts
Cached file metadata (or overrides as the case may be)
|
(package private) static byte[] |
INVALID_KEY |
private static byte[] |
INVALID_KEY_IN_MAP
Normally invalid key is null, but in the map null is the result for "no key"; so use
the following constant value in these maps instead.
|
private KeyValue.KVComparator |
kvComparator |
private static org.apache.commons.logging.Log |
LOG |
private static Bytes.RowEndKeyComparator |
MAP_COMPARATOR |
static byte[] |
OPEN_KEY
The key value used for range boundary, indicating that the boundary is open (i.e.
|
private StripeStoreFileManager.State |
state |
static byte[] |
STRIPE_END_KEY |
static byte[] |
STRIPE_START_KEY
The file metadata fields that contain the stripe information.
|
Constructor and Description |
---|
StripeStoreFileManager(KeyValue.KVComparator kvComparator,
org.apache.hadoop.conf.Configuration conf,
StripeStoreConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
addCompactionResults(Collection<StoreFile> compactedFiles,
Collection<StoreFile> results)
Adds compaction results into the structure.
|
com.google.common.collect.ImmutableCollection<StoreFile> |
clearFiles()
Clears all the files currently in use and returns them.
|
private void |
debugDumpState(String string) |
private byte[] |
endOf(StoreFile sf) |
private void |
ensureEdgeStripeMetadata(ArrayList<StoreFile> stripe,
boolean isFirst) |
private void |
ensureLevel0Metadata(StoreFile sf) |
private Collection<StoreFile> |
findExpiredFiles(com.google.common.collect.ImmutableList<StoreFile> stripe,
long maxTs,
List<StoreFile> filesCompacting,
Collection<StoreFile> expiredStoreFiles) |
private int |
findStripeForRow(byte[] row,
boolean isStart)
Finds the stripe index for the stripe containing a row provided externally for get/scan.
|
private int |
findStripeIndexByEndRow(byte[] endRow)
Finds the stripe index by end row.
|
Iterator<StoreFile> |
getCandidateFilesForRowKeyBefore(KeyValue targetKey)
See
StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue)
for details on this methods. |
double |
getCompactionPressure() |
byte[] |
getEndRow(int stripeIndex)
Gets the end row for a given stripe.
|
Collection<StoreFile> |
getFilesForScanOrGet(boolean isGet,
byte[] startRow,
byte[] stopRow)
Gets the store files to scan for a Scan or Get request.
|
List<StoreFile> |
getLevel0Files() |
private double |
getMidStripeSplitRatio(long smallerSize,
long largerSize,
long lastLargerSize) |
byte[] |
getSplitPoint()
Gets the split point for the split of this set of store files (approx.
|
private byte[] |
getSplitPointFromAllFiles() |
byte[] |
getStartRow(int stripeIndex)
Gets the start row for a given stripe.
|
int |
getStoreCompactionPriority() |
int |
getStorefileCount()
Returns the number of files currently in use.
|
Collection<StoreFile> |
getStorefiles()
Gets the snapshot of the store files currently in use.
|
List<byte[]> |
getStripeBoundaries() |
int |
getStripeCount() |
private long |
getStripeFilesSize(int stripeIndex)
Gets the total size of all files in the stripe.
|
ArrayList<com.google.common.collect.ImmutableList<StoreFile>> |
getStripes() |
Collection<StoreFile> |
getUnneededFiles(long maxTs,
List<StoreFile> filesCompacting) |
private static void |
insertFileIntoStripe(ArrayList<StoreFile> stripe,
StoreFile sf)
Inserts a file in the correct place (by seqnum) in a stripe copy.
|
void |
insertNewFiles(Collection<StoreFile> sfs)
Adds new files, either for from MemStore flush or bulk insert, into the structure.
|
private static boolean |
isInvalid(byte[] key)
Checks whether the key is invalid (e.g.
|
private static boolean |
isOpen(byte[] key)
Checks whether the key indicates an open interval boundary (i.e.
|
void |
loadFiles(List<StoreFile> storeFiles)
Loads the initial store files into empty StoreFileManager.
|
private void |
loadUnclassifiedStoreFiles(List<StoreFile> storeFiles)
Loads initial store files that were picked up from some physical location pertaining to
this store (presumably).
|
private int |
nonOpenRowCompare(byte[] k1,
byte[] k2)
Compare two keys.
|
private boolean |
rowEquals(byte[] k1,
byte[] k2)
Compare two keys for equality.
|
private byte[] |
startOf(StoreFile sf) |
Iterator<StoreFile> |
updateCandidateFilesForRowKeyBefore(Iterator<StoreFile> candidateFiles,
KeyValue targetKey,
Cell candidate)
See
StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue) and
StoreFileManager.updateCandidateFilesForRowKeyBefore(Iterator, KeyValue, Cell)
for details on this methods. |
private static final org.apache.commons.logging.Log LOG
public static final byte[] STRIPE_START_KEY
public static final byte[] STRIPE_END_KEY
private static final Bytes.RowEndKeyComparator MAP_COMPARATOR
public static final byte[] OPEN_KEY
static final byte[] INVALID_KEY
private StripeStoreFileManager.State state
private HashMap<StoreFile,byte[]> fileStarts
private static final byte[] INVALID_KEY_IN_MAP
private final KeyValue.KVComparator kvComparator
private StripeStoreConfig config
private final int blockingFileCount
public StripeStoreFileManager(KeyValue.KVComparator kvComparator, org.apache.hadoop.conf.Configuration conf, StripeStoreConfig config)
public void loadFiles(List<StoreFile> storeFiles)
StoreFileManager
loadFiles
in interface StoreFileManager
storeFiles
- The files to load.public Collection<StoreFile> getStorefiles()
StoreFileManager
getStorefiles
in interface StripeCompactionPolicy.StripeInformationProvider
getStorefiles
in interface StoreFileManager
public void insertNewFiles(Collection<StoreFile> sfs) throws IOException
StoreFileManager
insertNewFiles
in interface StoreFileManager
sfs
- New store files.IOException
public com.google.common.collect.ImmutableCollection<StoreFile> clearFiles()
StoreFileManager
clearFiles
in interface StoreFileManager
public int getStorefileCount()
StoreFileManager
getStorefileCount
in interface StoreFileManager
public Iterator<StoreFile> getCandidateFilesForRowKeyBefore(KeyValue targetKey)
StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue)
for details on this methods.getCandidateFilesForRowKeyBefore
in interface StoreFileManager
targetKey
- The key that is the basis of the search.public Iterator<StoreFile> updateCandidateFilesForRowKeyBefore(Iterator<StoreFile> candidateFiles, KeyValue targetKey, Cell candidate)
StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue)
and
StoreFileManager.updateCandidateFilesForRowKeyBefore(Iterator, KeyValue, Cell)
for details on this methods.updateCandidateFilesForRowKeyBefore
in interface StoreFileManager
candidateFiles
- The candidate files not yet checked for better candidates - return
value from StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue)
,
with some files already removed.targetKey
- The key to search for.candidate
- The current best candidate found.public byte[] getSplitPoint() throws IOException
StoreFileManager
getSplitPoint
in interface StoreFileManager
IOException
private byte[] getSplitPointFromAllFiles() throws IOException
IOException
private double getMidStripeSplitRatio(long smallerSize, long largerSize, long lastLargerSize)
public Collection<StoreFile> getFilesForScanOrGet(boolean isGet, byte[] startRow, byte[] stopRow)
StoreFileManager
getFilesForScanOrGet
in interface StoreFileManager
isGet
- Whether it's a get.startRow
- Start row of the request.stopRow
- Stop row of the request.public void addCompactionResults(Collection<StoreFile> compactedFiles, Collection<StoreFile> results) throws IOException
StoreFileManager
addCompactionResults
in interface StoreFileManager
compactedFiles
- The input files for the compaction.results
- The resulting files for the compaction.IOException
public int getStoreCompactionPriority()
getStoreCompactionPriority
in interface StoreFileManager
private long getStripeFilesSize(int stripeIndex)
stripeIndex
- Stripe index.private void loadUnclassifiedStoreFiles(List<StoreFile> storeFiles)
storeFiles
- Store files to add.private void ensureEdgeStripeMetadata(ArrayList<StoreFile> stripe, boolean isFirst)
private void ensureLevel0Metadata(StoreFile sf)
private void debugDumpState(String string)
private static final boolean isOpen(byte[] key)
private static final boolean isInvalid(byte[] key)
private final boolean rowEquals(byte[] k1, byte[] k2)
private final int nonOpenRowCompare(byte[] k1, byte[] k2)
private final int findStripeIndexByEndRow(byte[] endRow)
private final int findStripeForRow(byte[] row, boolean isStart)
public final byte[] getStartRow(int stripeIndex)
StripeCompactionPolicy.StripeInformationProvider
getStartRow
in interface StripeCompactionPolicy.StripeInformationProvider
stripeIndex
- Stripe index.public final byte[] getEndRow(int stripeIndex)
StripeCompactionPolicy.StripeInformationProvider
getEndRow
in interface StripeCompactionPolicy.StripeInformationProvider
stripeIndex
- Stripe index.private byte[] startOf(StoreFile sf)
private byte[] endOf(StoreFile sf)
private static void insertFileIntoStripe(ArrayList<StoreFile> stripe, StoreFile sf)
stripe
- Stripe copy to insert into.sf
- File to insert.public List<StoreFile> getLevel0Files()
getLevel0Files
in interface StripeCompactionPolicy.StripeInformationProvider
public List<byte[]> getStripeBoundaries()
getStripeBoundaries
in interface StripeCompactionPolicy.StripeInformationProvider
public ArrayList<com.google.common.collect.ImmutableList<StoreFile>> getStripes()
getStripes
in interface StripeCompactionPolicy.StripeInformationProvider
public int getStripeCount()
getStripeCount
in interface StripeCompactionPolicy.StripeInformationProvider
public Collection<StoreFile> getUnneededFiles(long maxTs, List<StoreFile> filesCompacting)
getUnneededFiles
in interface StoreFileManager
maxTs
- Maximum expired timestamp.filesCompacting
- Files that are currently compacting.private Collection<StoreFile> findExpiredFiles(com.google.common.collect.ImmutableList<StoreFile> stripe, long maxTs, List<StoreFile> filesCompacting, Collection<StoreFile> expiredStoreFiles)
public double getCompactionPressure()
getCompactionPressure
in interface StoreFileManager
Store.getCompactionPressure()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.