Package org.apache.hadoop.hbase.index.filter

Examples of org.apache.hadoop.hbase.index.filter.SingleColumnValuePartitionFilter


                newScvf =
                    new SingleColumnValueFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.GREATER_OR_EQUAL, scvf.getComparator());
              } else {
                newScvf =
                    new SingleColumnValuePartitionFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.GREATER_OR_EQUAL, scvf.getComparator(), vp);
              }
              Value newValue = new Value(CompareOp.GREATER_OR_EQUAL, prevValue, newScvf);
              valueList.add(newValue);
              return;
            }
          }
          break;
        case GREATER_OR_EQUAL:
          if (prevOperator == CompareOp.GREATER || prevOperator == CompareOp.GREATER_OR_EQUAL) {
            if (result >= 0) {
              valueListItr.remove();
            } else {
              // Already you found less value than present value means present filter will
              // return subset of previous filter. No need to add it to list.
              return;
            }
          } else if (prevOperator == CompareOp.LESS || prevOperator == CompareOp.LESS_OR_EQUAL) {
            // Need to handle conditions like previous is c1<5 and current c1>2. In these cases we
            // can change this condition into three parts c1<2,c1>=2 AND C1=<5 ,c1>5 and add to
            // list.
          } else if (prevOperator == CompareOp.EQUAL) {
            if (result >= 0) {
              valueListItr.remove();
            }
          }
          break;
        case LESS:
          if (prevOperator == CompareOp.LESS || prevOperator == CompareOp.LESS_OR_EQUAL) {
            if (result < 0) {
              valueListItr.remove();
            } else {
              // Already you found less or equal value than present value means present filter will
              // return subset of previous filter. No need to add it to list.
              return;
            }
          } else if (prevOperator == CompareOp.GREATER
              || prevOperator == CompareOp.GREATER_OR_EQUAL) {
            // Need to handle conditions like previous is c1<5 and current c1>2. In these cases we
            // can change this condition into three parts c1<2,c1>=2 AND C1=<5 ,c1>5 and add to
            // list.
          } else if (prevOperator == CompareOp.EQUAL) {
            if (result < 0) {
              valueListItr.remove();
            } else if (result == 0) {
              // remove this entry and convert LESS to LESS_OR_EQUAL
              valueListItr.remove();
              SingleColumnValueFilter newScvf = null;
              if (vp == null) {
                newScvf =
                    new SingleColumnValueFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.LESS_OR_EQUAL, scvf.getComparator());
              } else {
                newScvf =
                    new SingleColumnValuePartitionFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.LESS_OR_EQUAL, scvf.getComparator(), vp);
              }
              Value newValue = new Value(CompareOp.LESS_OR_EQUAL, prevValue, newScvf);
              valueList.add(newValue);
              return;
            }
          }
          break;
        case LESS_OR_EQUAL:
          if (prevOperator == CompareOp.LESS || prevOperator == CompareOp.LESS_OR_EQUAL) {
            if (result <= 0) {
              valueListItr.remove();
            } else {
              // Already you found less or equal value than present value means present filter will
              // return subset of previous filter. No need to add it to list.
              return;
            }
          } else if (prevOperator == CompareOp.GREATER
              || prevOperator == CompareOp.GREATER_OR_EQUAL) {
            // Need to handle conditions like previous is c1<5 and current c1>2. In these cases we
            // can change this condition into three parts c1<2,c1>=2 AND C1=<5 ,c1>5 and add to
            // list.
          } else if (prevOperator == CompareOp.EQUAL) {
            // If we dont want to do conversion we can add into first if condition.
            if (result <= 0) {
              valueListItr.remove();
            } else if (result == 0) {
              // remove this entry and convert GREATER to GREATER_OR_EQUAL
            }
          }
          break;
        case EQUAL:
          if (prevOperator == CompareOp.GREATER) {
            if (result < 0) {
              return;
            } else if (result == 0) {
              valueListItr.remove();
              SingleColumnValueFilter newScvf = null;
              if (vp == null) {
                newScvf =
                    new SingleColumnValueFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.GREATER_OR_EQUAL, scvf.getComparator());
              } else {
                newScvf =
                    new SingleColumnValuePartitionFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.GREATER_OR_EQUAL, scvf.getComparator(), vp);
              }
              Value newValue = new Value(CompareOp.GREATER_OR_EQUAL, prevValue, newScvf);
              valueList.add(newValue);
              return;
            }
          } else if (prevOperator == CompareOp.GREATER_OR_EQUAL) {
            if (result <= 0) {
              return;
            }
          } else if (prevOperator == CompareOp.LESS) {
            if (result > 0) {
              return;
            } else if (result == 0) {
              valueListItr.remove();
              SingleColumnValueFilter newScvf = null;
              if (vp == null) {
                newScvf =
                    new SingleColumnValueFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.LESS_OR_EQUAL, scvf.getComparator());
              } else {
                newScvf =
                    new SingleColumnValuePartitionFilter(scvf.getFamily(), scvf.getQualifier(),
                        CompareOp.LESS_OR_EQUAL, scvf.getComparator(), vp);
              }
              Value newValue = new Value(CompareOp.LESS_OR_EQUAL, prevValue, newScvf);
              valueList.add(newValue);
              return;
View Full Code Here


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

    Scan scan = new Scan();
    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);
View Full Code Here

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

    Scan scan = new Scan();
    scan.setFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.LESS_OR_EQUAL, "rti".getBytes(), vp));
    int i = 0;
    ResultScanner scanner = table.getScanner(scan);
    List<Result> testRes = new ArrayList<Result>();
    Result[] result = scanner.next(1);
View Full Code Here

    p = new Put("row3".getBytes());
    p.add("cf1".getBytes(), "cq".getBytes(), "partitionmultiple".getBytes());
    table.put(p);
    FilterList masterFilter = new FilterList(Operator.MUST_PASS_ALL);
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "rti".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "ti".getBytes(), vp2));
    Scan scan = new Scan();
    scan.setFilter(masterFilter);
    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.", 1, IndexRegionObserver
        .getMultipleSeekPoints().size());
    Assert.assertTrue("Overall result should have only 1 rows", testRes.size() == 1);

    masterFilter = new FilterList(Operator.MUST_PASS_ONE);
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.LESS, "rti".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER, "ti".getBytes(), vp2));
    scan = new Scan();
    scan.setFilter(masterFilter);
    i = 0;
    scanner = table.getScanner(scan);
View Full Code Here

    p = new Put("row3".getBytes());
    p.add("cf1".getBytes(), "cq".getBytes(), "partition--by--separator--multiple".getBytes());
    table.put(p);
    FilterList masterFilter = new FilterList(Operator.MUST_PASS_ALL);
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "by".getBytes(), vp2));
    Scan scan = new Scan();
    scan.setFilter(masterFilter);
    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 1 rows", testRes.size() == 2);

    masterFilter = new FilterList(Operator.MUST_PASS_ONE);
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "person".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.LESS, "multiple".getBytes(), vp2));
    scan = new Scan();
    scan.setFilter(masterFilter);
    i = 0;
    scanner = table.getScanner(scan);
View Full Code Here

    p = new Put("row3".getBytes());
    p.add("cf1".getBytes(), "cq".getBytes(), "partition--by--separator--multiple".getBytes());
    table.put(p);
    FilterList masterFilter = new FilterList(Operator.MUST_PASS_ALL);
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "by".getBytes(), vp2));
    masterFilter.addFilter(new SingleColumnValueFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "spatial--partition--multiple".getBytes()));

    Scan scan = new Scan();
    scan.setFilter(masterFilter);
    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.", 1, IndexRegionObserver
        .getMultipleSeekPoints().size());
    Assert.assertTrue("Overall result should have only 1 rows", testRes.size() == 1);

    masterFilter = new FilterList(Operator.MUST_PASS_ONE);
    masterFilter.addFilter(new SingleColumnValueFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "partition--by--separator--multiple".getBytes()));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "person".getBytes(), vp));
    masterFilter.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.LESS, "multiple".getBytes(), vp2));
    scan = new Scan();
    scan.setFilter(masterFilter);
    i = 0;
    scanner = table.getScanner(scan);
View Full Code Here

    table.put(p);

    FilterList masterFilter = new FilterList(Operator.MUST_PASS_ALL);

    FilterList filter1 = new FilterList(Operator.MUST_PASS_ALL);
    filter1.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp));
    filter1.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "by".getBytes(), vp2));
    filter1.addFilter(new SingleColumnValueFilter(hcd.getName(), "cq".getBytes(), CompareOp.EQUAL,
        "partition--multiple--multiple--multiple".getBytes()));

    FilterList filter2 = new FilterList(Operator.MUST_PASS_ONE);
    filter2.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp));
    filter2.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp2));

    FilterList filter3 = new FilterList(Operator.MUST_PASS_ALL);
    filter3.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp));
    filter3.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.EQUAL, "multiple".getBytes(), vp2));

    FilterList filter4 = new FilterList(Operator.MUST_PASS_ALL);
    filter3.addFilter(new SingleColumnValueFilter(hcd.getName(), "cq1".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "1234".getBytes()));
    filter3.addFilter(new SingleColumnValuePartitionFilter(hcd.getName(), "cq".getBytes(),
        CompareOp.GREATER_OR_EQUAL, "multiple".getBytes(), vp2));
    masterFilter.addFilter(filter1);
    masterFilter.addFilter(filter2);
    masterFilter.addFilter(filter3);
    masterFilter.addFilter(filter4);
View Full Code Here

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

    if (CompareOp.NOT_EQUAL == filter.getOperator() || CompareOp.NO_OP == filter.getOperator()) {
      return new NoIndexFilterNode();
    }
    FilterColumnValueDetail detail = null;
    if (filter instanceof SingleColumnValuePartitionFilter) {
      SingleColumnValuePartitionFilter escvf = (SingleColumnValuePartitionFilter) filter;
      detail =
          new FilterColumnValueDetail(escvf.getFamily(), escvf.getQualifier(), escvf
              .getComparator().getValue(), escvf.getValuePartition(), escvf.getOperator());
    } else {
      detail =
          new FilterColumnValueDetail(filter.getFamily(), filter.getQualifier(), filter
              .getComparator().getValue(), filter.getOperator());
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.index.filter.SingleColumnValuePartitionFilter

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.