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


Java IndexFileNames.segmentFileName方法代码示例

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


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

示例1: Lucene45DocValuesConsumer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
/** expert: Creates a new writer */
public Lucene45DocValuesConsumer(SegmentWriteState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
  boolean success = false;
  try {
    String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
    data = state.directory.createOutput(dataName, state.context);
    CodecUtil.writeHeader(data, dataCodec, Lucene45DocValuesFormat.VERSION_CURRENT);
    String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
    meta = state.directory.createOutput(metaName, state.context);
    CodecUtil.writeHeader(meta, metaCodec, Lucene45DocValuesFormat.VERSION_CURRENT);
    maxDoc = state.segmentInfo.getDocCount();
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(this);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Lucene45DocValuesConsumer.java

示例2: read

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public SegmentInfo read(Directory directory, String segmentName, IOContext context) throws IOException { 
  // NOTE: this is NOT how 3.x is really written...
  String fileName = IndexFileNames.segmentFileName(segmentName, "", Lucene3xSegmentInfoFormat.UPGRADED_SI_EXTENSION);

  boolean success = false;

  IndexInput input = directory.openInput(fileName, context);

  try {
    SegmentInfo si = readUpgradedSegmentInfo(segmentName, directory, input);
    success = true;
    return si;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(input);
    } else {
      input.close();
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene3xSegmentInfoReader.java

示例3: DirectDocValuesConsumer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
DirectDocValuesConsumer(SegmentWriteState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
  maxDoc = state.segmentInfo.getDocCount();
  boolean success = false;
  try {
    String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
    data = state.directory.createOutput(dataName, state.context);
    CodecUtil.writeHeader(data, dataCodec, VERSION_CURRENT);
    String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
    meta = state.directory.createOutput(metaName, state.context);
    CodecUtil.writeHeader(meta, metaCodec, VERSION_CURRENT);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(this);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:DirectDocValuesConsumer.java

示例4: FSTOrdTermsWriter

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
public FSTOrdTermsWriter(SegmentWriteState state, PostingsWriterBase postingsWriter) throws IOException {
  final String termsIndexFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, TERMS_INDEX_EXTENSION);
  final String termsBlockFileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, TERMS_BLOCK_EXTENSION);

  this.postingsWriter = postingsWriter;
  this.fieldInfos = state.fieldInfos;

  boolean success = false;
  try {
    this.indexOut = state.directory.createOutput(termsIndexFileName, state.context);
    this.blockOut = state.directory.createOutput(termsBlockFileName, state.context);
    writeHeader(indexOut);
    writeHeader(blockOut);
    this.postingsWriter.init(blockOut); 
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(indexOut, blockOut);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:FSTOrdTermsWriter.java

示例5: Lucene42NormsConsumer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
Lucene42NormsConsumer(SegmentWriteState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension, float acceptableOverheadRatio) throws IOException {
  this.acceptableOverheadRatio = acceptableOverheadRatio;
  maxDoc = state.segmentInfo.getDocCount();
  boolean success = false;
  try {
    String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
    data = state.directory.createOutput(dataName, state.context);
    CodecUtil.writeHeader(data, dataCodec, VERSION_CURRENT);
    String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
    meta = state.directory.createOutput(metaName, state.context);
    CodecUtil.writeHeader(meta, metaCodec, VERSION_CURRENT);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(this);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:Lucene42NormsConsumer.java

示例6: fieldsProducer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public FieldsProducer fieldsProducer(SegmentReadState readState)
  throws IOException {

  // Load our ID:
  final String idFileName = IndexFileNames.segmentFileName(readState.segmentInfo.name, readState.segmentSuffix, ID_EXTENSION);
  IndexInput in = readState.directory.openInput(idFileName, readState.context);
  boolean success = false;
  final int id;
  try {
    CodecUtil.checkHeader(in, RAM_ONLY_NAME, VERSION_START, VERSION_LATEST);
    id = in.readVInt();
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(in);
    } else {
      IOUtils.close(in);
    }
  }
  
  synchronized(state) {
    return state.get(id);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:RAMOnlyPostingsFormat.java

示例7: normsProducer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public DocValuesProducer normsProducer(SegmentReadState state) throws IOException {
  String filename = IndexFileNames.segmentFileName(state.segmentInfo.name, 
                                                   "nrm", 
                                                   IndexFileNames.COMPOUND_FILE_EXTENSION);
  return new Lucene40DocValuesReader(state, filename, Lucene40FieldInfosReader.LEGACY_NORM_TYPE_KEY);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:Lucene40NormsFormat.java

示例8: vectorsReader

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public TermVectorsReader vectorsReader(Directory directory, SegmentInfo segmentInfo, FieldInfos fieldInfos, IOContext context) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(Lucene3xSegmentInfoFormat.getDocStoreSegment(segmentInfo), "", Lucene3xTermVectorsReader.VECTORS_FIELDS_EXTENSION);

  // Unfortunately, for 3.x indices, each segment's
  // FieldInfos can lie about hasVectors (claim it's true
  // when really it's false).... so we have to carefully
  // check if the files really exist before trying to open
  // them (4.x has fixed this):
  final boolean exists;
  if (Lucene3xSegmentInfoFormat.getDocStoreOffset(segmentInfo) != -1 && Lucene3xSegmentInfoFormat.getDocStoreIsCompoundFile(segmentInfo)) {
    String cfxFileName = IndexFileNames.segmentFileName(Lucene3xSegmentInfoFormat.getDocStoreSegment(segmentInfo), "", Lucene3xCodec.COMPOUND_FILE_STORE_EXTENSION);
    if (segmentInfo.dir.fileExists(cfxFileName)) {
      Directory cfsDir = new CompoundFileDirectory(segmentInfo.dir, cfxFileName, context, false);
      try {
        exists = cfsDir.fileExists(fileName);
      } finally {
        cfsDir.close();
      }
    } else {
      exists = false;
    }
  } else {
    exists = directory.fileExists(fileName);
  }

  if (!exists) {
    // 3x's FieldInfos sometimes lies and claims a segment
    // has vectors when it doesn't:
    return null;
  } else {
    return new Lucene3xTermVectorsReader(directory, segmentInfo, fieldInfos, context);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:Lucene3xTermVectorsFormat.java

示例9: loadBytesFixedStraight

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
private BinaryDocValues loadBytesFixedStraight(FieldInfo field) throws IOException {
  String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
  IndexInput input = dir.openInput(fileName, state.context);
  boolean success = false;
  try {
    CodecUtil.checkHeader(input, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_START,
                                 Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
    final int fixedLength = input.readInt();
    PagedBytes bytes = new PagedBytes(16);
    bytes.copy(input, fixedLength * (long)state.segmentInfo.getDocCount());
    final PagedBytes.Reader bytesReader = bytes.freeze(true);
    CodecUtil.checkEOF(input);
    success = true;
    ramBytesUsed.addAndGet(bytesReader.ramBytesUsed());
    return new BinaryDocValues() {

      @Override
      public BytesRef get(int docID) {
        final BytesRef term = new BytesRef();
        bytesReader.fillSlice(term, fixedLength * (long)docID, fixedLength);
        return term;
      }
    };
  } finally {
    if (success) {
      IOUtils.close(input);
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:Lucene40DocValuesReader.java

示例10: checkCodeVersion

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
/** Verifies that the code version which wrote the segment is supported. */
public static void checkCodeVersion(Directory dir, String segment) throws IOException {
  final String indexStreamFN = IndexFileNames.segmentFileName(segment, "", FIELDS_INDEX_EXTENSION);
  IndexInput idxStream = dir.openInput(indexStreamFN, IOContext.DEFAULT);
  
  try {
    int format = idxStream.readInt();
    if (format < FORMAT_MINIMUM)
      throw new IndexFormatTooOldException(idxStream, format, FORMAT_MINIMUM, FORMAT_CURRENT);
    if (format > FORMAT_CURRENT)
      throw new IndexFormatTooNewException(idxStream, format, FORMAT_MINIMUM, FORMAT_CURRENT);
  } finally {
    idxStream.close();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Lucene3xStoredFieldsReader.java

示例11: getSorted

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public synchronized SortedDocValues getSorted(FieldInfo field) throws IOException {
  SortedDocValues instance = sortedInstances.get(field.number);
  if (instance == null) {
    String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "dat");
    String indexName = IndexFileNames.segmentFileName(state.segmentInfo.name + "_" + Integer.toString(field.number), segmentSuffix, "idx");
    IndexInput data = null;
    IndexInput index = null;
    boolean success = false;
    try {
      data = dir.openInput(dataName, state.context);
      index = dir.openInput(indexName, state.context);
      switch(LegacyDocValuesType.valueOf(field.getAttribute(legacyKey))) {
        case BYTES_FIXED_SORTED:
          instance = loadBytesFixedSorted(field, data, index);
          break;
        case BYTES_VAR_SORTED:
          instance = loadBytesVarSorted(field, data, index);
          break;
        default:
          throw new AssertionError();
      }
      CodecUtil.checkEOF(data);
      CodecUtil.checkEOF(index);
      success = true;
    } finally {
      if (success) {
        IOUtils.close(data, index);
      } else {
        IOUtils.closeWhileHandlingException(data, index);
      }
    }
    sortedInstances.put(field.number, instance);
  }
  return instance;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:Lucene40DocValuesReader.java

示例12: write

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
/** Save a single segment's info. */
@Override
public void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene46SegmentInfoFormat.SI_EXTENSION);
  si.addFile(fileName);

  final IndexOutput output = dir.createOutput(fileName, ioContext);

  boolean success = false;
  try {
    CodecUtil.writeHeader(output, Lucene46SegmentInfoFormat.CODEC_NAME, Lucene46SegmentInfoFormat.VERSION_CURRENT);
    Version version = si.getVersion();
    if (version.major < 3 || version.major > 4) {
      throw new IllegalArgumentException("invalid major version: should be 3 or 4 but got: " + version.major + " segment=" + si);
    }
    // Write the Lucene version that created this segment, since 3.1
    output.writeString(version.toString());
    output.writeInt(si.getDocCount());

    output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
    output.writeStringStringMap(si.getDiagnostics());
    output.writeStringSet(si.files());
    CodecUtil.writeFooter(output);
    success = true;
  } finally {
    if (!success) {
      IOUtils.closeWhileHandlingException(output);
      // TODO: are we doing this outside of the tracking wrapper? why must SIWriter cleanup like this?
      IOUtils.deleteFilesIgnoringExceptions(si.dir, fileName);
    } else {
      output.close();
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:Lucene46SegmentInfoWriter.java

示例13: getNormFilename

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
private static String getNormFilename(SegmentInfo info, int number) {
  if (hasSeparateNorms(info, number)) {
    long gen = Long.parseLong(info.getAttribute(Lucene3xSegmentInfoFormat.NORMGEN_PREFIX + number));
    return IndexFileNames.fileNameFromGeneration(info.name, SEPARATE_NORMS_EXTENSION + number, gen);
  } else {
    // single file for all norms
    return IndexFileNames.segmentFileName(info.name, "", NORMS_EXTENSION);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:Lucene3xNormsProducer.java

示例14: CompoundFileWriter

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
/**
 * Create the compound stream in the specified file. The file name is the
 * entire name (no extensions are added).
 * 
 * @throws NullPointerException
 *           if <code>dir</code> or <code>name</code> is null
 */
CompoundFileWriter(Directory dir, String name) {
  if (dir == null)
    throw new NullPointerException("directory cannot be null");
  if (name == null)
    throw new NullPointerException("name cannot be null");
  directory = dir;
  entryTableName = IndexFileNames.segmentFileName(
      IndexFileNames.stripExtension(name), "",
      IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION);
  dataFileName = name;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:CompoundFileWriter.java

示例15: normsConsumer

import org.apache.lucene.index.IndexFileNames; //导入方法依赖的package包/类
@Override
public DocValuesConsumer normsConsumer(SegmentWriteState state) throws IOException {
  if (!LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE) {
    return super.normsConsumer(state);
  } else {
    String filename = IndexFileNames.segmentFileName(state.segmentInfo.name, 
        "nrm", 
        IndexFileNames.COMPOUND_FILE_EXTENSION);
    return new Lucene40DocValuesWriter(state, filename, Lucene40FieldInfosReader.LEGACY_NORM_TYPE_KEY);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:Lucene40RWNormsFormat.java


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