本文整理了Java中org.apache.hadoop.hbase.regionserver.HStore.getSplitPoint()
方法的一些代码示例,展示了HStore.getSplitPoint()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HStore.getSplitPoint()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.regionserver.HStore
类名称:HStore
方法名:getSplitPoint
[英]Determines if Store should be split.
[中]确定是否应拆分存储。
代码示例来源:origin: apache/hbase
/**
* @return the key at which the region should be split, or null
* if it cannot be split. This will only be called if shouldSplit
* previously returned true.
*/
protected byte[] getSplitPoint() {
byte[] explicitSplitPoint = this.region.getExplicitSplitPoint();
if (explicitSplitPoint != null) {
return explicitSplitPoint;
}
List<HStore> stores = region.getStores();
byte[] splitPointFromLargestStore = null;
long largestStoreSize = 0;
for (HStore s : stores) {
Optional<byte[]> splitPoint = s.getSplitPoint();
// Store also returns null if it has references as way of indicating it is not splittable
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
splitPointFromLargestStore = splitPoint.get();
largestStoreSize = storeSize;
}
}
return splitPointFromLargestStore;
}
代码示例来源:origin: apache/hbase
@Test
public void testGetSplitPoint() throws IOException {
ConstantSizeRegionSplitPolicy policy =
(ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
// For no stores, should not split
assertFalse(policy.shouldSplit());
assertNull(policy.getSplitPoint());
// Add a store above the requisite size. Should split.
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("store 1 split"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
assertEquals("store 1 split",
Bytes.toString(policy.getSplitPoint()));
// Add a bigger store. The split point should come from that one
HStore mockStore2 = Mockito.mock(HStore.class);
Mockito.doReturn(4000L).when(mockStore2).getSize();
Mockito.doReturn(true).when(mockStore2).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("store 2 split"))).when(mockStore2).getSplitPoint();
stores.add(mockStore2);
assertEquals("store 2 split",
Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: apache/hbase
/**
* Test setting up a customized split policy
*/
@Test
public void testCustomPolicy() throws IOException {
HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
KeyPrefixRegionSplitPolicy.class.getName());
myHtd.setValue(KeyPrefixRegionSplitPolicy.PREFIX_LENGTH_KEY, String.valueOf(2));
HRegion myMockRegion = Mockito.mock(HRegion.class);
Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
Mockito.doReturn(stores).when(myMockRegion).getStores();
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("abcd"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
KeyPrefixRegionSplitPolicy policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
Mockito.doReturn(Bytes.toBytes("efgh")).when(myMockRegion)
.getExplicitSplitPoint();
policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ef", Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: apache/hbase
/**
* Test for HBASE-3492 - Test split on empty colfam (no store files).
*
* @throws IOException When the IO operations fail.
*/
@Test
public void testSplitWithEmptyColFam() throws IOException {
init(this.name.getMethodName());
assertFalse(store.getSplitPoint().isPresent());
store.getHRegion().forceSplit(null);
assertFalse(store.getSplitPoint().isPresent());
store.getHRegion().clearSplit();
}
代码示例来源:origin: apache/hbase
@Test
public void testDelimitedKeyPrefixRegionSplitPolicy() throws IOException {
HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
DelimitedKeyPrefixRegionSplitPolicy.class.getName());
myHtd.setValue(DelimitedKeyPrefixRegionSplitPolicy.DELIMITER_KEY, ",");
HRegion myMockRegion = Mockito.mock(HRegion.class);
Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
Mockito.doReturn(stores).when(myMockRegion).getStores();
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("ab,cd"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
DelimitedKeyPrefixRegionSplitPolicy policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
Mockito.doReturn(Bytes.toBytes("efg,h")).when(myMockRegion)
.getExplicitSplitPoint();
policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("efg", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(Bytes.toBytes("ijk")).when(myMockRegion)
.getExplicitSplitPoint();
assertEquals("ijk", Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: apache/phoenix
if (s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
if (oldSplitPoint != null && splitPoint.isPresent()
&& Bytes.compareTo(oldSplitPoint, splitPoint.get()) == 0) {
if (!s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
if (s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
if (oldSplitPoint != null && splitPoint.isPresent()
&& Bytes.compareTo(oldSplitPoint, splitPoint.get()) == 0) {
if (!s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
代码示例来源:origin: org.apache.phoenix/phoenix-core
if (s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
if (oldSplitPoint != null && splitPoint.isPresent()
&& Bytes.compareTo(oldSplitPoint, splitPoint.get()) == 0) {
if (!s.getColumnFamilyName()
.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testGetSplitPoint() throws IOException {
ConstantSizeRegionSplitPolicy policy =
(ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
// For no stores, should not split
assertFalse(policy.shouldSplit());
assertNull(policy.getSplitPoint());
// Add a store above the requisite size. Should split.
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("store 1 split"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
assertEquals("store 1 split",
Bytes.toString(policy.getSplitPoint()));
// Add a bigger store. The split point should come from that one
HStore mockStore2 = Mockito.mock(HStore.class);
Mockito.doReturn(4000L).when(mockStore2).getSize();
Mockito.doReturn(true).when(mockStore2).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("store 2 split"))).when(mockStore2).getSplitPoint();
stores.add(mockStore2);
assertEquals("store 2 split",
Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testDelimitedKeyPrefixRegionSplitPolicy() throws IOException {
HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
DelimitedKeyPrefixRegionSplitPolicy.class.getName());
myHtd.setValue(DelimitedKeyPrefixRegionSplitPolicy.DELIMITER_KEY, ",");
HRegion myMockRegion = Mockito.mock(HRegion.class);
Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
Mockito.doReturn(stores).when(myMockRegion).getStores();
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("ab,cd"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
DelimitedKeyPrefixRegionSplitPolicy policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
Mockito.doReturn(Bytes.toBytes("efg,h")).when(myMockRegion)
.getExplicitSplitPoint();
policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("efg", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(Bytes.toBytes("ijk")).when(myMockRegion)
.getExplicitSplitPoint();
assertEquals("ijk", Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: org.apache.hbase/hbase-server
/**
* Test setting up a customized split policy
*/
@Test
public void testCustomPolicy() throws IOException {
HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
KeyPrefixRegionSplitPolicy.class.getName());
myHtd.setValue(KeyPrefixRegionSplitPolicy.PREFIX_LENGTH_KEY, String.valueOf(2));
HRegion myMockRegion = Mockito.mock(HRegion.class);
Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
Mockito.doReturn(stores).when(myMockRegion).getStores();
HStore mockStore = Mockito.mock(HStore.class);
Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
Mockito.doReturn(Optional.of(Bytes.toBytes("abcd"))).when(mockStore).getSplitPoint();
stores.add(mockStore);
KeyPrefixRegionSplitPolicy policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
Mockito.doReturn(Bytes.toBytes("efgh")).when(myMockRegion)
.getExplicitSplitPoint();
policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
.create(myMockRegion, conf);
assertEquals("ef", Bytes.toString(policy.getSplitPoint()));
}
代码示例来源:origin: org.apache.hbase/hbase-server
/**
* Test for HBASE-3492 - Test split on empty colfam (no store files).
*
* @throws IOException When the IO operations fail.
*/
@Test
public void testSplitWithEmptyColFam() throws IOException {
init(this.name.getMethodName());
assertFalse(store.getSplitPoint().isPresent());
store.getHRegion().forceSplit(null);
assertFalse(store.getSplitPoint().isPresent());
store.getHRegion().clearSplit();
}
内容来源于网络,如有侵权,请联系作者删除!