org.apache.lucene.codecs

## Class CompoundDirectory

- java.lang.Object
- - org.apache.lucene.store.Directory
  - - org.apache.lucene.codecs.CompoundDirectory

All Implemented Interfaces:
  Closeable, AutoCloseable

    public abstract class CompoundDirectory
    extends Directory

A read-only `Directory` that consists of a view over a compound file.

See Also:
  `CompoundFormat`
WARNING: This API is experimental and might change in incompatible ways in the next release.

### Constructor Summary

Constructors
`protected` `CompoundDirectory()` Sole constructor.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`abstract void` `checkIntegrity()` Checks consistency of this directory.
`IndexOutput` `createOutput(String name, IOContext context)` Creates a new, empty file in the directory and returns an `IndexOutput` instance for appending data to this file.
`IndexOutput` `createTempOutput(String prefix, String suffix, IOContext context)` Creates a new, empty, temporary file in the directory and returns an `IndexOutput` instance for appending data to this file.
`void` `deleteFile(String name)` Not implemented
`Lock` `obtainLock(String name)` Acquires and returns a `Lock` for a file with the given name.
`void` `rename(String from, String to)` Not implemented
`void` `sync(Collection<String> names)` Ensures that any writes to these files are moved to stable storage (made durable).
`void` `syncMetaData()` Ensures that directory metadata, such as recent file renames, are moved to stable storage.

### Methods inherited from class org.apache.lucene.store.Directory

`close, copyFrom, ensureOpen, fileLength, getPendingDeletions, getTempFileName, listAll, openChecksumInput, openInput, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CompoundDirectory

    protected CompoundDirectory()

Sole constructor.

### Method Detail

#### checkIntegrity

    public abstract void checkIntegrity()
                                 throws IOException

Checks consistency of this directory.

Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value against large data files.

Throws:
  `IOException`

#### deleteFile

    public final void deleteFile(String name)

Not implemented

Specified by:
  `deleteFile` in class `Directory`
Parameters:
  `name` - the name of an existing file.
Throws:
  `UnsupportedOperationException` - always: not supported by CFS

#### rename

    public final void rename(String from,
                             String to)

Not implemented

Specified by:
  `rename` in class `Directory`
Throws:
  `UnsupportedOperationException` - always: not supported by CFS

#### syncMetaData

    public final void syncMetaData()

Description copied from class: `Directory`
Ensures that directory metadata, such as recent file renames, are moved to stable storage.

Specified by:
  `syncMetaData` in class `Directory`
See Also:
  `Directory.sync(Collection)`

#### createOutput

    public final IndexOutput createOutput(String name,
                                          IOContext context)
                                   throws IOException

Description copied from class: `Directory`
Creates a new, empty file in the directory and returns an `IndexOutput` instance for appending data to this file. This method must throw `FileAlreadyExistsException` if the file already exists.

Specified by:
  `createOutput` in class `Directory`
Parameters:
  `name` - the name of the file to create.
Throws:
  `IOException` - in case of I/O error

#### createTempOutput

    public final IndexOutput createTempOutput(String prefix,
                                              String suffix,
                                              IOContext context)
                                       throws IOException

Description copied from class: `Directory`
Creates a new, empty, temporary file in the directory and returns an `IndexOutput` instance for appending data to this file. The temporary file name (accessible via `IndexOutput.getName()`) will start with `prefix`, end with `suffix` and have a reserved file extension `.tmp`.

Specified by:
  `createTempOutput` in class `Directory`
Throws:
  `IOException`

#### sync

    public final void sync(Collection<String> names)

Description copied from class: `Directory`
Ensures that any writes to these files are moved to stable storage (made durable). Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.

Specified by:
  `sync` in class `Directory`
See Also:
  `Directory.syncMetaData()`

#### obtainLock

    public final Lock obtainLock(String name)

Description copied from class: `Directory`
Acquires and returns a `Lock` for a file with the given name.

Specified by:
  `obtainLock` in class `Directory`
Parameters:
  `name` - the name of the lock file