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


Java AtomicReader.getSortedDocValues方法代码示例

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


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

示例1: getTermsIndex

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public SortedDocValues getTermsIndex(AtomicReader reader, String field, float acceptableOverheadRatio) throws IOException {
  SortedDocValues valuesIn = reader.getSortedDocValues(field);
  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return valuesIn;
  } else {
    final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
    if (info == null) {
      return DocValues.emptySorted();
    } else if (info.hasDocValues()) {
      // we don't try to build a sorted instance from numeric/binary doc
      // values because dedup can be very costly
      throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
    } else if (!info.isIndexed()) {
      return DocValues.emptySorted();
    }
    SortedDocValuesImpl impl = (SortedDocValuesImpl) caches.get(SortedDocValues.class).get(reader, new CacheKey(field, acceptableOverheadRatio), false);
    return impl.iterator();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:FieldCacheImpl.java

示例2: getTerms

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public BinaryDocValues getTerms(AtomicReader reader, String field, boolean setDocsWithField, float acceptableOverheadRatio) throws IOException {
  BinaryDocValues valuesIn = reader.getBinaryDocValues(field);
  if (valuesIn == null) {
    valuesIn = reader.getSortedDocValues(field);
  }

  if (valuesIn != null) {
    // Not cached here by FieldCacheImpl (cached instead
    // per-thread by SegmentReader):
    return valuesIn;
  }

  final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
  if (info == null) {
    return DocValues.emptyBinary();
  } else if (info.hasDocValues()) {
    throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
  } else if (!info.isIndexed()) {
    return DocValues.emptyBinary();
  }

  BinaryDocValuesImpl impl = (BinaryDocValuesImpl) caches.get(BinaryDocValues.class).get(reader, new CacheKey(field, acceptableOverheadRatio), setDocsWithField);
  return impl.iterator();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:FieldCacheImpl.java

示例3: getDocTermOrds

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public SortedSetDocValues getDocTermOrds(AtomicReader reader, String field) throws IOException {
  SortedSetDocValues dv = reader.getSortedSetDocValues(field);
  if (dv != null) {
    return dv;
  }
  
  SortedDocValues sdv = reader.getSortedDocValues(field);
  if (sdv != null) {
    return DocValues.singleton(sdv);
  }
  
  final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
  if (info == null) {
    return DocValues.emptySortedSet();
  } else if (info.hasDocValues()) {
    throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
  } else if (!info.isIndexed()) {
    return DocValues.emptySortedSet();
  }
  
  DocTermOrds dto = (DocTermOrds) caches.get(DocTermOrds.class).get(reader, new CacheKey(field, null), false);
  return dto.iterator(reader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:FieldCacheImpl.java

示例4: write

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
public void write(int docId, AtomicReader reader, Writer out) throws IOException {
  SortedDocValues vals = reader.getSortedDocValues(this.field);
  BytesRef ref = vals.get(docId);
  fieldType.indexedToReadable(ref, cref);
  out.write('"');
  out.write(this.field);
  out.write('"');
  out.write(":");
  out.write('"');
  out.write(cref.toString());
  out.write('"');
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:SortingResponseWriter.java

示例5: getSortDoc

import org.apache.lucene.index.AtomicReader; //导入方法依赖的package包/类
private SortDoc getSortDoc(SolrIndexSearcher searcher, SortField[] sortFields) throws IOException {
  SortValue[] sortValues = new SortValue[sortFields.length];
  IndexSchema schema = searcher.getSchema();
  for(int i=0; i<sortFields.length; ++i) {
    SortField sf = sortFields[i];
    String field = sf.getField();
    boolean reverse = sf.getReverse();
    SchemaField schemaField = schema.getField(field);
    FieldType ft = schemaField.getType();

    if(!schemaField.hasDocValues()) {
      throw new IOException(field+" must have DocValues to use this feature.");
    }

    if(ft instanceof TrieIntField) {
      if(reverse) {
        sortValues[i] = new IntValue(field, new IntDesc());
      } else {
        sortValues[i] = new IntValue(field, new IntAsc());
      }
    } else if(ft instanceof TrieFloatField) {
      if(reverse) {
        sortValues[i] = new FloatValue(field, new FloatDesc());
      } else {
        sortValues[i] = new FloatValue(field, new FloatAsc());
      }
    } else if(ft instanceof TrieDoubleField) {
      if(reverse) {
        sortValues[i] = new DoubleValue(field, new DoubleDesc());
      } else {
        sortValues[i] = new DoubleValue(field, new DoubleAsc());
      }
    } else if(ft instanceof TrieLongField) {
      if(reverse) {
        sortValues[i] = new LongValue(field, new LongDesc());
      } else {
        sortValues[i] = new LongValue(field, new LongAsc());
      }
    } else if(ft instanceof StrField) {
      AtomicReader reader = searcher.getAtomicReader();
      SortedDocValues vals =  reader.getSortedDocValues(field);
      if(reverse) {
        sortValues[i] = new StringValue(vals, field, new IntDesc());
      } else {
        sortValues[i] = new StringValue(vals, field, new IntAsc());
      }
    } else {
      throw new IOException("Sort fields must be one of the following types: int,float,long,double,string");
    }
  }

  if(sortValues.length == 1) {
    return new SingleValueSortDoc(sortValues[0]);
  } else if(sortValues.length == 2) {
    return new DoubleValueSortDoc(sortValues[0], sortValues[1]);
  } else if(sortValues.length == 3) {
    return new TripleValueSortDoc(sortValues[0], sortValues[1], sortValues[2]);
  } else if(sortValues.length == 4) {
    return new QuadValueSortDoc(sortValues[0], sortValues[1], sortValues[2], sortValues[3]);
  } else {
    throw new IOException("A max of 4 sorts can be specified");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:64,代码来源:SortingResponseWriter.java


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