java hrows使用的解释_Java HRegion.getStore方法代码示例

import org.apache.hadoop.hbase.regionserver.HRegion; //导入方法依赖的package包/类

@Test

public void testScannerSelection() throws IOException {

Configuration conf = TEST_UTIL.getConfiguration();

conf.setBoolean("hbase.store.delete.expired.storefile", false);

HColumnDescriptor hcd =

new HColumnDescriptor(FAMILY_BYTES)

.setMaxVersions(Integer.MAX_VALUE)

.setTimeToLive(TTL_SECONDS);

HTableDescriptor htd = new HTableDescriptor(TABLE);

htd.addFamily(hcd);

HRegionInfo info = new HRegionInfo(TABLE);

HRegion region =

HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(info.getEncodedName()),

conf, htd);

long ts = EnvironmentEdgeManager.currentTime();

long version = 0; //make sure each new set of Put's have a new ts

for (int iFile = 0; iFile < totalNumFiles; ++iFile) {

if (iFile == NUM_EXPIRED_FILES) {

Threads.sleepWithoutInterrupt(TTL_MS);

version += TTL_MS;

}

for (int iRow = 0; iRow < NUM_ROWS; ++iRow) {

Put put = new Put(Bytes.toBytes("row" + iRow));

for (int iCol = 0; iCol < NUM_COLS_PER_ROW; ++iCol) {

put.add(FAMILY_BYTES, Bytes.toBytes("col" + iCol),

ts + version, Bytes.toBytes("value" + iFile + "_" + iRow + "_" + iCol));

}

region.put(put);

}

region.flush(true);

version++;

}

Scan scan = new Scan();

scan.setMaxVersions(Integer.MAX_VALUE);

CacheConfig cacheConf = new CacheConfig(conf);

LruBlockCache cache = (LruBlockCache) cacheConf.getBlockCache();

cache.clearCache();

InternalScanner scanner = region.getScanner(scan);

List results = new ArrayList();

final int expectedKVsPerRow = numFreshFiles * NUM_COLS_PER_ROW;

int numReturnedRows = 0;

LOG.info("Scanning the entire table");

while (scanner.next(results) || results.size() > 0) {

assertEquals(expectedKVsPerRow, results.size());

++numReturnedRows;

results.clear();

}

assertEquals(NUM_ROWS, numReturnedRows);

Set accessedFiles = cache.getCachedFileNamesForTest();

LOG.debug("Files accessed during scan: " + accessedFiles);

// Exercise both compaction codepaths.

if (explicitCompaction) {

HStore store = (HStore)region.getStore(FAMILY_BYTES);

store.compactRecentForTestingAssumingDefaultPolicy(totalNumFiles);

} else {

region.compact(false);

}

region.close();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值