Class Codec
- java.lang.Object
-
- org.apache.lucene.codecs.Codec
-
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
- Direct Known Subclasses:
FilterCodec
,Lucene70Codec
,Lucene80Codec
,Lucene84Codec
,Lucene86Codec
,Lucene87Codec
,SimpleTextCodec
public abstract class Codec extends java.lang.Object implements NamedSPILoader.NamedSPI
Encodes/decodes an inverted index segment.Note, when extending this class, the name (
getName()
) is written into the index. In order for the segment to be read, the name must resolve to your implementation viaforName(String)
. This method uses Java'sService Provider Interface
(SPI) to resolve codec names.If you implement your own codec, make sure that it has a no-arg constructor so SPI can load it.
- See Also:
ServiceLoader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Codec.Holder
This static holder class prevents classloading deadlock by delaying init of default codecs and available codecs until needed.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
name
-
Constructor Summary
Constructors Modifier Constructor Description protected
Codec(java.lang.String name)
Creates a new codec.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>
availableCodecs()
returns a list of all available codec namesabstract CompoundFormat
compoundFormat()
Encodes/decodes compound filesabstract DocValuesFormat
docValuesFormat()
Encodes/decodes docvaluesabstract FieldInfosFormat
fieldInfosFormat()
Encodes/decodes field infos filestatic Codec
forName(java.lang.String name)
looks up a codec by namestatic Codec
getDefault()
expert: returns the default codec used for newly createdIndexWriterConfig
s.java.lang.String
getName()
Returns this codec's nameabstract LiveDocsFormat
liveDocsFormat()
Encodes/decodes live docsabstract NormsFormat
normsFormat()
Encodes/decodes document normalization valuesabstract PointsFormat
pointsFormat()
Encodes/decodes points indexabstract PostingsFormat
postingsFormat()
Encodes/decodes postingsstatic void
reloadCodecs(java.lang.ClassLoader classloader)
Reloads the codec list from the givenClassLoader
.abstract SegmentInfoFormat
segmentInfoFormat()
Encodes/decodes segment info filestatic void
setDefault(Codec codec)
expert: sets the default codec used for newly createdIndexWriterConfig
s.abstract StoredFieldsFormat
storedFieldsFormat()
Encodes/decodes stored fieldsabstract TermVectorsFormat
termVectorsFormat()
Encodes/decodes term vectorsjava.lang.String
toString()
returns the codec's name.
-
-
-
Constructor Detail
-
Codec
protected Codec(java.lang.String name)
Creates a new codec.The provided name will be written into the index segment: in order to for the segment to be read this class should be registered with Java's SPI mechanism (registered in META-INF/ of your jar file, etc).
- Parameters:
name
- must be all ascii alphanumeric, and less than 128 characters in length.
-
-
Method Detail
-
getName
public final java.lang.String getName()
Returns this codec's name- Specified by:
getName
in interfaceNamedSPILoader.NamedSPI
-
postingsFormat
public abstract PostingsFormat postingsFormat()
Encodes/decodes postings
-
docValuesFormat
public abstract DocValuesFormat docValuesFormat()
Encodes/decodes docvalues
-
storedFieldsFormat
public abstract StoredFieldsFormat storedFieldsFormat()
Encodes/decodes stored fields
-
termVectorsFormat
public abstract TermVectorsFormat termVectorsFormat()
Encodes/decodes term vectors
-
fieldInfosFormat
public abstract FieldInfosFormat fieldInfosFormat()
Encodes/decodes field infos file
-
segmentInfoFormat
public abstract SegmentInfoFormat segmentInfoFormat()
Encodes/decodes segment info file
-
normsFormat
public abstract NormsFormat normsFormat()
Encodes/decodes document normalization values
-
liveDocsFormat
public abstract LiveDocsFormat liveDocsFormat()
Encodes/decodes live docs
-
compoundFormat
public abstract CompoundFormat compoundFormat()
Encodes/decodes compound files
-
pointsFormat
public abstract PointsFormat pointsFormat()
Encodes/decodes points index
-
forName
public static Codec forName(java.lang.String name)
looks up a codec by name
-
availableCodecs
public static java.util.Set<java.lang.String> availableCodecs()
returns a list of all available codec names
-
reloadCodecs
public static void reloadCodecs(java.lang.ClassLoader classloader)
Reloads the codec list from the givenClassLoader
. Changes to the codecs are visible after the method ends, all iterators (availableCodecs()
,...) stay consistent.NOTE: Only new codecs are added, existing ones are never removed or replaced.
This method is expensive and should only be called for discovery of new codecs on the given classpath/classloader!
-
getDefault
public static Codec getDefault()
expert: returns the default codec used for newly createdIndexWriterConfig
s.
-
setDefault
public static void setDefault(Codec codec)
expert: sets the default codec used for newly createdIndexWriterConfig
s.
-
toString
public java.lang.String toString()
returns the codec's name. Subclasses can override to provide more detail (such as parameters).- Overrides:
toString
in classjava.lang.Object
-
-