Java 类org.apache.hadoop.hbase.index.SeparatorPartition 实例源码

项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}
项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:HIndex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}
项目:hindex    文件:TestExtendedPutOps.java   
@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));
}