Directory

abstract class Directory : AutoCloseable

A Directory provides an abstraction layer for storing a list of files. A directory contains only files (no sub-folder hierarchy).

Implementing classes must comply with the following:

  • A file in a directory can be created (.createOutput), appended to, then closed.

  • A file open for writing may not be available for read access until the corresponding [ ] is closed.

  • Once a file is created it must only be opened for input (.openInput), or deleted (.deleteFile). Calling .createOutput on an existing file must throw [ ].

NOTE: If your application requires external synchronization, you should not synchronize on the Directory implementation instance as this may cause deadlock; use your own (non-Lucene) objects instead.

See also

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Functions

Link copied to clipboard
abstract override fun close()

Closes the directory.

Link copied to clipboard
open fun copyFrom(from: Directory, src: String, dest: String, context: IOContext)

Copies an existing src file from directory from to a non-existent file dest in this directory. The given IOContext is only used for opening the destination file.

Link copied to clipboard
abstract fun createOutput(name: String, context: IOContext): IndexOutput

Creates a new, empty file in the directory and returns an IndexOutput instance for appending data to this file.

Link copied to clipboard
abstract fun createTempOutput(prefix: String, suffix: String, context: IOContext): IndexOutput

Creates a new, empty, temporary file in the directory and returns an IndexOutput instance for appending data to this file.

Link copied to clipboard
abstract fun deleteFile(name: String)

Removes an existing file in the directory.

Link copied to clipboard
open fun ensureOpen()

Ensures this directory is still open.

Link copied to clipboard
abstract fun fileLength(name: String): Long

Returns the byte length of a file in the directory.

Link copied to clipboard
abstract fun listAll(): Array<String>

Returns names of all files stored in this directory. The output must be in sorted (UTF-16, java's String.compareTo) order.

Link copied to clipboard
abstract fun obtainLock(name: String): Lock

Acquires and returns a Lock for a file with the given name.

Link copied to clipboard

Opens a checksum-computing stream for reading an existing file.

Link copied to clipboard
abstract fun openInput(name: String, context: IOContext): IndexInput

Opens a stream for reading an existing file.

Link copied to clipboard
abstract fun rename(source: String, dest: String)

Renames source file to dest file where dest must not already exist in the directory.

Link copied to clipboard
abstract fun sync(names: MutableCollection<String>)

Ensures that any writes to these files are moved to stable storage (made durable).

Link copied to clipboard
abstract fun syncMetaData()

Ensures that directory metadata, such as recent file renames, are moved to stable storage.

Link copied to clipboard
open override fun toString(): String