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


Java Directory.fileExists方法代码示例

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


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

示例1: vectorsReader

import org.apache.lucene.store.Directory; //导入方法依赖的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

示例2: addIfExists

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
private static void addIfExists(Directory dir, Set<String> files, String fileName) throws IOException {
  if (dir.fileExists(fileName)) {
    files.add(fileName);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:Lucene3xSegmentInfoReader.java


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