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


Java NumericUtils.doubleToSortableLong方法代码示例

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


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

示例1: testSortableLongBitsToDoubles

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
public void testSortableLongBitsToDoubles() {
    final double value = randomDouble();
    final long valueBits = NumericUtils.doubleToSortableLong(value);

    NumericDocValues values = new NumericDocValues() {
        @Override
        public long get(int docID) {
            return valueBits;
        }
    };

    SortedNumericDoubleValues asMultiDoubles = FieldData.sortableLongBitsToDoubles(DocValues.singleton(values, null));
    NumericDoubleValues asDoubles = FieldData.unwrapSingleton(asMultiDoubles);
    assertNotNull(asDoubles);
    assertEquals(value, asDoubles.get(0), 0);

    NumericDocValues backToLongs = DocValues.unwrapSingleton(FieldData.toSortableLongBits(asMultiDoubles));
    assertSame(values, backToLongs);

    SortedNumericDocValues multiValues = new SortedNumericDocValues() {

        @Override
        public long valueAt(int index) {
            return valueBits;
        }

        @Override
        public void setDocument(int doc) {
        }

        @Override
        public int count() {
            return 1;
        }
    };

    asMultiDoubles = FieldData.sortableLongBitsToDoubles(multiValues);
    assertEquals(value, asMultiDoubles.valueAt(0), 0);
    assertSame(multiValues, FieldData.toSortableLongBits(asMultiDoubles));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:FieldDataTests.java

示例2: testDoublesToSortableLongBits

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
public void testDoublesToSortableLongBits() {
    final double value = randomDouble();
    final long valueBits = NumericUtils.doubleToSortableLong(value);

    NumericDoubleValues values = new NumericDoubleValues() {
        @Override
        public double get(int docID) {
            return value;
        }
    };

    SortedNumericDocValues asMultiLongs = FieldData.toSortableLongBits(FieldData.singleton(values, null));
    NumericDocValues asLongs = DocValues.unwrapSingleton(asMultiLongs);
    assertNotNull(asLongs);
    assertEquals(valueBits, asLongs.get(0));

    SortedNumericDoubleValues multiValues = new SortedNumericDoubleValues() {
        @Override
        public double valueAt(int index) {
            return value;
        }

        @Override
        public void setDocument(int doc) {
        }

        @Override
        public int count() {
            return 1;
        }
    };

    asMultiLongs = FieldData.toSortableLongBits(multiValues);
    assertEquals(valueBits, asMultiLongs.valueAt(0));
    assertSame(multiValues, FieldData.sortableLongBitsToDoubles(asMultiLongs));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:FieldDataTests.java

示例3: term

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef term(Double value) {
    long longValue = NumericUtils.doubleToSortableLong(value);
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(longValue, 0, bytesRef);
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:TermBuilder.java

示例4: indexedValueForSearch

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public BytesRef indexedValueForSearch(Object value) {
    long longValue = NumericUtils.doubleToSortableLong(parseDoubleValue(value));
    BytesRefBuilder bytesRef = new BytesRefBuilder();
    NumericUtils.longToPrefixCoded(longValue, 0, bytesRef);   // 0 because of exact match
    return bytesRef.get();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:DoubleFieldMapper.java

示例5: get

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public long get(int docID) {
    return NumericUtils.doubleToSortableLong(values.get(docID));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:SortableLongBitsNumericDocValues.java

示例6: valueAt

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
public long valueAt(int index) {
    return NumericUtils.doubleToSortableLong(values.valueAt(index));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:SortableLongBitsSortedNumericDocValues.java

示例7: createField

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
@Override
protected IndexableField createField(String name, int value) {
    return new SortedNumericDocValuesField(name, NumericUtils.doubleToSortableLong(value));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:DoubleNestedSortingTests.java

示例8: count

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
private void count(ValueSource valueSource, List<MatchingDocs> matchingDocs) throws IOException {

    DoubleRange[] ranges = (DoubleRange[]) this.ranges;

    LongRange[] longRanges = new LongRange[ranges.length];
    for(int i=0;i<ranges.length;i++) {
      DoubleRange range = ranges[i];
      longRanges[i] =  new LongRange(range.label,
                                     NumericUtils.doubleToSortableLong(range.minIncl), true,
                                     NumericUtils.doubleToSortableLong(range.maxIncl), true);
    }

    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++;
        }
      }
    }

    missingCount += counter.fillCounts(counts);
    totCount -= missingCount;
  }
 
开发者ID:europeana,项目名称:search,代码行数:55,代码来源:DoubleRangeFacetCounts.java

示例9: toLongRange

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
LongRange toLongRange() {
  return new LongRange(label,
                       NumericUtils.doubleToSortableLong(minIncl), true,
                       NumericUtils.doubleToSortableLong(maxIncl), true);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:DoubleRange.java

示例10: setNumericLimits

import org.apache.lucene.util.NumericUtils; //导入方法依赖的package包/类
/**
 * Set startLimit and endLimit for numeric values. The limits in this case
 * are going to be the <code>long</code> representation of the original
 * value. <code>startLimit</code> will be incremented by one in case of the
 * interval start being exclusive. <code>endLimit</code> will be decremented by
 * one in case of the interval end being exclusive.
 */
private void setNumericLimits(SchemaField schemaField) {
  if (start == null) {
    startLimit = Long.MIN_VALUE;
  } else {
    switch (schemaField.getType().getNumericType()) {
      case LONG:
        if (schemaField.getType() instanceof TrieDateField) {
          startLimit = ((Date) schemaField.getType().toObject(schemaField, start)).getTime();
        } else {
          startLimit = (long) schemaField.getType().toObject(schemaField, start);
        }
        break;
      case INT:
        startLimit = ((Integer) schemaField.getType().toObject(schemaField, start)).longValue();
        break;
      case FLOAT:
        startLimit = NumericUtils.floatToSortableInt((float) schemaField.getType().toObject(schemaField, start));
        break;
      case DOUBLE:
        startLimit = NumericUtils.doubleToSortableLong((double) schemaField.getType().toObject(schemaField, start));
        break;
      default:
        throw new AssertionError();
    }
    if (startOpen) {
      startLimit++;
    }
  }


  if (end == null) {
    endLimit = Long.MAX_VALUE;
  } else {
    switch (schemaField.getType().getNumericType()) {
      case LONG:
        if (schemaField.getType() instanceof TrieDateField) {
          endLimit = ((Date) schemaField.getType().toObject(schemaField, end)).getTime();
        } else {
          endLimit = (long) schemaField.getType().toObject(schemaField, end);
        }
        break;
      case INT:
        endLimit = ((Integer) schemaField.getType().toObject(schemaField, end)).longValue();
        break;
      case FLOAT:
        endLimit = NumericUtils.floatToSortableInt((float) schemaField.getType().toObject(schemaField, end));
        break;
      case DOUBLE:
        endLimit = NumericUtils.doubleToSortableLong((double) schemaField.getType().toObject(schemaField, end));
        break;
      default:
        throw new AssertionError();
    }
    if (endOpen) {
      endLimit--;
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:66,代码来源:IntervalFacets.java


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