Examples of IntSet


Examples of org.antlr.misc.IntSet

  public boolean member(int a) {
    return tokenTypeSet.member(a);
  }

  public LookaheadSet intersection(LookaheadSet s) {
    IntSet i = this.tokenTypeSet.and(s.tokenTypeSet);
    LookaheadSet intersection = new LookaheadSet(i);
    return intersection;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

     */
    long[] values = {60, 80, 40, 50, 0, 20, 10, 70, 30, 90};
    int[] ids = {7, 80, 81, 200, 235, 490, 601, 698, 888, 965};
    index = fillIndex(values, ids);
    for (int i = 0; i < values.length; i++) {
      IntSet lookupResult = index.lookup(Bytes.toBytes(values[i]));
      Assert.assertEquals(1, lookupResult.size());
      Assert.assertEquals(true, lookupResult.contains(ids[i]));
    }
    Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());

    /**
     * All the entries have the samae value
     */
    values = new long[]{100, 100, 100, 100, 100, 100, 100, 100, 100, 100};
    index = fillIndex(values, ids);
    IntSet lookupResult = index.lookup(Bytes.toBytes(100L));
    Assert.assertEquals(10, lookupResult.size());
    for (int id : ids) {
      Assert.assertEquals(true, lookupResult.contains(id));
    }
    Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());

    /**
     * Some of the entries have one value on the others have another value
     */
    values = new long[]{100, 99, 50, 99, 100, 50, 100, 100, 99, 99};
    index = fillIndex(values, ids);
    lookupResult = index.lookup(Bytes.toBytes(100L));
    Assert.assertEquals(4, lookupResult.size());
    for (int id : new int[]{7, 235, 601, 698}) {
      Assert.assertEquals(true, lookupResult.contains(id));
    }

    lookupResult = index.lookup(Bytes.toBytes(99L));
    Assert.assertEquals(4, lookupResult.size());
    for (int id : new int[]{80, 200, 888, 965}) {
      Assert.assertEquals(true, lookupResult.contains(id));
    }

    lookupResult = index.lookup(Bytes.toBytes(50L));
    Assert.assertEquals(2, lookupResult.size());
    for (int id : new int[]{81, 490}) {
      Assert.assertEquals(true, lookupResult.contains(id));
    }
    Assert.assertTrue(index.lookup(Bytes.toBytes(35L)).isEmpty());
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

        expression.getClass().getName());
    }
  }

  protected IntSet evaluate(IdxSearchContext searchContext, And and) {
    IntSet result = null;
    for (Expression expression : and.getChildren()) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Intersecting expression:");
      }
      IntSet childResult = evaluate(searchContext, expression);
      if (result == null) {
        result = childResult;
      } else if (childResult != null) {
        result = result.intersect(childResult);
      }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    }
    return result;
  }

  protected IntSet evaluate(IdxSearchContext searchContext, Or or) {
    IntSet result = null;
    for (Expression expression : or.getChildren()) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Uniting expression:");
      }
      IntSet childResult = evaluate(searchContext, expression);
      if (result == null) {
        result = childResult;
      } else if (childResult != null) {
        result = result.unite(childResult);
      }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    if (index == null) throw new IllegalStateException(
            String.format("Could not find an index for column: '%s', qualifier: '%s'",
                    Bytes.toString(comparison.getColumnName()),
                    Bytes.toString(comparison.getQualifier())));

    IntSet matched = null;
    switch (comparison.getOperator()) {
      case EQ:
        matched = index.lookup(comparison.getValue());
        break;
      case GT:
        matched = index.tail(comparison.getValue(), false);
        break;
      case GTE:
        matched = index.tail(comparison.getValue(), true);
        break;
      case LT:
        matched = index.head(comparison.getValue(), false);
        break;
      case LTE:
        matched = index.head(comparison.getValue(), true);
        break;
    }

    if (LOG.isDebugEnabled() && matched != null) {
      LOG.debug(String.format("Evaluation of comparison on column: '%s', " +
          "qualifier: '%s', operator: %s, value: '%s' yielded %s matches",
          Bytes.toString(comparison.getColumnName()),
          Bytes.toString(comparison.getQualifier()),
          comparison.getOperator(),
          index.probeToString(comparison.getValue()), matched.size()));
    }

    return matched != null ? matched : null;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

      int interval = (int) Math.round(Math.sqrt(indexSize));
      int precalcSize = indexSize / interval +
        Integer.signum(indexSize % interval);

      IntSet[] tails = new IntSet[precalcSize];
      IntSet currentTail = IntSetBuilder.newEmptyIntSet(numKeyValues);
      for (int i = indexSize - 1; i >= 0; i--) {
        currentTail = currentTail.unite(valueStore[i]);
        if (i % interval == 0) {
          tails[i / interval] = currentTail;
          currentTail = currentTail.clone();
        }
      }

      IntSet[] heads = new IntSet[precalcSize];
      IntSet currentHead = IntSetBuilder.newEmptyIntSet(numKeyValues);
      for (int i = 0; i < indexSize; i++) {
        currentHead = currentHead.unite(valueStore[i]);
        if (i % interval == 0) {
          heads[i / interval] = currentHead;
          currentHead = currentHead.clone();
        }
      }

      return new CompleteIndex(keyStore, valueStore, heads, tails,
        numKeyValues, interval);
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    } else {
      totalIndexedScans.incrementAndGet();
      // Grab a new search context
      IdxSearchContext searchContext = indexManager.newSearchContext();
      // use the expression evaluator to determine the final set of ints
      IntSet matchedExpression = expressionEvaluator.evaluate(searchContext,
        expression);
      if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("%s rows matched the index expression",
          matchedExpression.size()));
      }
      return new IdxRegionScanner(scan, searchContext, matchedExpression);
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    }
    if (index < 0) {
      index = -index;
    }
    int tailIndex = index / precalcInterval + 1;
    IntSet result = tailIndex < tails.length ?
      tails[tailIndex].clone() :
      IntSetBuilder.newEmptyIntSet(numKeyValues);
    int stopIndex = Math.min(tailIndex * precalcInterval, valueStore.length);
    for (int i = index; i < stopIndex; i++) {
      result = result.unite(valueStore[i]);
    }
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    if (index < 0) {
      index = -(index + 1);
    }

    int headIndex = (index - 1) / precalcInterval;
    IntSet result = headIndex > 0 ?
      heads[headIndex].clone() :
      IntSetBuilder.newEmptyIntSet(numKeyValues);
    int startIndex = Math.max(headIndex * precalcInterval, 0);
    for (int i = startIndex; i < index; i++) {
      result = result.unite(valueStore[i]);
    }
    return result;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.regionserver.idx.support.sets.IntSet

    searchContext.indices.put(Pair.of(column, qualifier), index);

    // perform the test
    IdxExpressionEvaluator evaluator = new IdxExpressionEvaluator();
    Expression exp = Expression.comparison(column, qualifier, Comparison.Operator.EQ, value);
    IntSet intSet = evaluator.evaluate(searchContext, exp);

    // assert the evaluator interacted with the indices correctly
    Assert.assertNotNull("The response from the evaluator should not be null", intSet);
    EasyMock.verify(index);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.