当前位置: 首页>>代码示例>>Java>>正文


Java FunctionValues.doubleVal方法代码示例

本文整理汇总了Java中org.apache.lucene.queries.function.FunctionValues.doubleVal方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionValues.doubleVal方法的具体用法?Java FunctionValues.doubleVal怎么用?Java FunctionValues.doubleVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.queries.function.FunctionValues的用法示例。


在下文中一共展示了FunctionValues.doubleVal方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: distance

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * @param doc  The doc to score
 * @return The haversine distance formula
 */
protected double distance(int doc, FunctionValues p1DV, FunctionValues p2DV) {

  double[] p1D = new double[2];
  double[] p2D = new double[2];
  p1DV.doubleVal(doc, p1D);
  p2DV.doubleVal(doc, p2D);
  double y1;
  double x1;
  double y2;
  double x2;
  if (convertToRadians) {
    y1 = p1D[0] * DistanceUtils.DEGREES_TO_RADIANS;
    x1 = p1D[1] * DistanceUtils.DEGREES_TO_RADIANS;
    y2 = p2D[0] * DistanceUtils.DEGREES_TO_RADIANS;
    x2 = p2D[1] * DistanceUtils.DEGREES_TO_RADIANS;
  } else {
    y1 = p1D[0];
    x1 = p1D[1];
    y2 = p2D[0];
    x2 = p2D[1];
  }
  return DistanceUtils.distHaversineRAD(y1,x1,y2,x2)*radius;
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:HaversineFunction.java

示例2: getDocIdSet

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
@Override
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException {
  final FunctionValues values = source.getValues( null, context );
  return new FilteredDocIdSet(startingFilter.getDocIdSet(context, acceptDocs)) {
    @Override
    public boolean match(int doc) {
      double val = values.doubleVal( doc );
      return val >= min && val <= max;
    }
  };
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:ValueSourceFilter.java

示例3: sumValues

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
private final void sumValues(List<MatchingDocs> matchingDocs, boolean keepScores, ValueSource valueSource) throws IOException {
  final FakeScorer scorer = new FakeScorer();
  Map<String, Scorer> context = new HashMap<>();
  if (keepScores) {
    context.put("scorer", scorer);
  }
  IntsRef scratch = new IntsRef();
  for(MatchingDocs hits : matchingDocs) {
    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;
      }
    }
  }

  rollup();
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:TaxonomyFacetSumValueSource.java

示例4: distance

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * @param doc The doc to score
 */
@Override
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {

  double[] vals1 = new double[source1.dimension()];
  double[] vals2 = new double[source1.dimension()];
  dv1.doubleVal(doc, vals1);
  dv2.doubleVal(doc, vals2);

  return distSquaredCartesian(vals1, vals2);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SquaredEuclideanFunction.java

示例5: distance

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * Calculate the distance
 *
 * @param doc The current doc
 * @param dv1 The values from the first MultiValueSource
 * @param dv2 The values from the second MultiValueSource
 * @return The distance
 */
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {
  //Handle some special cases:
  double[] vals1 = new double[source1.dimension()];
  double[] vals2 = new double[source1.dimension()];
  dv1.doubleVal(doc, vals1);
  dv2.doubleVal(doc, vals2);
  return vectorDistance(vals1, vals2, power, oneOverPower);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:VectorDistanceFunction.java

示例6: getValues

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
@Override
public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
    final FunctionValues latVals = latSource.getValues(context, readerContext);
    final FunctionValues lonVals = lonSource.getValues(context, readerContext);
    final double latCenterRad = this.latCenter * DEGREES_TO_RADIANS;
    final double lonCenterRad = this.lonCenter * DEGREES_TO_RADIANS;
    final double latCenterRad_cos = this.latCenterRad_cos;

    return new DoubleDocValues(this) {
        @Override
        public double doubleVal(int doc) {
            double latRad = latVals.doubleVal(doc) * DEGREES_TO_RADIANS;
            double lonRad = lonVals.doubleVal(doc) * DEGREES_TO_RADIANS;
            double diffX = latCenterRad - latRad;
            double diffY = lonCenterRad - lonRad;
            double hsinX = Math.sin(diffX * 0.5);
            double hsinY = Math.sin(diffY * 0.5);
            double h = hsinX * hsinX + (latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);


            double distance = (EARTH_MEAN_DIAMETER * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));

            if (distance >= 0.0 && distance < 0.25) {
                return 1000;
            } else if (distance >= 0.25 && distance < 1.0) {
                return 800;
            } else if (distance >= 1.0 && distance < 5) {
                return 600;
            } else if (distance >= 5 && distance < 20) {
                return 400;
            } else if (distance >= 20 && distance < 50) {
                return 200;
            } else {
                return 0;
            }
        }
    };
}
 
开发者ID:gogobot,项目名称:solr-distance-cluster,代码行数:39,代码来源:GogobotHaversineConstFunction.java

示例7: distance

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * @param doc The doc to score
 */
@Override
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {

  double[] vals1 = new double[source1.dimension()];
  double[] vals2 = new double[source1.dimension()];
  dv1.doubleVal(doc, vals1);
  dv2.doubleVal(doc, vals2);

  return DistanceUtils.distSquaredCartesian(vals1, vals2);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:14,代码来源:SquaredEuclideanFunction.java

示例8: sumValues

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
private final void sumValues(List<MatchingDocs> matchingDocs, boolean keepScores, ValueSource valueSource) throws IOException {
  final FakeScorer scorer = new FakeScorer();
  Map<String, Scorer> context = new HashMap<String, Scorer>();
  if (keepScores) {
    context.put("scorer", scorer);
  }
  IntsRef scratch = new IntsRef();
  for(MatchingDocs hits : matchingDocs) {
    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;
      }
    }
  }

  rollup();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:33,代码来源:TaxonomyFacetSumValueSource.java

示例9: distance

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * Calculate the distance
 *
 * @param doc The current doc
 * @param dv1 The values from the first MultiValueSource
 * @param dv2 The values from the second MultiValueSource
 * @return The distance
 */
protected double distance(int doc, FunctionValues dv1, FunctionValues dv2) {
  //Handle some special cases:
  double[] vals1 = new double[source1.dimension()];
  double[] vals2 = new double[source1.dimension()];
  dv1.doubleVal(doc, vals1);
  dv2.doubleVal(doc, vals2);
  return DistanceUtils.vectorDistance(vals1, vals2, power, oneOverPower);
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:17,代码来源:VectorDistanceFunction.java

示例10: unusedTestCompile

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
/**
 * This method is unused, it is just here to make sure that the function signatures don't change.
 * If this method fails to compile, you also have to change the byte code generator to correctly
 * use the FunctionValues class.
 */
@SuppressWarnings({"unused", "null"})
private static void unusedTestCompile() {
  FunctionValues f = null;
  double ret = f.doubleVal(2);
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:JavascriptCompiler.java

示例11: func

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
@Override
public double func(int doc, FunctionValues vals) {
  return vals.doubleVal(doc) * DistanceUtils.DEGREES_TO_RADIANS;
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:ValueSourceParser.java

示例12: func

import org.apache.lucene.queries.function.FunctionValues; //导入方法依赖的package包/类
@Override
public double func(int doc, FunctionValues vals) {
  return vals.doubleVal(doc) * DistanceUtils.RADIANS_TO_DEGREES;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:5,代码来源:ValueSourceParser.java


注:本文中的org.apache.lucene.queries.function.FunctionValues.doubleVal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。