當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。