本文整理匯總了Java中org.apache.hadoop.hbase.index.SeparatorPartition類的典型用法代碼示例。如果您正苦於以下問題:Java SeparatorPartition類的具體用法?Java SeparatorPartition怎麽用?Java SeparatorPartition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SeparatorPartition類屬於org.apache.hadoop.hbase.index包,在下文中一共展示了SeparatorPartition類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testPutWithOneUnitLengthSeparatorWithoutValue
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneUnitLengthSeparatorWithoutValue() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testPutWithOneUnitLengthSeparatorWithoutValue"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("_", 4),
ValueType.String, 10);
byte[] value1 = "2ndFloor_solitaire_huawei__karnataka".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例2: testPutWithOneUnitLengthSeparatorWithoutValue
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneUnitLengthSeparatorWithoutValue() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testPutWithOneUnitLengthSeparatorWithoutValue");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("_", 4),
ValueType.String, 10);
byte[] value1 = "2ndFloor_solitaire_huawei__karnataka".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例3: testIndexPutWithSeparatorAndDataType
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithSeparatorAndDataType() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testIndexPutWithSeparatorAndDataType");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 4),
ValueType.Int, 4);
byte[] putValue = new byte[19];
byte[] value1 = "AB---CD---EF---".getBytes();
byte[] value2 = Bytes.toBytes(100000);
System.arraycopy(value1, 0, putValue, 0, value1.length);
System.arraycopy(value2, 0, putValue, value1.length, value2.length);
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), putValue);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
int a = 100000;
byte[] expectedResult = Bytes.toBytes(a ^ (1 << 31));
byte[] actualResult = new byte[4];
byte[] indexRowKey = indexPut.getRow();
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
Assert.assertTrue(Bytes.equals(expectedResult, actualResult));
}
示例4: testIndexPutWithSeparatorAndDataType
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithSeparatorAndDataType() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testIndexPutWithSeparatorAndDataType"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 4),
ValueType.Int, 4);
byte[] putValue = new byte[19];
byte[] value1 = "AB---CD---EF---".getBytes();
byte[] value2 = Bytes.toBytes(100000);
System.arraycopy(value1, 0, putValue, 0, value1.length);
System.arraycopy(value2, 0, putValue, value1.length, value2.length);
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), putValue);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
int a = 100000;
byte[] expectedResult = Bytes.toBytes(a ^ (1 << 31));
byte[] actualResult = new byte[4];
byte[] indexRowKey = indexPut.getRow();
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
Assert.assertTrue(Bytes.equals(expectedResult, actualResult));
}
示例5: testPutWithOneUnitLengthSeparator
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneUnitLengthSeparator() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testPutWithOneUnitLengthSeparator"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("_", 4),
ValueType.String, 10);
byte[] value1 = "2ndFloor_solitaire_huawei_bangalore_karnataka".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("bangalore".getBytes(), 0, expectedResult, 0, "bangalore".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "2ndFloor_solitaire_huawei_bangal".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("bangal".getBytes(), 0, expectedResult, 0, "bangal".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "2ndFloor_solitaire_huawei_".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例6: testPutWithOneAsSplit
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneAsSplit() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testPutWithOneUnitLengthSeparator"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 1),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("AB".getBytes(), 0, expectedResult, 0, "AB".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("AB".getBytes(), 0, expectedResult, 0, "AB".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例7: testIndexPutWithMultipleUnitLengthSeparator
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithMultipleUnitLengthSeparator() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testIndexPutWithMultipleUnitLengthSeparator"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 6),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("KL".getBytes(), 0, expectedResult, 0, "KL".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ---K".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("K".getBytes(), 0, expectedResult, 0, "K".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例8: testIndexPutWithMultipleUnitLengthWithSimilarStringPattern
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithMultipleUnitLengthWithSimilarStringPattern() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd =
new HTableDescriptor(TableName.valueOf("testIndexPutWithMultipleUnitLengthSeparator"));
HRegionInfo info = new HRegionInfo(htd.getTableName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 6),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---K-L---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("K-L".getBytes(), 0, expectedResult, 0, "K-L".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ---K--L".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("K--L".getBytes(), 0, expectedResult, 0, "K--L".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ----".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
expectedResult[0] = '-';
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例9: testPutWithOneUnitLengthSeparator
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneUnitLengthSeparator() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testPutWithOneUnitLengthSeparator");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("_", 4),
ValueType.String, 10);
byte[] value1 = "2ndFloor_solitaire_huawei_bangalore_karnataka".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("bangalore".getBytes(), 0, expectedResult, 0, "bangalore".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "2ndFloor_solitaire_huawei_bangal".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("bangal".getBytes(), 0, expectedResult, 0, "bangal".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "2ndFloor_solitaire_huawei_".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例10: testPutWithOneAsSplit
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testPutWithOneAsSplit() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testPutWithOneUnitLengthSeparator");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 1),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("AB".getBytes(), 0, expectedResult, 0, "AB".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("AB".getBytes(), 0, expectedResult, 0, "AB".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "".getBytes();
p = new Put("row1".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例11: testIndexPutWithMultipleUnitLengthSeparator
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithMultipleUnitLengthSeparator() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testIndexPutWithMultipleUnitLengthSeparator");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 6),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("KL".getBytes(), 0, expectedResult, 0, "KL".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ---K".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("K".getBytes(), 0, expectedResult, 0, "K".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}
示例12: testIndexPutWithMultipleUnitLengthWithSimilarStringPattern
import org.apache.hadoop.hbase.index.SeparatorPartition; //導入依賴的package包/類
@Test(timeout = 180000)
public void testIndexPutWithMultipleUnitLengthWithSimilarStringPattern() throws IOException {
Path basedir = new Path(DIR + "TestIndexPut");
Configuration conf = TEST_UTIL.getConfiguration();
HTableDescriptor htd = new HTableDescriptor("testIndexPutWithMultipleUnitLengthSeparator");
HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
IndexSpecification spec = new IndexSpecification("index");
spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("---", 6),
ValueType.String, 10);
byte[] value1 = "AB---CD---EF---GH---IJ---K-L---MN---OP---".getBytes();
Put p = new Put("row".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
byte[] indexRowKey = indexPut.getRow();
byte[] actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
byte[] expectedResult = new byte[10];
System.arraycopy("K-L".getBytes(), 0, expectedResult, 0, "K-L".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ---K--L".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
System.arraycopy("K--L".getBytes(), 0, expectedResult, 0, "K--L".getBytes().length);
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
value1 = "AB---CD---EF---GH---IJ----".getBytes();
p = new Put("row2".getBytes());
p.add("col".getBytes(), "ql1".getBytes(), value1);
indexPut = IndexUtils.prepareIndexPut(p, spec, region);
indexRowKey = indexPut.getRow();
actualResult = new byte[10];
System.arraycopy(indexRowKey, 22, actualResult, 0, actualResult.length);
expectedResult = new byte[10];
expectedResult[0] = '-';
Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
}