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


Java InfoStream.message方法代码示例

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


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

示例1: IndexReplicationHandler

import org.apache.lucene.util.InfoStream; //导入方法依赖的package包/类
/**
 * Constructor with the given index directory and callback to notify when the
 * indexes were updated.
 */
public IndexReplicationHandler(Directory indexDir, Callable<Boolean> callback) throws IOException {
  this.callback = callback;
  this.indexDir = indexDir;
  currentRevisionFiles = null;
  currentVersion = null;
  if (DirectoryReader.indexExists(indexDir)) {
    final List<IndexCommit> commits = DirectoryReader.listCommits(indexDir);
    final IndexCommit commit = commits.get(commits.size() - 1);
    currentRevisionFiles = IndexRevision.revisionFiles(commit);
    currentVersion = IndexRevision.revisionVersion(commit);
    final InfoStream infoStream = InfoStream.getDefault();
    if (infoStream.isEnabled(INFO_STREAM_COMPONENT)) {
      infoStream.message(INFO_STREAM_COMPONENT, "constructor(): currentVersion=" + currentVersion
          + " currentRevisionFiles=" + currentRevisionFiles);
      infoStream.message(INFO_STREAM_COMPONENT, "constructor(): commit=" + commit);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:IndexReplicationHandler.java

示例2: upgrade

import org.apache.lucene.util.InfoStream; //导入方法依赖的package包/类
/** Perform the upgrade. */
public void upgrade() throws IOException {
  if (!DirectoryReader.indexExists(dir)) {
    throw new IndexNotFoundException(dir.toString());
  }

  if (!deletePriorCommits) {
    final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);
    if (commits.size() > 1) {
      throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);
    }
  }
  
  iwc.setMergePolicy(new UpgradeIndexMergePolicy(iwc.getMergePolicy()));
  iwc.setIndexDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
  
  final IndexWriter w = new IndexWriter(dir, iwc);
  try {
    InfoStream infoStream = iwc.getInfoStream();
    if (infoStream.isEnabled("IndexUpgrader")) {
      infoStream.message("IndexUpgrader", "Upgrading all pre-" + Version.LATEST + " segments of index directory '" + dir + "' to version " + Version.LATEST + "...");
    }
    w.forceMerge(1);
    if (infoStream.isEnabled("IndexUpgrader")) {
      infoStream.message("IndexUpgrader", "All segments upgraded to version " + Version.LATEST);
    }
  } finally {
    w.close();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:IndexUpgrader.java

示例3: IndexAndTaxonomyReplicationHandler

import org.apache.lucene.util.InfoStream; //导入方法依赖的package包/类
/**
 * Constructor with the given index directory and callback to notify when the
 * indexes were updated.
 */
public IndexAndTaxonomyReplicationHandler(Directory indexDir, Directory taxoDir, Callable<Boolean> callback)
    throws IOException {
  this.callback = callback;
  this.indexDir = indexDir;
  this.taxoDir = taxoDir;
  currentRevisionFiles = null;
  currentVersion = null;
  final boolean indexExists = DirectoryReader.indexExists(indexDir);
  final boolean taxoExists = DirectoryReader.indexExists(taxoDir);
  if (indexExists != taxoExists) {
    throw new IllegalStateException("search and taxonomy indexes must either both exist or not: index=" + indexExists
        + " taxo=" + taxoExists);
  }
  if (indexExists) { // both indexes exist
    final IndexCommit indexCommit = IndexReplicationHandler.getLastCommit(indexDir);
    final IndexCommit taxoCommit = IndexReplicationHandler.getLastCommit(taxoDir);
    currentRevisionFiles = IndexAndTaxonomyRevision.revisionFiles(indexCommit, taxoCommit);
    currentVersion = IndexAndTaxonomyRevision.revisionVersion(indexCommit, taxoCommit);
    final InfoStream infoStream = InfoStream.getDefault();
    if (infoStream.isEnabled(INFO_STREAM_COMPONENT)) {
      infoStream.message(INFO_STREAM_COMPONENT, "constructor(): currentVersion=" + currentVersion
          + " currentRevisionFiles=" + currentRevisionFiles);
      infoStream.message(INFO_STREAM_COMPONENT, "constructor(): indexCommit=" + indexCommit
          + " taxoCommit=" + taxoCommit);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:IndexAndTaxonomyReplicationHandler.java

示例4: cleanupOldIndexFiles

import org.apache.lucene.util.InfoStream; //导入方法依赖的package包/类
/**
 * Cleans up the index directory from old index files. This method uses the
 * last commit found by {@link #getLastCommit(Directory)}. If it matches the
 * expected segmentsFile, then all files not referenced by this commit point
 * are deleted.
 * <p>
 * <b>NOTE:</b> this method does a best effort attempt to clean the index
 * directory. It suppresses any exceptions that occur, as this can be retried
 * the next time.
 */
public static void cleanupOldIndexFiles(Directory dir, String segmentsFile, InfoStream infoStream) {
  try {
    IndexCommit commit = getLastCommit(dir);
    // commit == null means weird IO errors occurred, ignore them
    // if there were any IO errors reading the expected commit point (i.e.
    // segments files mismatch), then ignore that commit either.
    if (commit != null && commit.getSegmentsFileName().equals(segmentsFile)) {
      Set<String> commitFiles = new HashSet<>();
      commitFiles.addAll(commit.getFileNames());
      commitFiles.add(IndexFileNames.SEGMENTS_GEN);
      Matcher matcher = IndexFileNames.CODEC_FILE_PATTERN.matcher("");
      for (String file : dir.listAll()) {
        if (!commitFiles.contains(file)
            && (matcher.reset(file).matches() || file.startsWith(IndexFileNames.SEGMENTS))) {
          // suppress exceptions, it's just a best effort
          IOUtils.deleteFilesIgnoringExceptions(dir, file);
        }
      }
    }
  } catch (Throwable t) {
    // ignore any errors that happen during this state and only log it. this
    // cleanup will have a chance to succeed the next time we get a new
    // revision.
    if (infoStream.isEnabled(INFO_STREAM_COMPONENT)) {
      infoStream.message(INFO_STREAM_COMPONENT, "cleanupOldIndexFiles(): failed on error " + t.getMessage());
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:IndexReplicationHandler.java

示例5: upgrade

import org.apache.lucene.util.InfoStream; //导入方法依赖的package包/类
/** Perform the upgrade. */
public void upgrade() throws IOException {
  if (!DirectoryReader.indexExists(dir)) {
    throw new IndexNotFoundException(dir.toString());
  }

  if (!deletePriorCommits) {
    final Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);
    if (commits.size() > 1) {
      throw new IllegalArgumentException("This tool was invoked to not delete prior commit points, but the following commits were found: " + commits);
    }
  }
  
  final IndexWriterConfig c = iwc.clone();
  c.setMergePolicy(new UpgradeIndexMergePolicy(c.getMergePolicy()));
  c.setIndexDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
  
  final IndexWriter w = new IndexWriter(dir, c);
  try {
    InfoStream infoStream = c.getInfoStream();
    if (infoStream.isEnabled("IndexUpgrader")) {
      infoStream.message("IndexUpgrader", "Upgrading all pre-" + Constants.LUCENE_MAIN_VERSION + " segments of index directory '" + dir + "' to version " + Constants.LUCENE_MAIN_VERSION + "...");
    }
    w.forceMerge(1);
    if (infoStream.isEnabled("IndexUpgrader")) {
      infoStream.message("IndexUpgrader", "All segments upgraded to version " + Constants.LUCENE_MAIN_VERSION);
    }
  } finally {
    w.close();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:32,代码来源:IndexUpgrader.java


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