Lucene - 目錄



此類表示索引的儲存位置,通常是檔案列表。這些檔案稱為索引檔案。索引檔案通常建立一次,然後用於讀取操作,或者可以刪除。

類宣告

以下是org.apache.lucene.store.Directory類的宣告:

public abstract class Directory
   extends Object
      implements Closeable

欄位

以下是org.apache.lucene.store.Directory類的欄位:

  • protected boolean isOpen

  • protected LockFactory lockFactory - 持有 LockFactory 例項(為該 Directory 例項實現鎖定)。

類建構函式

下表顯示了類建構函式:

序號 建構函式及說明
1

Directory()

類方法

下表顯示了不同的類方法:

序號 方法及說明
1

void clearLock(String name)

嘗試清除(強制解鎖並刪除)指定的鎖。

2

abstract void close()

關閉儲存。

3

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

已棄用。應替換為對每個需要複製的檔案呼叫 copy (Directory, String, String)。您可以使用以下程式碼:

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複製到 Directory 下,並使用新的檔名dest

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)。為了方便遷移,您可以將程式碼更改為呼叫 sync(Collections.singleton(name))

20

String toString()

21

abstract void touchFile(String name)

已棄用。Lucene 從未使用此 API;它將在 4.0 中刪除。

繼承的方法

此類繼承自以下類的方法:

  • java.lang.Object
lucene_indexing_classes.htm
廣告

© . All rights reserved.