Package org.apache.hadoop.hbase.index

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


    im.addIndexForTable("index_name", indexList);
    indexList = im.getIndicesForTable("index_name");
    assertEquals("Index name should be equal with actual value.", "index_name", indexList.get(0)
        .getName());
    assertTrue("Column qualifier state mismatch.",
      indexList.get(0).getIndexColumns().contains(new ColumnQualifier("cf", "cq", null, 10)));

  }
View Full Code Here


    ByteArrayInputStream bis = null;
    DataInputStream dis = null;
    try {
      bos = new ByteArrayOutputStream();
      dos = new DataOutputStream(bos);
      ColumnQualifier cq =
          new ColumnQualifier("cf", "cq", ValueType.String, 10, new SpatialPartition(0, 5));
      cq.write(dos);
      dos.flush();
      byte[] byteArray = bos.toByteArray();
      bis = new ByteArrayInputStream(byteArray);
      dis = new DataInputStream(bis);
      ColumnQualifier c = new ColumnQualifier();
      c.readFields(dis);
      assertTrue("ColumnQualifier state mismatch.", c.equals(cq));
    } finally {
      if (null != bos) {
        bos.close();
      }
      if (null != dos) {
View Full Code Here

      NonLeafFilterNode nlfn = new NonLeafFilterNode(null);
      List<FilterColumnValueDetail> fcvds = new ArrayList<FilterColumnValueDetail>();
      // Here by we expect that the equals expressions are given the order of columns in index.
      // TODO add reordering if needed?
      for (EqualsExpression ee : sie.getEqualsExpressions()) {
        ColumnQualifier cq = colVsCQ.get(ee.getColumn());
        if (cq == null) {
          throw new RuntimeException("The column:[" + ee.getColumn() + "] is not a part of index: "
              + sie.getIndexName());
        }
        FilterColumnValueDetail fcvd =
            new FilterColumnValueDetail(ee.getColumn(), ee.getValue(), CompareOp.EQUAL);
        fcvd.maxValueLength = cq.getMaxValueLength();
        fcvd.valueType = cq.getType();
        fcvds.add(fcvd);
      }
      // RangeExpression to come after the EqualsExpressions
      RangeExpression re = sie.getRangeExpression();
      if (re != null) {
        ColumnQualifier cq = colVsCQ.get(re.getColumn());
        if (cq == null) {
          throw new RuntimeException("The column:[" + re.getColumn() + "] is not a part of index: "
              + sie.getIndexName());
        }
        CompareOp lowerBoundCompareOp =
            re.isLowerBoundInclusive() ? CompareOp.GREATER_OR_EQUAL : CompareOp.GREATER;
        CompareOp upperBoundCompareOp =
            re.isUpperBoundInclusive() ? CompareOp.LESS_OR_EQUAL : CompareOp.LESS;
        if (re.getLowerBoundValue() == null) {
          lowerBoundCompareOp = null;
        }
        if (re.getUpperBoundValue() == null) {
          upperBoundCompareOp = null;
        }
        FilterColumnValueRange fcvr =
            new FilterColumnValueRange(re.getColumn(), re.getLowerBoundValue(),
                lowerBoundCompareOp, re.getUpperBoundValue(), upperBoundCompareOp);
        fcvr.maxValueLength = cq.getMaxValueLength();
        fcvr.valueType = cq.getType();
        fcvds.add(fcvr);
      }
      nlfn.addIndicesToUse(fcvds, index);
      return nlfn;
    }
View Full Code Here

    int bestFitIndexColsSize = Integer.MAX_VALUE;
    for (IndexSpecification index : indices) {
      Set<ColumnQualifier> indexColumns = index.getIndexColumns();
      // Don't worry . This Set is LinkedHashSet. So this will maintain the order.
      Iterator<ColumnQualifier> indexColumnsIterator = indexColumns.iterator();
      ColumnQualifier firstCQInIndex = indexColumnsIterator.next();
      Column firstColInIndex =
          new Column(firstCQInIndex.getColumnFamily(), firstCQInIndex.getQualifier(),
              firstCQInIndex.getValuePartition());
      if (firstColInIndex.equals(detail.column)) {
        possibleUseIndices.add(new Pair<IndexSpecification, Integer>(index, indexColumns.size()));
        // When we have condition on col1 and we have indices on col1&Col2 and col1&col3
        // which one we should select? We dont know the data related details of every index.
        // So select any one. May be the 1st come selected.
        // TODO later we can add more intelligence and then add index level data details
        if (indexColumns.size() < bestFitIndexColsSize) {
          bestFitIndex = index;
          bestFitIndexColsSize = indexColumns.size();
        }
        detail.maxValueLength = firstCQInIndex.getMaxValueLength();
        detail.valueType = firstCQInIndex.getType();
      }
      // This index might be useful at a topper level....
      // I will explain in detail
      // When the filter from customer is coming this way as shown below
      // &
      // ___|___
      // | |
      // c1=10 c2=5
      // Suppose we have an index on c2&c1 only on the table, when we check for c1=10 node
      // we will not find any index for that as index is not having c1 as the 1st column.
      // For c2=5 node, the index is a possible option. Now when we consider the & node,
      // the index seems perfect match. That is why even for the c1=10 node also, we can not
      // sat it is a NoIndexFilterNode, if there are any indices on the table which contain c1
      // as one column in the index columns.
      else {
        ColumnQualifier cq = null;
        Column column = null;
        while (indexColumnsIterator.hasNext()) {
          cq = indexColumnsIterator.next();
          column = new Column(cq.getColumnFamily(), cq.getQualifier(), cq.getValuePartition());
          if (column.equals(detail.column)) {
            possibleFutureUseIndices.add(new Pair<IndexSpecification, Integer>(index, indexColumns
                .size()));
            detail.maxValueLength = firstCQInIndex.getMaxValueLength();
            detail.valueType = firstCQInIndex.getType();
View Full Code Here

TOP

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

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.