Examples of FunctionValues


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

    final float scale = (scaleInfo.maxVal-scaleInfo.minVal==0) ? 0 : (max-min)/(scaleInfo.maxVal-scaleInfo.minVal);
    final float minSource = scaleInfo.minVal;
    final float maxSource = scaleInfo.maxVal;

    final FunctionValues vals =  source.getValues(context, readerContext);

    return new FloatDocValues(this) {
      @Override
      public float floatVal(int doc) {
        return (vals.floatVal(doc) - minSource) * scale + min;
      }
      @Override
      public String toString(int doc) {
        return "scale(" + vals.toString(doc) + ",toMin=" + min + ",toMax=" + max
                + ",fromMin=" + minSource
                + ",fromMax=" + maxSource
                + ")";
      }
    };
View Full Code Here

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

    return "map(" + source.description() + "," + min + "," + max + "," + target + ")";
  }

  @Override
  public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
    final FunctionValues vals =  source.getValues(context, readerContext);
    return new FloatDocValues(this) {
      @Override
      public float floatVal(int doc) {
        float val = vals.floatVal(doc);
        return (val>=min && val<=max) ? target : (defaultVal == null ? val : defaultVal);
      }
      @Override
      public String toString(int doc) {
        return "map(" + vals.toString(doc) + ",min=" + min + ",max=" + max + ",target=" + target + ")";
      }
    };
  }
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

        }

        @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

    // 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, true);
      final Bits docsWithField = FieldCache.DEFAULT.getDocsWithField(readerContext.reader(), field);
      return new FunctionValues() {

        @Override
        public boolean exists(int doc) {
          return docsWithField.get(doc);
        }
View Full Code Here

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

    final FieldCache.Doubles ptX = FieldCache.DEFAULT.getDoubles(reader, strategy.getFieldNameX(), true);
    final FieldCache.Doubles ptY = FieldCache.DEFAULT.getDoubles(reader, strategy.getFieldNameY(), true);
    final Bits validX =  FieldCache.DEFAULT.getDocsWithField(reader, strategy.getFieldNameX());
    final Bits validY =  FieldCache.DEFAULT.getDocsWithField(reader, strategy.getFieldNameY());

    return new FunctionValues() {

      private final Point from = DistanceValueSource.this.from;
      private final DistanceCalculator calculator = strategy.getSpatialContext().getDistCalc();
      private final double nullValue = (strategy.getSpatialContext().isGeo() ? 180 : Double.MAX_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 : Double.MAX_VALUE);
View Full Code Here

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

  @Override
  public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
    final FieldCache.Bytes arr = cache.getBytes(readerContext.reader(), field, parser, false);
   
    return new FunctionValues() {
      @Override
      public byte byteVal(int doc) {
        return arr.get(doc);
      }
View Full Code Here

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

  @Override
  public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
    final FieldCache.Shorts arr = cache.getShorts(readerContext.reader(), field, parser, false);
   
    return new FunctionValues() {
      @Override
      public byte byteVal(int doc) {
        return (byte) arr.get(doc);
      }
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.