Package org.apache.hadoop.hbase.index

Examples of org.apache.hadoop.hbase.index.IndexSpecification


        new HRegionInfo(idxDesc.getName(), START_KEY.getBytes(), END_KEY.getBytes(), false);
    indexRegion = HRegion.createHRegion(idxInfo, basedir, conf, idxDesc);
  }

  private void index(String name, String cf, String cq, ValueType type, int maxSize) {
    IndexSpecification index = indexMap.get(name);
    if (index == null) {
      index = new IndexSpecification(name);
    }
    index.addIndexColumn(new HColumnDescriptor(cf), cq, type, maxSize);
    indexMap.put(name, index);
  }
View Full Code Here


    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);
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

    Path basedir = new Path(DIR + "TestIndexPut");
    Configuration conf = TEST_UTIL.getConfiguration();
    HTableDescriptor htd = new HTableDescriptor("testIndexPutWithOffsetAndLength");
    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 SpatialPartition(20, 2),
      ValueType.String, 18);

    byte[] value1 = "AB---CD---EF---GH---IJ---KL---MN---OP---".getBytes();
    Put p = new Put("row".getBytes());
    p.add("col".getBytes(), "ql1".getBytes(), value1);
View Full Code Here

    Configuration conf = TEST_UTIL.getConfiguration();
    HTableDescriptor htd =
        new HTableDescriptor("testIndexPutWithOffsetAndLengthWhenPutIsSmallerThanOffset");
    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 SpatialPartition(20, 2),
      ValueType.String, 18);

    byte[] value1 = "AB---CD---EF---GH".getBytes();
    Put p = new Put("row".getBytes());
    p.add("col".getBytes(), "ql1".getBytes(), value1);
View Full Code Here

    Assert.assertTrue(Bytes.equals(actualResult, expectedResult));
  }

  @Test(timeout = 180000)
  public void testExtentedParametersValidityFailScenarios() throws IOException {
    IndexSpecification spec = new IndexSpecification("index");

    // When separator length is zero
    try {
      spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("", 4),
        ValueType.String, 10);
      Assert.fail("Testcase should fail if separator length is zero.");
    } catch (IllegalArgumentException e) {
    }

    // when the valuePosition is zero with separator
    try {
      spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("--", 0),
        ValueType.String, 10);
      Assert
          .fail("the testcase should fail if the valuePosition with the separator is passed as zero.");
    } catch (IllegalArgumentException e) {
    }
View Full Code Here

    }

  }

  public void testExtentedParametersValidityPassScenarios() throws IOException {
    IndexSpecification spec = new IndexSpecification("index");

    // When the provided arguments are correct
    try {
      spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SpatialPartition(4, 10),
        ValueType.String, 10);
    } catch (IllegalArgumentException e) {
      Assert.fail("the testcase should not throw exception as the arguments passed are correct.");
    }

    // When the provided arguments are correct
    try {
      spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", new SeparatorPartition("--", 1),
        ValueType.String, 10);
    } catch (IllegalArgumentException e) {
      Assert.fail("the testcase should not throw exception as the arguments passed are correct.");
    }

    try {
      spec.addIndexColumn(new HColumnDescriptor("col"), "ql2", ValueType.String, 10);
    } catch (IllegalArgumentException e) {
      Assert.fail("the testcase should not throw exception as the arguments passed are correct.");
    }
  }
View Full Code Here

    Configuration conf = TEST_UTIL.getConfiguration();
    HTableDescriptor htd = new HTableDescriptor("testIndexPutwithPositiveIntDataTypes");
    HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
    // HLog hlog = UTIL.getMiniHBaseCluster().getRegionServer(0).getWAL();
    HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
    IndexSpecification spec = new IndexSpecification("index");
    spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", ValueType.Int, 4);
    spec.addIndexColumn(new HColumnDescriptor("col"), "ql2", ValueType.Float, 4);

    byte[] value1 = Bytes.toBytes(1000);
    Put p = new Put("row".getBytes());
    p.add("col".getBytes(), "ql1".getBytes(), value1);
    Put indexPut1 = IndexUtils.prepareIndexPut(p, spec, region);
View Full Code Here

    Configuration conf = TEST_UTIL.getConfiguration();
    HTableDescriptor htd = new HTableDescriptor("testIndexPutWithNegativeIntDataTypes");
    HRegionInfo info = new HRegionInfo(htd.getName(), "ABC".getBytes(), "BBB".getBytes(), false);
    // HLog hlog = UTIL.getMiniHBaseCluster().getRegionServer(0).getWAL();
    HRegion region = HRegion.createHRegion(info, basedir, conf, htd);
    IndexSpecification spec = new IndexSpecification("index");
    spec.addIndexColumn(new HColumnDescriptor("col"), "ql1", ValueType.Int, 4);
    spec.addIndexColumn(new HColumnDescriptor("col"), "ql2", ValueType.Float, 4);

    byte[] value1 = Bytes.toBytes(-2562351);
    Put p = new Put("row".getBytes());
    p.add("col".getBytes(), "ql1".getBytes(), value1);
    Put indexPut = IndexUtils.prepareIndexPut(p, spec, region);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.index.IndexSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.