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


Java IndexOptions.compareTo方法代码示例

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


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

示例1: setField

import org.apache.lucene.index.FieldInfo.IndexOptions; //导入方法依赖的package包/类
@Override
public int setField(FieldInfo fieldInfo) {
  IndexOptions indexOptions = fieldInfo.getIndexOptions();
  fieldHasFreqs = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
  fieldHasPositions = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
  fieldHasOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  fieldHasPayloads = fieldInfo.hasPayloads();
  skipWriter.setField(fieldHasPositions, fieldHasOffsets, fieldHasPayloads);
  lastState = emptyState;
  if (fieldHasPositions) {
    if (fieldHasPayloads || fieldHasOffsets) {
      return 3;  // doc + pos + pay FP
    } else {
      return 2;  // doc + pos FP
    }
  } else {
    return 1;    // doc FP
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene41PostingsWriter.java

示例2: reset

import org.apache.lucene.index.FieldInfo.IndexOptions; //导入方法依赖的package包/类
public SimpleTextDocsAndPositionsEnum reset(long fp, Bits liveDocs, IndexOptions indexOptions, int docFreq) {
  this.liveDocs = liveDocs;
  nextDocStart = fp;
  docID = -1;
  readPositions = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
  readOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
  if (!readOffsets) {
    startOffset = -1;
    endOffset = -1;
  }
  cost = docFreq;
  return this;
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SimpleTextFieldsReader.java

示例3: read

import org.apache.lucene.index.FieldInfo.IndexOptions; //导入方法依赖的package包/类
@Override
public FieldInfos read(Directory directory, String segmentName, String segmentSuffix, IOContext iocontext) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene40FieldInfosFormat.FIELD_INFOS_EXTENSION);
  IndexInput input = directory.openInput(fileName, iocontext);
  
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40FieldInfosFormat.CODEC_NAME, 
                                 Lucene40FieldInfosFormat.FORMAT_START, 
                                 Lucene40FieldInfosFormat.FORMAT_CURRENT);

    final int size = input.readVInt(); //read in the size
    FieldInfo infos[] = new FieldInfo[size];

    for (int i = 0; i < size; i++) {
      String name = input.readString();
      final int fieldNumber = input.readVInt();
      byte bits = input.readByte();
      boolean isIndexed = (bits & Lucene40FieldInfosFormat.IS_INDEXED) != 0;
      boolean storeTermVector = (bits & Lucene40FieldInfosFormat.STORE_TERMVECTOR) != 0;
      boolean omitNorms = (bits & Lucene40FieldInfosFormat.OMIT_NORMS) != 0;
      boolean storePayloads = (bits & Lucene40FieldInfosFormat.STORE_PAYLOADS) != 0;
      final IndexOptions indexOptions;
      if (!isIndexed) {
        indexOptions = null;
      } else if ((bits & Lucene40FieldInfosFormat.OMIT_TERM_FREQ_AND_POSITIONS) != 0) {
        indexOptions = IndexOptions.DOCS_ONLY;
      } else if ((bits & Lucene40FieldInfosFormat.OMIT_POSITIONS) != 0) {
        indexOptions = IndexOptions.DOCS_AND_FREQS;
      } else if ((bits & Lucene40FieldInfosFormat.STORE_OFFSETS_IN_POSTINGS) != 0) {
        indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
      } else {
        indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
      }

      // LUCENE-3027: past indices were able to write
      // storePayloads=true when omitTFAP is also true,
      // which is invalid.  We correct that, here:
      if (isIndexed && indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
        storePayloads = false;
      }
      // DV Types are packed in one byte
      byte val = input.readByte();
      final LegacyDocValuesType oldValuesType = getDocValuesType((byte) (val & 0x0F));
      final LegacyDocValuesType oldNormsType = getDocValuesType((byte) ((val >>> 4) & 0x0F));
      final Map<String,String> attributes = input.readStringStringMap();;
      if (oldValuesType.mapping != null) {
        attributes.put(LEGACY_DV_TYPE_KEY, oldValuesType.name());
      }
      if (oldNormsType.mapping != null) {
        if (oldNormsType.mapping != DocValuesType.NUMERIC) {
          throw new CorruptIndexException("invalid norm type: " + oldNormsType + " (resource=" + input + ")");
        }
        attributes.put(LEGACY_NORM_TYPE_KEY, oldNormsType.name());
      }
      infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, 
        omitNorms, storePayloads, indexOptions, oldValuesType.mapping, oldNormsType.mapping, -1, Collections.unmodifiableMap(attributes));
    }

    CodecUtil.checkEOF(input);
    FieldInfos fieldInfos = new FieldInfos(infos);
    success = true;
    return fieldInfos;
  } finally {
    if (success) {
      input.close();
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:72,代码来源:Lucene40FieldInfosReader.java


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