当前位置: 首页 > 文档资料 > Lucene 中文文档 >

Directory

优质
小牛编辑
120浏览
2023-12-01

此类表示索引的存储位置,通常是文件列表。 这些文件称为索引文件。 索引文件通常只创建一次,然后用于读取操作或可以删除​​。

Class 声明 (Class Declaration)

以下是org.apache.lucene.store.Directory类的声明 -

public abstract class Directory
   extends Object
      implements Closeable

字段 (Field)

以下是org.apache.lucene.store.Directory class的字段 -

  • protected boolean isOpen

  • protected LockFactory lockFactory - 保存LockFactory实例(为此Directory实例实现锁定)。

类构造函数 (Class Constructors)

下表显示了一个类构造函数 -

S.No.构造函数和描述
1

Directory()

Class Methods

下表显示了不同的类方法 -

S.No.方法和描述
1

void clearLock(String name)

尝试清除(强制解锁和删除)指定的锁。

2

abstract void close()

关闭商店。

3

static void copy(Directory src, Directory dest, boolean closeDirSrc)

已过时。 应该替换为每个需要复制的文件的复制调用(目录,字符串,字符串)。 您可以使用以下代码 -

IndexFileNameFilter filter = IndexFileNameFilter.getFilter();
for (String file : src.listAll()) {
   if (filter.accept(null, file)) {
     src.copy(dest, file, file);
   }
}
4

void copy(Directory to, String src, String dest)

将文件src复制到新文件名dest下的Directory。

5

abstract IndexOutput createOutput(String name)

在具有给定名称的目录中创建一个新的空文件。

6

abstract void deleteFile(String name)

删除目录中的现有文件。

7

protected void ensureOpen() =

8

abstract boolean fileExists(String name)

如果存在具有给定名称的文件,则返回true。

9

abstract long fileLength(String name)

返回目录中文件的长度。

10

abstract long fileModified(String name)

已过时。

11

LockFactory getLockFactory()

获取此Directory实例用于其锁定实现的LockFactory。

12

String getLockID()

返回一个字符串标识符,用于唯一地将此Directory实例与其他Directory实例区分开来。

13

abstract String[] listAll()

返回一个字符串数组,一个用于目录中的每个文件。

14

Lock makeLock(String name)

构造一个锁。

15

abstract IndexInput openInput(String name)

返回读取现有文件的流。

16

IndexInput openInput(String name, int bufferSize)

返回读取现有文件的流,具有指定的读取缓冲区大小。

17

void setLockFactory(LockFactory lockFactory)

设置此Directory实例应用于其锁定实现的LockFactory。

18

void sync(Collection《String》 names)

确保将这些文件的任何权限移动到稳定存储。

19

void sync(String name)

已过时。 请改用sync(Collection)。 为了便于迁移,您可以将代码更改为调用同步(Collections.singleton(name))

20

String toString()

21

abstract void touchFile(String name)

已过时。 Lucene从不使用这个API; 它将在4.0中删除。

方法继承 (Methods Inherited)

该类继承以下类中的方法 -

  • java.lang.Object