本文整理汇总了Java中org.apache.lucene.store.NoSuchDirectoryException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchDirectoryException类的具体用法?Java NoSuchDirectoryException怎么用?Java NoSuchDirectoryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchDirectoryException类属于org.apache.lucene.store包,在下文中一共展示了NoSuchDirectoryException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLastCommitGeneration
import org.apache.lucene.store.NoSuchDirectoryException; //导入依赖的package包/类
/**
* Get the generation of the most recent commit to the
* index in this directory (N in the segments_N file).
*
* @param directory -- directory to search for the latest segments_N file
*/
public static long getLastCommitGeneration(Directory directory) throws IOException {
try {
return getLastCommitGeneration(directory.listAll());
} catch (NoSuchDirectoryException nsde) {
return -1;
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SegmentInfos.java
示例2: indexExists
import org.apache.lucene.store.NoSuchDirectoryException; //导入依赖的package包/类
/**
* Returns <code>true</code> if an index likely exists at
* the specified directory. Note that if a corrupt index
* exists, or if an index in the process of committing
* @param directory the directory to check for an index
* @return <code>true</code> if an index exists; <code>false</code> otherwise
*/
public static boolean indexExists(Directory directory) throws IOException {
// LUCENE-2812, LUCENE-2727, LUCENE-4738: this logic will
// return true in cases that should arguably be false,
// such as only IW.prepareCommit has been called, or a
// corrupt first commit, but it's too deadly to make
// this logic "smarter" and risk accidentally returning
// false due to various cases like file description
// exhaustion, access denied, etc., because in that
// case IndexWriter may delete the entire index. It's
// safer to err towards "index exists" than try to be
// smart about detecting not-yet-fully-committed or
// corrupt indices. This means that IndexWriter will
// throw an exception on such indices and the app must
// resolve the situation manually:
String[] files;
try {
files = directory.listAll();
} catch (NoSuchDirectoryException nsde) {
// Directory does not exist --> no index exists
return false;
}
// Defensive: maybe a Directory impl returns null
// instead of throwing NoSuchDirectoryException:
if (files != null) {
String prefix = IndexFileNames.SEGMENTS + "_";
for(String file : files) {
if (file.startsWith(prefix) || file.equals(IndexFileNames.SEGMENTS_GEN)) {
return true;
}
}
}
return false;
}
开发者ID:europeana,项目名称:search,代码行数:42,代码来源:DirectoryReader.java
示例3: testNoDir
import org.apache.lucene.store.NoSuchDirectoryException; //导入依赖的package包/类
public void testNoDir() throws Throwable {
File tempDir = createTempDir("doesnotexist");
TestUtil.rm(tempDir);
Directory dir = newFSDirectory(tempDir);
try {
DirectoryReader.open(dir);
fail("did not hit expected exception");
} catch (NoSuchDirectoryException nsde) {
// expected
}
dir.close();
}
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:TestDirectoryReader.java
示例4: testNoDir
import org.apache.lucene.store.NoSuchDirectoryException; //导入依赖的package包/类
public void testNoDir() throws Throwable {
File tempDir = _TestUtil.getTempDir("doesnotexist");
_TestUtil.rmDir(tempDir);
Directory dir = newFSDirectory(tempDir);
try {
DirectoryReader.open(dir);
fail("did not hit expected exception");
} catch (NoSuchDirectoryException nsde) {
// expected
}
dir.close();
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:13,代码来源:TestDirectoryReader.java
示例5: isEmpty
import org.apache.lucene.store.NoSuchDirectoryException; //导入依赖的package包/类
public boolean isEmpty() throws IOException {
rwl.r.lock();
try {
return ArrayUtils.isEmpty(directory.listAll());
} catch (NoSuchDirectoryException e) {
return true;
} finally {
rwl.r.unlock();
}
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:11,代码来源:IndexDirectory.java
注:本文中的org.apache.lucene.store.NoSuchDirectoryException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论