• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CheckAbort类的典型用法和代码示例

java 2次浏览

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

CheckAbort类属于org.apache.lucene.index.MergeState包,在下文中一共展示了CheckAbort类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createCompoundFile

点赞 2

import org.apache.lucene.index.MergeState.CheckAbort; //导入依赖的package包/类
/**
 * NOTE: this method creates a compound file for all files returned by
 * info.files(). While, generally, this may include separate norms and
 * deletion files, this SegmentInfo must not reference such files when this
 * method is called, because they are not allowed within a compound file.
 */
static final Collection<String> createCompoundFile(InfoStream infoStream, Directory directory, CheckAbort checkAbort, final SegmentInfo info, IOContext context)
        throws IOException {

  final String fileName = IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION);
  if (infoStream.isEnabled("IW")) {
    infoStream.message("IW", "create compound file " + fileName);
  }
  assert Lucene3xSegmentInfoFormat.getDocStoreOffset(info) == -1;
  // Now merge all added files
  Collection<String> files = info.files();
  CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
  boolean success = false;
  try {
    for (String file : files) {
      directory.copy(cfsDir, file, file, context);
      checkAbort.work(directory.fileLength(file));
    }
    success = true;
  } finally {
    if (success) {
      IOUtils.close(cfsDir);
    } else {
      IOUtils.closeWhileHandlingException(cfsDir);
      try {
        directory.deleteFile(fileName);
      } catch (Throwable t) {
      }
      try {
        directory.deleteFile(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
      } catch (Throwable t) {
      }
    }
  }

  // Replace all previous files with the CFS/CFE files:
  Set<String> siFiles = new HashSet<>();
  siFiles.add(fileName);
  siFiles.add(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
  info.setFiles(siFiles);

  return files;
}
 

开发者ID:lamsfoundation,
项目名称:lams,
代码行数:49,
代码来源:IndexWriter.java

示例2: createCompoundFile

点赞 2

import org.apache.lucene.index.MergeState.CheckAbort; //导入依赖的package包/类
/**
 * NOTE: this method creates a compound file for all files returned by
 * info.files(). While, generally, this may include separate norms and
 * deletion files, this SegmentInfo must not reference such files when this
 * method is called, because they are not allowed within a compound file.
 */
static final Collection<String> createCompoundFile(InfoStream infoStream, Directory directory, CheckAbort checkAbort, final SegmentInfo info, IOContext context)
        throws IOException {

  final String fileName = IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION);
  if (infoStream.isEnabled("IW")) {
    infoStream.message("IW", "create compound file " + fileName);
  }
  assert Lucene3xSegmentInfoFormat.getDocStoreOffset(info) == -1;
  // Now merge all added files
  Collection<String> files = info.files();
  CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
  IOException prior = null;
  try {
    for (String file : files) {
      directory.copy(cfsDir, file, file, context);
      checkAbort.work(directory.fileLength(file));
    }
  } catch(IOException ex) {
    prior = ex;
  } finally {
    boolean success = false;
    try {
      IOUtils.closeWhileHandlingException(prior, cfsDir);
      success = true;
    } finally {
      if (!success) {
        try {
          directory.deleteFile(fileName);
        } catch (Throwable t) {
        }
        try {
          directory.deleteFile(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
        } catch (Throwable t) {
        }
      }
    }
  }

  // Replace all previous files with the CFS/CFE files:
  Set<String> siFiles = new HashSet<String>();
  siFiles.add(fileName);
  siFiles.add(IndexFileNames.segmentFileName(info.name, "", IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
  info.setFiles(siFiles);

  return files;
}
 

开发者ID:pkarmstr,
项目名称:NYBC,
代码行数:53,
代码来源:IndexWriter.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)