热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.lucene.store.RAMDirectory.ensureOpen()方法的使用及代码示例

本文整理了Java中org.apache.lucene.store.RAMDirectory.ensureOpen方法的一些代码示例,展示了RAMDirec

本文整理了Java中org.apache.lucene.store.RAMDirectory.ensureOpen方法的一些代码示例,展示了RAMDirectory.ensureOpen的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RAMDirectory.ensureOpen方法的具体详情如下:
包路径:org.apache.lucene.store.RAMDirectory
类名称:RAMDirectory
方法名:ensureOpen

RAMDirectory.ensureOpen介绍

暂无

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

/**
* Return total size in bytes of all files in this directory. This is
* currently quantized to RAMOutputStream.BUFFER_SIZE.
*/
@Override
public final long ramBytesUsed() {
ensureOpen();
return sizeInBytes.get();
}

代码示例来源:origin: org.apache.lucene/lucene-core

public final boolean fileNameExists(String name) {
ensureOpen();
return fileMap.containsKey(name);
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public void deleteFile(String name) throws IOException {
ensureOpen();
RAMFile file = fileMap.remove(name);
if (file != null) {
file.directory = null;
sizeInBytes.addAndGet(-file.sizeInBytes);
} else {
throw new FileNotFoundException(name);
}
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** Returns a stream reading an existing file. */
@Override
public IndexInput openInput(String name, IOContext context) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
return new RAMInputStream(name, file);
}

代码示例来源:origin: org.apache.lucene/lucene-core

/** Returns the length in bytes of a file in the directory.
* @throws IOException if the file does not exist
*/
@Override
public final long fileLength(String name) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
return file.getLength();
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public void rename(String source, String dest) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(source);
if (file == null) {
throw new FileNotFoundException(source);
}
if (fileMap.putIfAbsent(dest, file) != null) {
throw new FileAlreadyExistsException(dest);
}
if (!fileMap.remove(source, file)) {
throw new IllegalStateException("file was unexpectedly replaced: " + source);
}
fileMap.remove(source);
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public final String[] listAll() {
ensureOpen();
// NOTE: this returns a "weakly consistent view". Unless we change Dir API, keep this,
// and do not synchronize or anything stronger. it's great for testing!
// NOTE: fileMap.keySet().toArray(new String[0]) is broken in non Sun JDKs,
// and the code below is resilient to map changes during the array population.
// NOTE: don't replace this with return names.toArray(new String[names.size()]);
// or some files could be null at the end of the array if files are being deleted
// concurrently
Set fileNames = fileMap.keySet();
List names = new ArrayList<>(fileNames.size());
for (String name : fileNames) {
names.add(name);
}
String[] namesArray = names.toArray(new String[names.size()]);
Arrays.sort(namesArray);
return namesArray;
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException {
ensureOpen();
// Make the file first...
RAMFile file = newRAMFile();
// ... then try to find a unique name for it:
while (true) {
String name = IndexFileNames.segmentFileName(prefix, suffix + "_" + Long.toString(nextTempFileCounter.getAndIncrement(), Character.MAX_RADIX), "tmp");
if (fileMap.putIfAbsent(name, file) == null) {
return new RAMOutputStream(name, file, true);
}
}
}

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public IndexOutput createOutput(String name, IOContext context) throws IOException {
ensureOpen();
RAMFile file = newRAMFile();
if (fileMap.putIfAbsent(name, file) != null) {
throw new FileAlreadyExistsException(name);
}
return new RAMOutputStream(name, file, true);
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

/** Return total size in bytes of all files in this
* directory. This is currently quantized to
* RAMOutputStream.BUFFER_SIZE. */
public synchronized final long sizeInBytes() {
ensureOpen();
return sizeInBytes;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/**
* Return total size in bytes of all files in this directory. This is
* currently quantized to RAMOutputStream.BUFFER_SIZE.
*/
@Override
public final long ramBytesUsed() {
ensureOpen();
return sizeInBytes.get();
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

/** Returns true iff the named file exists in this directory. */
public final boolean fileExists(String name) {
ensureOpen();
RAMFile file;
synchronized (this) {
file = (RAMFile)fileMap.get(name);
}
return file != null;
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/**
* Return total size in bytes of all files in this directory. This is
* currently quantized to RAMOutputStream.BUFFER_SIZE.
*/
@Override
public final long ramBytesUsed() {
ensureOpen();
return sizeInBytes.get();
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
public void renameFile(String source, String dest) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(source);
if (file == null) {
throw new FileNotFoundException(source);
}
fileMap.put(dest, file);
fileMap.remove(source);
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

/** Returns an array of strings, one for each file in the directory. */
public synchronized final String[] list() {
ensureOpen();
Set fileNames = fileMap.keySet();
String[] result = new String[fileNames.size()];
int i = 0;
Iterator it = fileNames.iterator();
while (it.hasNext())
result[i++] = (String)it.next();
return result;
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

/** Returns an array of strings, one for each file in the directory. */
public synchronized final String[] list() {
ensureOpen();
Set fileNames = fileMap.keySet();
String[] result = new String[fileNames.size()];
int i = 0;
Iterator it = fileNames.iterator();
while (it.hasNext())
result[i++] = (String)it.next();
return result;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

/** Returns the length in bytes of a file in the directory.
* @throws IOException if the file does not exist
*/
@Override
public final long fileLength(String name) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
return file.getLength();
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

/** Returns a stream reading an existing file. */
public IndexInput openInput(String name) throws IOException {
ensureOpen();
RAMFile file;
synchronized (this) {
file = (RAMFile)fileMap.get(name);
}
if (file == null)
throw new FileNotFoundException(name);
return new RAMInputStream(file);
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/** Returns the length in bytes of a file in the directory.
* @throws IOException if the file does not exist
*/
@Override
public final long fileLength(String name) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
return file.getLength();
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/** Returns a stream reading an existing file. */
@Override
public IndexInput openInput(String name, IOContext context) throws IOException {
ensureOpen();
RAMFile file = fileMap.get(name);
if (file == null) {
throw new FileNotFoundException(name);
}
return new RAMInputStream(name, file);
}

推荐阅读
author-avatar
我想去海边6_414
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有