• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NoSuchDirectoryException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StreamInitiation类代码示例发布时间:2022-05-23
下一篇:
Java Clob类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap