Package org.apache.lucene.index
Class CompoundFileWriter
- java.lang.Object
-
- org.apache.lucene.index.CompoundFileWriter
-
public final class CompoundFileWriter extends Object
Combines multiple files into a single compound file. The file format:
- VInt fileCount
- {Directory} fileCount entries with the following structure:
- long dataOffset
- String fileName
- {File Data} fileCount entries with the raw data of the corresponding file
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description CompoundFileWriter(Directory dir, String name)
Create the compound stream in the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFile(String file)
Add a source stream.void
addFile(String file, Directory dir)
Same asaddFile(String)
, only for files that are found in an externalDirectory
.void
close()
Merge files with the extensions added up to now.Directory
getDirectory()
Returns the directory of the compound file.String
getName()
Returns the name of the compound file.
-
-
-
Constructor Detail
-
CompoundFileWriter
public CompoundFileWriter(Directory dir, String name)
Create the compound stream in the specified file. The file name is the entire name (no extensions are added).- Throws:
NullPointerException
- ifdir
orname
is null
-
-
Method Detail
-
getDirectory
public Directory getDirectory()
Returns the directory of the compound file.
-
getName
public String getName()
Returns the name of the compound file.
-
addFile
public void addFile(String file)
Add a source stream.file
is the string by which the sub-stream will be known in the compound stream.- Throws:
IllegalStateException
- if this writer is closedNullPointerException
- iffile
is nullIllegalArgumentException
- if a file with the same name has been added already
-
addFile
public void addFile(String file, Directory dir)
Same asaddFile(String)
, only for files that are found in an externalDirectory
.
-
close
public void close() throws IOException
Merge files with the extensions added up to now. All files with these extensions are combined sequentially into the compound stream.- Throws:
IllegalStateException
- if close() had been called before or if no file has been added to this objectIOException
-
-