当前位置: 首页>>代码示例>>Java>>正文


Java IndexUtils类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.index.client.IndexUtils的典型用法代码示例。如果您正苦于以下问题:Java IndexUtils类的具体用法?Java IndexUtils怎么用?Java IndexUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexUtils类属于org.apache.hadoop.hbase.index.client包,在下文中一共展示了IndexUtils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSingleIndexExpressionWithOneEqualsExpression

import org.apache.hadoop.hbase.index.client.IndexUtils; //导入依赖的package包/类
@Test
public void testSingleIndexExpressionWithOneEqualsExpression() throws Exception {
  String indexName = "idx1";
  SingleIndexExpression singleIndexExpression = new SingleIndexExpression(indexName);
  byte[] value = "1".getBytes();
  Column column = new Column(FAMILY1, QUALIFIER1);
  EqualsExpression equalsExpression = new EqualsExpression(column, value);
  singleIndexExpression.addEqualsExpression(equalsExpression);

  Scan scan = new Scan();
  scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(singleIndexExpression));
  Filter filter = new SingleColumnValueFilter(FAMILY1, QUALIFIER1, CompareOp.EQUAL, value);
  scan.setFilter(filter);
  ScanFilterEvaluator evaluator = new ScanFilterEvaluator();
  List<IndexSpecification> indices = new ArrayList<IndexSpecification>();
  IndexSpecification index = new IndexSpecification(indexName);
  HColumnDescriptor colDesc = new HColumnDescriptor(FAMILY1);
  index.addIndexColumn(colDesc, COL1, ValueType.String, 10);
  indices.add(index);
  HRegion region =
      initHRegion(tableName.getBytes(), null, null,
        "testSingleIndexExpressionWithOneEqualsExpression", TEST_UTIL.getConfiguration(), FAMILY1);
  IndexRegionScanner scanner = evaluator.evaluate(scan, indices, new byte[0], region, tableName);
  // TODO add assertions
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:TestScanFilterEvaluatorForIndexInScan.java

示例2: testNoIndexExpression

import org.apache.hadoop.hbase.index.client.IndexUtils; //导入依赖的package包/类
@Test
public void testNoIndexExpression() throws Exception {
  IndexExpression exp = new NoIndexExpression();
  Scan scan = new Scan();
  scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(exp));
  byte[] value1 = Bytes.toBytes("asdf");
  scan.setFilter(new SingleColumnValueFilter(FAMILY1, QUALIFIER1, CompareOp.EQUAL, value1));
  List<IndexSpecification> indices = new ArrayList<IndexSpecification>();
  IndexSpecification is1 = new IndexSpecification("idx1");
  HColumnDescriptor colDesc = new HColumnDescriptor(FAMILY1);
  is1.addIndexColumn(colDesc, COL1, ValueType.String, 15);
  indices.add(is1);
  ScanFilterEvaluator evaluator = new ScanFilterEvaluator();
  HRegion region =
      initHRegion(tableName.getBytes(), null, null, "testNoIndexExpression",
        TEST_UTIL.getConfiguration(), FAMILY1);
  IndexRegionScanner scanner = evaluator.evaluate(scan, indices, new byte[0], region, tableName);
  assertNull(scanner);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:20,代码来源:TestScanFilterEvaluatorForIndexInScan.java

示例3: testSingleColumnValuePartitionFilterBySettingAsAttributeToScan

import org.apache.hadoop.hbase.index.client.IndexUtils; //导入依赖的package包/类
@Test(timeout = 180000)
public void testSingleColumnValuePartitionFilterBySettingAsAttributeToScan() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  String userTableName = "testSingleColumnValuePartitionFilterBySettingAsAttributeToScan";
  HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
  TableIndices indices = new TableIndices();
  HColumnDescriptor hcd = new HColumnDescriptor("cf1");
  ihtd.addFamily(hcd);
  ValuePartition vp = new SeparatorPartition("_", 3);
  IndexSpecification iSpec = new IndexSpecification("idx1");
  iSpec.addIndexColumn(hcd, "cq", vp, ValueType.String, 200);
  indices.addIndex(iSpec);
  ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
  admin.createTable(ihtd);
  HTable table = new HTable(conf, userTableName);
  byte[] value1 = "2ndFloor_solitaire_huawei_bangalore_karnataka".getBytes();
  Put p = new Put("row".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(), value1);
  table.put(p);
  p = new Put("row2".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(),
    "7thFloor_solitaire_huawei_bangalore_karnataka".getBytes());
  table.put(p);

  p = new Put("row3".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(), "rrr_sss_hhh_bangalore_karnataka".getBytes());
  table.put(p);

  Scan scan = new Scan();
  SingleIndexExpression singleIndexExpression = new SingleIndexExpression("idx1");
  byte[] value = "huawei".getBytes();
  Column column = new Column("cf1".getBytes(), "cq".getBytes(), vp);
  EqualsExpression equalsExpression = new EqualsExpression(column, value);
  singleIndexExpression.addEqualsExpression(equalsExpression);
  scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(singleIndexExpression));
  scan.setFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
      CompareOp.EQUAL, "huawei".getBytes(), vp));
  int i = 0;
  ResultScanner scanner = table.getScanner(scan);
  List<Result> testRes = new ArrayList<Result>();
  Result[] result = scanner.next(1);
  while (result != null && result.length > 0) {
    testRes.add(result[0]);
    i++;
    result = scanner.next(1);
  }
  assertTrue("Index flow should get used.", IndexRegionObserver.getIndexedFlowUsed());
  assertTrue("Seekpoints should get added by index scanner",
    IndexRegionObserver.getSeekpointAdded());
  assertEquals("It should get two seek points from index scanner.", 2, IndexRegionObserver
      .getMultipleSeekPoints().size());
  assertTrue("Overall result should have only 2 rows", testRes.size() == 2);

}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:55,代码来源:TestValuePartitionInScan.java

示例4: testSingleColumnValuePartitionFilterBySettingAsAttributeToScan

import org.apache.hadoop.hbase.index.client.IndexUtils; //导入依赖的package包/类
@Test(timeout = 180000)
public void testSingleColumnValuePartitionFilterBySettingAsAttributeToScan() throws Exception {

  HBaseAdmin admin = UTIL.getHBaseAdmin();
  Configuration conf = UTIL.getConfiguration();
  String userTableName = "testSingleColumnValuePartitionFilterBySettingAsAttributeToScan";
  IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
  HColumnDescriptor hcd = new HColumnDescriptor("cf1");
  ihtd.addFamily(hcd);
  ValuePartition vp = new SeparatorPartition("_", 3);
  IndexSpecification iSpec = new IndexSpecification("idx1");
  iSpec.addIndexColumn(hcd, "cq", vp, ValueType.String, 200);
  ihtd.addIndex(iSpec);
  admin.createTable(ihtd);
  HTable table = new HTable(conf, userTableName);
  byte[] value1 = "2ndFloor_solitaire_huawei_bangalore_karnataka".getBytes();
  Put p = new Put("row".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(), value1);
  table.put(p);
  p = new Put("row2".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(),
    "7thFloor_solitaire_huawei_bangalore_karnataka".getBytes());
  table.put(p);

  p = new Put("row3".getBytes());
  p.add("cf1".getBytes(), "cq".getBytes(), "rrr_sss_hhh_bangalore_karnataka".getBytes());
  table.put(p);

  Scan scan = new Scan();
  SingleIndexExpression singleIndexExpression = new SingleIndexExpression("idx1");
  byte[] value = "huawei".getBytes();
  Column column = new Column("cf1".getBytes(), "cq".getBytes(), vp);
  EqualsExpression equalsExpression = new EqualsExpression(column, value);
  singleIndexExpression.addEqualsExpression(equalsExpression);
  scan.setAttribute(Constants.INDEX_EXPRESSION, IndexUtils.toBytes(singleIndexExpression));
  scan.setFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
      CompareOp.EQUAL, "huawei".getBytes(), vp));
  int i = 0;
  ResultScanner scanner = table.getScanner(scan);
  List<Result> testRes = new ArrayList<Result>();
  Result[] result = scanner.next(1);
  while (result != null && result.length > 0) {
    testRes.add(result[0]);
    i++;
    result = scanner.next(1);
  }
  Assert.assertTrue("Index flow should get used.", IndexRegionObserver.getIndexedFlowUsed());
  Assert.assertTrue("Seekpoints should get added by index scanner",
    IndexRegionObserver.getSeekpointAdded());
  Assert.assertEquals("It should get two seek points from index scanner.", 2, IndexRegionObserver
      .getMultipleSeekPoints().size());
  Assert.assertTrue("Overall result should have only 2 rows", testRes.size() == 2);

}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:55,代码来源:TestValuePartitionInScan.java


注:本文中的org.apache.hadoop.hbase.index.client.IndexUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。