Examples of FunctionValues


Examples of org.apache.lucene.queries.function.FunctionValues

    final FieldInfo fieldInfo = readerContext.reader().getFieldInfos().fieldInfo(field);
    // To be sorted or not to be sorted, that is the question
    // TODO: do it cleaner?
    if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.BINARY) {
      final BinaryDocValues binaryValues = FieldCache.DEFAULT.getTerms(readerContext.reader(), field);
      return new FunctionValues() {

        @Override
        public boolean exists(int doc) {
          return true; // doc values are dense
        }
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

        }

        @Override
        public Bits bits() throws IOException {
          //null Map context -- we simply don't have one. That's ok.
          final FunctionValues predFuncValues = predicateValueSource.getValues(null, context);

          return new Bits() {

            @Override
            public boolean get(int index) {
              if (acceptDocs != null && !acceptDocs.get(index))
                return false;
              return predFuncValues.boolVal(index);
            }

            @Override
            public int length() {
              return context.reader().maxDoc();
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

    @Override
    public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
      final BinaryDocValues docValues = readerContext.reader().getBinaryDocValues(fieldName);

      return new FunctionValues() {
        int bytesRefDoc = -1;
        BytesRef bytesRef = new BytesRef();//scratch

        boolean fillBytes(int doc) {
          if (bytesRefDoc != doc) {
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

        // TODO: this is just like ValueSourceScorer,
        // ValueSourceFilter (spatial),
        // ValueSourceRangeFilter (solr); also,
        // https://issues.apache.org/jira/browse/LUCENE-4251

        final FunctionValues values = valueSource.getValues(Collections.emptyMap(), context);

        final int maxDoc = context.reader().maxDoc();

        final Bits fastMatchBits;
        if (fastMatchFilter != null) {
          DocIdSet dis = fastMatchFilter.getDocIdSet(context, null);
          if (dis == null) {
            // No documents match
            return null;
          }
          fastMatchBits = dis.bits();
          if (fastMatchBits == null) {
            throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
          }
        } else {
          fastMatchBits = null;
        }

        return new DocIdSet() {

          @Override
          public Bits bits() {
            return new Bits() {
              @Override
              public boolean get(int docID) {
                if (acceptDocs != null && acceptDocs.get(docID) == false) {
                  return false;
                }
                if (fastMatchBits != null && fastMatchBits.get(docID) == false) {
                  return false;
                }
                return accept(values.longVal(docID));
              }

              @Override
              public int length() {
                return maxDoc;
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

    LongRangeCounter counter = new LongRangeCounter(ranges);

    int missingCount = 0;
    for (MatchingDocs hits : matchingDocs) {
      FunctionValues fv = valueSource.getValues(Collections.emptyMap(), hits.context);
     
      totCount += hits.totalHits;
      Bits bits;
      if (fastMatchFilter != null) {
        DocIdSet dis = fastMatchFilter.getDocIdSet(hits.context, null);
        if (dis == null) {
          // No documents match
          continue;
        }
        bits = dis.bits();
        if (bits == null) {
          throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
        }
      } else {
        bits = null;
      }

      DocIdSetIterator docs = hits.bits.iterator();     
      int doc;
      while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        if (bits != null && bits.get(doc) == false) {
          doc++;
          continue;
        }
        // Skip missing docs:
        if (fv.exists(doc)) {
          counter.add(fv.longVal(doc));
        } else {
          missingCount++;
        }
      }
    }
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

        // TODO: this is just like ValueSourceScorer,
        // ValueSourceFilter (spatial),
        // ValueSourceRangeFilter (solr); also,
        // https://issues.apache.org/jira/browse/LUCENE-4251

        final FunctionValues values = valueSource.getValues(Collections.emptyMap(), context);

        final int maxDoc = context.reader().maxDoc();

        final Bits fastMatchBits;
        if (fastMatchFilter != null) {
          DocIdSet dis = fastMatchFilter.getDocIdSet(context, null);
          if (dis == null) {
            // No documents match
            return null;
          }
          fastMatchBits = dis.bits();
          if (fastMatchBits == null) {
            throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
          }
        } else {
          fastMatchBits = null;
        }

        return new DocIdSet() {

          @Override
          public Bits bits() {
            return new Bits() {
              @Override
              public boolean get(int docID) {
                if (acceptDocs != null && acceptDocs.get(docID) == false) {
                  return false;
                }
                if (fastMatchBits != null && fastMatchBits.get(docID) == false) {
                  return false;
                }
                return accept(values.doubleVal(docID));
              }

              @Override
              public int length() {
                return maxDoc;
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

    LongRangeCounter counter = new LongRangeCounter(longRanges);

    int missingCount = 0;
    for (MatchingDocs hits : matchingDocs) {
      FunctionValues fv = valueSource.getValues(Collections.emptyMap(), hits.context);
     
      totCount += hits.totalHits;
      Bits bits;
      if (fastMatchFilter != null) {
        DocIdSet dis = fastMatchFilter.getDocIdSet(hits.context, null);
        if (dis == null) {
          // No documents match
          continue;
        }
        bits = dis.bits();
        if (bits == null) {
          throw new IllegalArgumentException("fastMatchFilter does not implement DocIdSet.bits");
        }
      } else {
        bits = null;
      }

      DocIdSetIterator docs = hits.bits.iterator();
     
      int doc;
      while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        if (bits != null && bits.get(doc) == false) {
          doc++;
          continue;
        }
        // Skip missing docs:
        if (fv.exists(doc)) {
          counter.add(NumericUtils.doubleToSortableLong(fv.doubleVal(doc)));
        } else {
          missingCount++;
        }
      }
    }
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

      OrdinalsReader.OrdinalsSegmentReader ords = ordinalsReader.getReader(hits.context);
     
      int scoresIdx = 0;
      float[] scores = hits.scores;

      FunctionValues functionValues = valueSource.getValues(context, hits.context);
      DocIdSetIterator docs = hits.bits.iterator();
     
      int doc;
      while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
        ords.get(doc, scratch);
        if (keepScores) {
          scorer.docID = doc;
          scorer.score = scores[scoresIdx++];
        }
        float value = (float) functionValues.doubleVal(doc);
        for(int i=0;i<scratch.length;i++) {
          values[scratch.ints[i]] += value;
        }
      }
    }
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

    return getClass().getSimpleName()+"("+provider+", "+from+")";
  }

  @Override
  public FunctionValues getValues(Map context, final AtomicReaderContext readerContext) throws IOException {
    return new FunctionValues() {
      private final ShapeFieldCache<Point> cache =
          provider.getCache(readerContext.reader());
      private final Point from = ShapeFieldCacheDistanceValueSource.this.from;
      private final DistanceCalculator calculator = ctx.getDistCalc();
      private final double nullValue = (ctx.isGeo() ? 180 * multiplier : Double.MAX_VALUE);
View Full Code Here

Examples of org.apache.lucene.queries.function.FunctionValues

    shapeValueSource.createWeight(context, searcher);
  }

  @Override
  public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
    final FunctionValues shapeValues = shapeValueSource.getValues(context, readerContext);

    return new DoubleDocValues(this) {
      @Override
      public double doubleVal(int doc) {
        Shape shape = (Shape) shapeValues.objectVal(doc);
        if (shape == null || shape.isEmpty())
          return nullValue;
        Point pt = shape.getCenter();
        return distCalc.distance(queryPoint, pt) * multiplier;
      }

      @Override
      public Explanation explain(int doc) {
        Explanation exp = super.explain(doc);
        exp.addDetail(shapeValues.explain(doc));
        return exp;
      }
    };
  }
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.