Class Lucene50CompoundReader
- java.lang.Object
-
- org.apache.lucene.store.Directory
-
- org.apache.lucene.codecs.lucene50.Lucene50CompoundReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
final class Lucene50CompoundReader extends Directory
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Lucene50CompoundReader.FileEntry
Offset/Length for a slice inside of a compound file
-
Field Summary
Fields Modifier and Type Field Description private Directory
directory
private java.util.Map<java.lang.String,Lucene50CompoundReader.FileEntry>
entries
private IndexInput
handle
private java.lang.String
segmentName
private int
version
-
Constructor Summary
Constructors Constructor Description Lucene50CompoundReader(Directory directory, SegmentInfo si, IOContext context)
Create a new CompoundFileDirectory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the directory.IndexOutput
createOutput(java.lang.String name, IOContext context)
Creates a new, empty file in the directory and returns anIndexOutput
instance for appending data to this file.IndexOutput
createTempOutput(java.lang.String prefix, java.lang.String suffix, IOContext context)
Creates a new, empty, temporary file in the directory and returns anIndexOutput
instance for appending data to this file.void
deleteFile(java.lang.String name)
Not implementedlong
fileLength(java.lang.String name)
Returns the length of a file in the directory.java.util.Set<java.lang.String>
getPendingDeletions()
Returns a set of files currently pending deletion in this directory.java.lang.String[]
listAll()
Returns an array of strings, one for each file in the directory.Lock
obtainLock(java.lang.String name)
Acquires and returns aLock
for a file with the given name.IndexInput
openInput(java.lang.String name, IOContext context)
Opens a stream for reading an existing file.private java.util.Map<java.lang.String,Lucene50CompoundReader.FileEntry>
readEntries(byte[] segmentID, Directory dir, java.lang.String entriesFileName)
Helper method that reads CFS entries from an input streamvoid
rename(java.lang.String from, java.lang.String to)
Not implementedvoid
sync(java.util.Collection<java.lang.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.java.lang.String
toString()
-
Methods inherited from class org.apache.lucene.store.Directory
copyFrom, ensureOpen, getTempFileName, openChecksumInput
-
-
-
-
Field Detail
-
directory
private final Directory directory
-
segmentName
private final java.lang.String segmentName
-
entries
private final java.util.Map<java.lang.String,Lucene50CompoundReader.FileEntry> entries
-
handle
private final IndexInput handle
-
version
private int version
-
-
Constructor Detail
-
Lucene50CompoundReader
public Lucene50CompoundReader(Directory directory, SegmentInfo si, IOContext context) throws java.io.IOException
Create a new CompoundFileDirectory.- Throws:
java.io.IOException
-
-
Method Detail
-
readEntries
private java.util.Map<java.lang.String,Lucene50CompoundReader.FileEntry> readEntries(byte[] segmentID, Directory dir, java.lang.String entriesFileName) throws java.io.IOException
Helper method that reads CFS entries from an input stream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Description copied from class:Directory
Closes the directory.
-
openInput
public IndexInput openInput(java.lang.String name, IOContext context) throws java.io.IOException
Description copied from class:Directory
Opens a stream for reading an existing file. This method must throw eitherNoSuchFileException
orFileNotFoundException
ifname
points to a non-existing file.
-
listAll
public java.lang.String[] listAll()
Returns an array of strings, one for each file in the directory.
-
deleteFile
public void deleteFile(java.lang.String name)
Not implemented- Specified by:
deleteFile
in classDirectory
- Parameters:
name
- the name of an existing file.- Throws:
java.lang.UnsupportedOperationException
- always: not supported by CFS
-
rename
public void rename(java.lang.String from, java.lang.String to)
Not implemented
-
syncMetaData
public 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 classDirectory
- See Also:
Directory.sync(Collection)
-
fileLength
public long fileLength(java.lang.String name) throws java.io.IOException
Returns the length of a file in the directory.- Specified by:
fileLength
in classDirectory
- Parameters:
name
- the name of an existing file.- Throws:
java.io.IOException
- if the file does not exist
-
createOutput
public IndexOutput createOutput(java.lang.String name, IOContext context) throws java.io.IOException
Description copied from class:Directory
Creates a new, empty file in the directory and returns anIndexOutput
instance for appending data to this file. This method must throwFileAlreadyExistsException
if the file already exists.- Specified by:
createOutput
in classDirectory
- Parameters:
name
- the name of the file to create.- Throws:
java.io.IOException
- in case of I/O error
-
createTempOutput
public IndexOutput createTempOutput(java.lang.String prefix, java.lang.String suffix, IOContext context) throws java.io.IOException
Description copied from class:Directory
Creates a new, empty, temporary file in the directory and returns anIndexOutput
instance for appending data to this file. The temporary file name (accessible viaIndexOutput.getName()
) will start withprefix
, end withsuffix
and have a reserved file extension.tmp
.- Specified by:
createTempOutput
in classDirectory
- Throws:
java.io.IOException
-
sync
public void sync(java.util.Collection<java.lang.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 classDirectory
- See Also:
Directory.syncMetaData()
-
obtainLock
public Lock obtainLock(java.lang.String name)
Description copied from class:Directory
Acquires and returns aLock
for a file with the given name.- Specified by:
obtainLock
in classDirectory
- Parameters:
name
- the name of the lock file
-
getPendingDeletions
public java.util.Set<java.lang.String> getPendingDeletions()
Description copied from class:Directory
Returns a set of files currently pending deletion in this directory.- Specified by:
getPendingDeletions
in classDirectory
-
-