當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。