当前位置: 首页>>代码示例>>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;未经允许,请勿转载。