本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.StoreFileScanner.seek方法的典型用法代码示例。如果您正苦于以下问题:Java StoreFileScanner.seek方法的具体用法?Java StoreFileScanner.seek怎么用?Java StoreFileScanner.seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.regionserver.StoreFileScanner
的用法示例。
在下文中一共展示了StoreFileScanner.seek方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readCell
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* Reads a cell from the mob file.
* @param search The cell need to be searched in the mob file.
* @param cacheMobBlocks Should this scanner cache blocks.
* @param readPt the read point.
* @return The cell in the mob file.
* @throws IOException
*/
public Cell readCell(Cell search, boolean cacheMobBlocks, long readPt) throws IOException {
Cell result = null;
StoreFileScanner scanner = null;
List<HStoreFile> sfs = new ArrayList<>();
sfs.add(sf);
try {
List<StoreFileScanner> sfScanners = StoreFileScanner.getScannersForStoreFiles(sfs,
cacheMobBlocks, true, false, false, readPt);
if (!sfScanners.isEmpty()) {
scanner = sfScanners.get(0);
if (scanner.seek(search)) {
result = scanner.peek();
}
}
} finally {
if (scanner != null) {
scanner.close();
}
}
return result;
}
示例2: readCell
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* Reads a cell from the mob file.
* @param search The KeyValue need to be searched in the mob file.
* @param cacheMobBlocks Should this scanner cache blocks.
* @return The KeyValue in the mob file.
* @throws IOException
*/
public KeyValue readCell(KeyValue search, boolean cacheMobBlocks) throws IOException {
KeyValue result = null;
StoreFileScanner scanner = null;
List<StoreFile> sfs = new ArrayList<StoreFile>();
sfs.add(sf);
try {
List<StoreFileScanner> sfScanners = StoreFileScanner.getScannersForStoreFiles(sfs,
cacheMobBlocks, true, false, null, sf.getMaxMemstoreTS());
if (!sfScanners.isEmpty()) {
scanner = sfScanners.get(0);
if (scanner.seek(search)) {
result = scanner.peek();
}
}
} finally {
if (scanner != null) {
scanner.close();
}
}
return result;
}
示例3: winterTestingStoreFile
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
private void winterTestingStoreFile(StoreFile sf) throws IOException {
StoreFileScanner compactedFileScanner = sf.getReader().getStoreFileScanner(false, false);
KeyValue startKey =
KeyValueUtil.createFirstOnRow(HConstants.EMPTY_START_ROW, HConstants.LATEST_TIMESTAMP);
compactedFileScanner.seek(startKey);
KeyValue kv;
int n = 0;
while ((kv = (KeyValue) compactedFileScanner.next()) != null) {
LOG.info("LCDBG, show kv: " + Bytes.toInt(kv.getRow()));
++n;
}
LOG.info("LCDBG, reader has: " + n + " in " + sf.getPath());
compactedFileScanner.close();
}
示例4: readHFile
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
private void readHFile(Configuration hadoopConf, Configuration hbaseConf, String fsStr,
String fileName) throws IOException {
CacheConfig tmpCacheConfig = new CacheConfig(hbaseConf);
FileSystem fs = null;
if (fsStr.equalsIgnoreCase("local")) {
fs = LocalFileSystem.getLocal(hadoopConf);
} else {
fs = FileSystem.get(hadoopConf);
}
Path path = new Path(fileName);
if (!fs.exists(path)) {
System.out.println("WinterTestAID file not exists: " + path);
} else {
System.out.println("WinterTestAID reading lccindex hfile: " + path);
StoreFile sf = new StoreFile(fs, path, hbaseConf, tmpCacheConfig, BloomType.NONE, null);
Reader reader = sf.createReader();
System.out.println("WinterTestAID store file attr: " + sf.mWinterGetAttribute());
StoreFileScanner sss = reader.getStoreFileScanner(false, false);
sss.seek(KeyValue.LOWESTKEY);
System.out.println("WinterTestAID store peek value: "
+ LCCIndexConstant.mWinterToPrint(sss.peek()));
KeyValue kv;
int counter = 0, printInterval = 1, totalSize = 0;
while ((kv = sss.next()) != null) {
if (counter == 0) {
counter = printInterval;
System.out
.println("WinterTestAID hfile keyvalue: " + LCCIndexConstant.mWinterToPrint(kv));
}
--counter;
++totalSize;
}
sss.close();
reader.close(false);
System.out.println("WinterTestAID total size: " + totalSize);
System.out.println("WinterTestAID winter inner mWinterGetScannersForStoreFiles start: "
+ LCCIndexConstant.convertUnknownBytes(reader.getFirstKey()));
}
}
示例5: readHFile
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
public static void readHFile(Configuration hbaseConf, Path hfilePath) throws IOException {
CacheConfig tmpCacheConfig = new CacheConfig(hbaseConf);
FileSystem hdfs = getHDFS();
if (!hdfs.exists(hfilePath)) {
System.out.println("WinterTestAID file not exists: " + hfilePath);
} else {
System.out.println("WinterTestAID reading lccindex hfile: " + hfilePath);
StoreFile sf = new StoreFile(hdfs, hfilePath, hbaseConf, tmpCacheConfig, BloomType.NONE, null);
Reader reader = sf.createReader();
System.out.println("WinterTestAID store file attr: " + sf.mWinterGetAttribute());
StoreFileScanner sss = reader.getStoreFileScanner(false, false);
sss.seek(KeyValue.LOWESTKEY);
System.out.println("WinterTestAID store peek value: "
+ LCCIndexConstant.mWinterToPrint(sss.peek()));
KeyValue kv;
int counter = 0, printInterval = 1, totalSize = 0;
while ((kv = sss.next()) != null) {
if (counter == 0) {
counter = printInterval;
System.out
.println("WinterTestAID hfile keyvalue: " + LCCIndexConstant.mWinterToPrint(kv));
}
--counter;
++totalSize;
}
sss.close();
reader.close(false);
System.out.println("WinterTestAID total size: " + totalSize);
System.out.println("WinterTestAID winter inner mWinterGetScannersForStoreFiles start: "
+ LCCIndexConstant.convertUnknownBytes(reader.getFirstKey()));
}
}
示例6: testStoreFileScanner
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* _test store file scanner.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void testStoreFileScanner() throws IOException
{
LOG.info("StoreFileScanner full starts");
long start = System.currentTimeMillis();
Map<byte[], Store> storeMap = region.getStores();
Collection<Store> stores = storeMap.values();
Store store = stores.iterator().next();
Collection<StoreFile> files = store.getStorefiles();
start = System.currentTimeMillis();
int count = 0;
for(StoreFile file: files){
LOG.info(file.getPath());
StoreFile.Reader reader = file.createReader();
StoreFileScanner scanner = reader.getStoreFileScanner(false, false);
scanner.seek(KeyValue.LOWESTKEY);
while(scanner.next() != null){
count++;
}
scanner.close();
reader.close(false);
}
long end = System.currentTimeMillis();
LOG.info("StoreFileScanner full finished in "+(end-start)+"ms. Found "+count+" records");
}
示例7: _testRandomDirectScanners
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* _test random direct scanners.
*
* FAIL after compaction
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void _testRandomDirectScanners() throws IOException
{
LOG.info("Random StoreFile scanners . Running "+(N/10)+ " of size "+M+ " scanners");
Random r = new Random();
long totalScanned =0;
long start = System.currentTimeMillis();
Map<byte[], Store> storeMap = region.getStores();
Collection<Store> stores = storeMap.values();
Store store = stores.iterator().next();
Collection<StoreFile> files = store.getStorefiles();
StoreFile[] array = new StoreFile[files.size()];
files.toArray(array);
for(int i =0; i < N/10; i++){
StoreFile file = array[r.nextInt(files.size())];
byte[] row = (ROW_PREFIX+r.nextInt(N)).getBytes();
StoreFile.Reader reader = file.createReader();
StoreFileScanner scanner = reader.getStoreFileScanner(false, false);
KeyValue kv = new KeyValue(row, CF, CQQ[0]);
//LOG.info(i+" Seek "+kv);
scanner.seek(kv);
int total = 0;
while(total ++ < M && scanner.next() != null){
totalScanned++;
}
if(i % 100000 == 0 && i > 0){
LOG.info("Scanner "+i+" scanned="+totalScanned+" avg per scanner="+(totalScanned/i));
}
scanner.close();
reader.close(false);
}
LOG.info("Random StoreFile scanners done. "+(N/10)+" in "+
(System.currentTimeMillis() - start)+"ms. Total scanned="+totalScanned+" Avg. ="+((totalScanned * 10)/ N));
}
示例8: _testStoreFileScanner
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* _test store file scanner.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void _testStoreFileScanner() throws IOException
{
LOG.info("StoreFileScanner full starts");
long start = System.currentTimeMillis();
Map<byte[], Store> storeMap = region.getStores();
Collection<Store> stores = storeMap.values();
Store store = stores.iterator().next();
Collection<StoreFile> files = store.getStorefiles();
start = System.currentTimeMillis();
int count = 0;
for(StoreFile file: files){
LOG.info(file.getPath());
StoreFile.Reader reader = file.createReader();
StoreFileScanner scanner = reader.getStoreFileScanner(false, false);
scanner.seek(KeyValue.LOWESTKEY);
while(scanner.next() != null){
count++;
}
scanner.close();
reader.close(true);
}
long end = System.currentTimeMillis();
LOG.info("StoreFileScanner full finished in "+(end-start)+"ms. Found "+count+" records");
}
示例9: _testRandomDirectScanners
import org.apache.hadoop.hbase.regionserver.StoreFileScanner; //导入方法依赖的package包/类
/**
* _test random direct scanners.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public void _testRandomDirectScanners() throws IOException
{
LOG.info("Random StoreFile scanners . Running "+(N/10)+ " of size "+M+ " scanners");
Random r = new Random();
long totalScanned =0;
long start = System.currentTimeMillis();
Map<byte[], Store> storeMap = region.getStores();
Collection<Store> stores = storeMap.values();
Store store = stores.iterator().next();
Collection<StoreFile> files = store.getStorefiles();
StoreFile[] array = new StoreFile[files.size()];
files.toArray(array);
for(int i =0; i < N/10; i++){
StoreFile file = array[r.nextInt(files.size())];
byte[] row = (ROW_PREFIX+r.nextInt(N)).getBytes();
StoreFile.Reader reader = file.createReader();
StoreFileScanner scanner = reader.getStoreFileScanner(false, false);
KeyValue kv = new KeyValue(row, CF, CQQ[0]);
scanner.seek(kv);
int total = 0;
while(total ++ < M && scanner.next() != null){
totalScanned++;
}
if(i % 100000 == 0 && i > 0){
LOG.info("Scanner "+i+" scanned="+totalScanned+" avg per scanner="+(totalScanned/i));
}
scanner.close();
reader.close(false);
}
LOG.info("Random StoreFile scanners done. "+(N/10)+" in "+
(System.currentTimeMillis() - start)+"ms. Total scanned="+totalScanned+" Avg. ="+((totalScanned * 10)/ N));
}