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


Java Directory.deleteFile方法代码示例

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


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

示例1: removeCorruptionMarker

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
/**
 * Deletes all corruption markers from this store.
 */
public void removeCorruptionMarker() throws IOException {
    ensureOpen();
    final Directory directory = directory();
    IOException firstException = null;
    final String[] files = directory.listAll();
    for (String file : files) {
        if (file.startsWith(CORRUPTED)) {
            try {
                directory.deleteFile(file);
            } catch (IOException ex) {
                if (firstException == null) {
                    firstException = ex;
                } else {
                    firstException.addSuppressed(ex);
                }
            }
        }
    }
    if (firstException != null) {
        throw firstException;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:Store.java

示例2: cleanLuceneIndex

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
/**
 * This method removes all lucene files from the given directory. It will first try to delete all commit points / segments
 * files to ensure broken commits or corrupted indices will not be opened in the future. If any of the segment files can't be deleted
 * this operation fails.
 */
public static void cleanLuceneIndex(Directory directory) throws IOException {
    try (Lock writeLock = directory.obtainLock(IndexWriter.WRITE_LOCK_NAME)) {
        for (final String file : directory.listAll()) {
            if (file.startsWith(IndexFileNames.SEGMENTS) || file.equals(IndexFileNames.OLD_SEGMENTS_GEN)) {
                directory.deleteFile(file); // remove all segment_N files
            }
        }
    }
    try (IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(Lucene.STANDARD_ANALYZER)
            .setMergePolicy(NoMergePolicy.INSTANCE) // no merges
            .setCommitOnClose(false) // no commits
            .setOpenMode(IndexWriterConfig.OpenMode.CREATE))) // force creation - don't append...
    {
        // do nothing and close this will kick of IndexFileDeleter which will remove all pending files
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:Lucene.java

示例3: deleteFilesIgnoringExceptions

import org.apache.lucene.store.Directory; //导入方法依赖的package包/类
/**
 * Deletes all given files, suppressing all thrown IOExceptions.
 * <p>
 * Note that the files should not be null.
 */
public static void deleteFilesIgnoringExceptions(Directory dir, String... files) {
  for (String name : files) {
    try {
      dir.deleteFile(name);
    } catch (Throwable ignored) {
      // ignore
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:IOUtils.java


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