下面列出了org.apache.hadoop.hbase.io.Reference#isTopFileRegion ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @param fs
* @param p
* @param cacheConf
* @param r
* @param conf
* @param indexMaintainers
* @param viewConstants
* @param regionInfo
* @param regionStartKeyInHFile
* @param splitKey
* @throws IOException
*/
public IndexHalfStoreFileReader(final FileSystem fs, final Path p, final CacheConfig cacheConf,
final Reference r, final Configuration conf,
final Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers,
final byte[][] viewConstants, final HRegionInfo regionInfo,
final byte[] regionStartKeyInHFile, byte[] splitKey) throws IOException {
super(fs, p, cacheConf, conf);
this.splitkey = splitKey == null ? r.getSplitKey() : splitKey;
// Is it top or bottom half?
this.top = Reference.isTopFileRegion(r.getFileRegion());
this.splitRow = CellUtil.cloneRow(KeyValue.createKeyValueFromKey(splitkey));
this.indexMaintainers = indexMaintainers;
this.viewConstants = viewConstants;
this.regionInfo = regionInfo;
this.regionStartKeyInHFile = regionStartKeyInHFile;
this.offset = regionStartKeyInHFile.length;
}
/**
* @param fs
* @param p
* @param cacheConf
* @param in
* @param size
* @param r
* @param conf
* @param indexMaintainers
* @param viewConstants
* @param regionInfo
* @param regionStartKeyInHFile
* @param splitKey
* @throws IOException
*/
public IndexHalfStoreFileReader(final FileSystem fs, final Path p, final CacheConfig cacheConf,
final FSDataInputStreamWrapper in, long size, final Reference r,
final Configuration conf,
final Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers,
final byte[][] viewConstants, final HRegionInfo regionInfo,
byte[] regionStartKeyInHFile, byte[] splitKey) throws IOException {
super(fs, p, in, size, cacheConf, conf);
this.splitkey = splitKey == null ? r.getSplitKey() : splitKey;
// Is it top or bottom half?
this.top = Reference.isTopFileRegion(r.getFileRegion());
this.splitRow = CellUtil.cloneRow(KeyValue.createKeyValueFromKey(splitkey));
this.indexMaintainers = indexMaintainers;
this.viewConstants = viewConstants;
this.regionInfo = regionInfo;
this.regionStartKeyInHFile = regionStartKeyInHFile;
this.offset = regionStartKeyInHFile.length;
}
/**
* helper function to compute HDFS blocks distribution of a given reference file.For reference
* file, we don't compute the exact value. We use some estimate instead given it might be good
* enough. we assume bottom part takes the first half of reference file, top part takes the second
* half of the reference file. This is just estimate, given midkey ofregion != midkey of HFile,
* also the number and size of keys vary. If this estimate isn't good enough, we can improve it
* later.
* @param fs The FileSystem
* @param reference The reference
* @param status The reference FileStatus
* @return HDFS blocks distribution
*/
private static HDFSBlocksDistribution computeRefFileHDFSBlockDistribution(final FileSystem fs,
final Reference reference, final FileStatus status) throws IOException {
if (status == null) {
return null;
}
long start = 0;
long length = 0;
if (Reference.isTopFileRegion(reference.getFileRegion())) {
start = status.getLen() / 2;
length = status.getLen() - status.getLen() / 2;
} else {
start = 0;
length = status.getLen() / 2;
}
return FSUtils.computeHDFSBlocksDistribution(fs, status, start, length);
}
/**
* @param fs
* @param p
* @param cacheConf
* @param in
* @param size
* @param r
* @param conf
* @param indexMaintainers
* @param viewConstants
* @param regionInfo
* @param regionStartKeyInHFile
* @param splitKey
* @throws IOException
*/
public IndexHalfStoreFileReader(final FileSystem fs, final Path p, final CacheConfig cacheConf,
final FSDataInputStreamWrapper in, long size, final Reference r,
final Configuration conf,
final Map<ImmutableBytesWritable, IndexMaintainer> indexMaintainers,
final byte[][] viewConstants, final RegionInfo regionInfo,
byte[] regionStartKeyInHFile, byte[] splitKey, boolean primaryReplicaStoreFile,
AtomicInteger refCount, RegionInfo currentRegion) throws IOException {
super(fs, p, in, size, cacheConf, primaryReplicaStoreFile, refCount, false,
conf);
this.splitkey = splitKey == null ? r.getSplitKey() : splitKey;
// Is it top or bottom half?
this.top = Reference.isTopFileRegion(r.getFileRegion());
this.splitRow = CellUtil.cloneRow(new KeyValue.KeyOnlyKeyValue(splitkey));
this.indexMaintainers = indexMaintainers;
this.viewConstants = viewConstants;
this.childRegionInfo = regionInfo;
this.regionStartKeyInHFile = regionStartKeyInHFile;
this.offset = regionStartKeyInHFile.length;
this.refCount = refCount;
this.currentRegion = currentRegion;
}
/** @return True if the store file is a top Reference */
public boolean isTopReference() {
return this.reference != null && Reference.isTopFileRegion(this.reference.getFileRegion());
}