當前位置: 首頁>>代碼示例>>Java>>正文


Java NumericUtils.BUF_SIZE_LONG屬性代碼示例

本文整理匯總了Java中org.apache.lucene.util.NumericUtils.BUF_SIZE_LONG屬性的典型用法代碼示例。如果您正苦於以下問題:Java NumericUtils.BUF_SIZE_LONG屬性的具體用法?Java NumericUtils.BUF_SIZE_LONG怎麽用?Java NumericUtils.BUF_SIZE_LONG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.lucene.util.NumericUtils的用法示例。


在下文中一共展示了NumericUtils.BUF_SIZE_LONG屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readableToIndexed

@Override
public String readableToIndexed(String val) {
  // TODO: Numeric should never be handled as String, that may break in future lucene versions! Change to use BytesRef for term texts!
  final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
  readableToIndexed(val, bytes);
  return bytes.utf8ToString();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:7,代碼來源:TrieField.java

示例2: readableToIndexed

/**
 * {@inheritDoc}
 */
@Override
public String readableToIndexed(String val) {
  if (val == null)
    return null;

  final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
  readableToIndexed(val, bytes);
  return bytes.utf8ToString();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:12,代碼來源:EnumField.java

示例3: storedToIndexed

/**
 * {@inheritDoc}
 */
@Override
public String storedToIndexed(IndexableField f) {
  final Number val = f.numericValue();
  if (val == null)
    return null;
  final BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
  NumericUtils.intToPrefixCoded(val.intValue(), 0, bytes);
  return bytes.utf8ToString();
}
 
開發者ID:yintaoxue,項目名稱:read-open-source-code,代碼行數:12,代碼來源:EnumField.java

示例4: testRandomTrieAndClassicRangeQuery

private void testRandomTrieAndClassicRangeQuery(int precisionStep) throws Exception {
  String field="field"+precisionStep;
  int totalTermCountT=0,totalTermCountC=0,termCountT,termCountC;
  int num = _TestUtil.nextInt(random(), 10, 20);
  for (int i = 0; i < num; i++) {
    long lower=(long)(random().nextDouble()*noDocs*distance)+startOffset;
    long upper=(long)(random().nextDouble()*noDocs*distance)+startOffset;
    if (lower>upper) {
      long a=lower; lower=upper; upper=a;
    }
    final BytesRef lowerBytes = new BytesRef(NumericUtils.BUF_SIZE_LONG), upperBytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
    NumericUtils.longToPrefixCodedBytes(lower, 0, lowerBytes);
    NumericUtils.longToPrefixCodedBytes(upper, 0, upperBytes);
    
    // test inclusive range
    NumericRangeQuery<Long> tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
    TermRangeQuery cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, true);
    TopDocs tTopDocs = searcher.search(tq, 1);
    TopDocs cTopDocs = searcher.search(cq, 1);
    assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
    totalTermCountT += termCountT = countTerms(tq);
    totalTermCountC += termCountC = countTerms(cq);
    checkTermCounts(precisionStep, termCountT, termCountC);
    // test exclusive range
    tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
    cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, false);
    tTopDocs = searcher.search(tq, 1);
    cTopDocs = searcher.search(cq, 1);
    assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
    totalTermCountT += termCountT = countTerms(tq);
    totalTermCountC += termCountC = countTerms(cq);
    checkTermCounts(precisionStep, termCountT, termCountC);
    // test left exclusive range
    tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
    cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, true);
    tTopDocs = searcher.search(tq, 1);
    cTopDocs = searcher.search(cq, 1);
    assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
    totalTermCountT += termCountT = countTerms(tq);
    totalTermCountC += termCountC = countTerms(cq);
    checkTermCounts(precisionStep, termCountT, termCountC);
    // test right exclusive range
    tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
    cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, false);
    tTopDocs = searcher.search(tq, 1);
    cTopDocs = searcher.search(cq, 1);
    assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
    totalTermCountT += termCountT = countTerms(tq);
    totalTermCountC += termCountC = countTerms(cq);
    checkTermCounts(precisionStep, termCountT, termCountC);
  }
  
  checkTermCounts(precisionStep, totalTermCountT, totalTermCountC);
  if (VERBOSE && precisionStep != Integer.MAX_VALUE) {
    System.out.println("Average number of terms during random search on '" + field + "':");
    System.out.println(" Numeric query: " + (((double)totalTermCountT)/(num * 4)));
    System.out.println(" Classical query: " + (((double)totalTermCountC)/(num * 4)));
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:59,代碼來源:TestNumericRangeQuery64.java


注:本文中的org.apache.lucene.util.NumericUtils.BUF_SIZE_LONG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。