Class CompoundFileDirectory

  • All Implemented Interfaces:, java.lang.AutoCloseable

    public final class CompoundFileDirectory
    extends BaseDirectory
    Class for accessing a compound stream. This class implements a directory, but is limited to only read operations. Directory methods that would normally modify data throw an exception.

    All files belonging to a segment have the same name with varying extensions. The extensions correspond to the different file formats used by the Codec. When using the Compound File format these files are collapsed into a single .cfs file (except for the LiveDocsFormat, with a corresponding .cfe file indexing its sub-files.


    • .cfs: An optional "virtual" file consisting of all the other index files for systems that frequently run out of file handles.
    • .cfe: The "virtual" compound file's entry table holding all entries in the corresponding .cfs file.


    • Compound (.cfs) --> Header, FileData FileCount
    • Compound Entry Table (.cfe) --> Header, FileCount, <FileName, DataOffset, DataLength> FileCount
    • Header --> CodecHeader
    • FileCount --> VInt
    • DataOffset,DataLength --> UInt64
    • FileName --> String
    • FileData --> raw file data


    • FileCount indicates how many files are contained in this compound file. The entry table that follows has that many entries.
    • Each directory entry contains a long pointer to the start of this file's data section, the files length, and a String with that file's name.
    • Constructor Detail

      • CompoundFileDirectory

        public CompoundFileDirectory​(Directory directory,
                                     java.lang.String fileName,
                                     IOContext context,
                                     boolean openForWrite)
        Create a new CompoundFileDirectory.
    • Method Detail

      • getDirectory

        public Directory getDirectory()
      • getName

        public java.lang.String getName()
      • close

        public void close()
        Description copied from class: Directory
        Closes the store.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface
        Specified by:
        close in class Directory
      • openInput

        public IndexInput openInput​(java.lang.String name,
                                    IOContext context)
        Description copied from class: Directory
        Returns a stream reading an existing file, with the specified read buffer size. The particular Directory implementation may ignore the buffer size. Currently the only Directory implementations that respect this parameter are FSDirectory and CompoundFileDirectory.
      • Must throw FileNotFoundException if the file does not exist (not java.nio.file.NoSuchFileException of Java 7).
Specified by:
openInput in class Directory
createSlicer in class Directory
Throws: - if an IOException occurs