Class Codec
Encodes/decodes an inverted index segment.
Note, when extending this class, the name (Name) is written into the index. In order for the segment to be read, the name must resolve to your implementation via ForName(String). This method uses GetCodec(String) to resolve codec names.
To implement your own codec:
- Subclass this class.
- Subclass DefaultCodecFactory, override the Initialize() method,
and add the line
base.ScanForCodecs(typeof(YourCodec).GetTypeInfo().Assembly)
. If you have any codec classes in your assembly that are not meant for reading, you can add the ExcludeCodecFromScanAttribute to them so they are ignored by the scan. - set the new ICodecFactory by calling SetCodecFactory(ICodecFactory) at application startup.
Codec Names
Unlike the Java version, codec names are by default convention-based on the class name. If you name your custom codec class "MyCustomCodec", the codec name will the same name without the "Codec" suffix: "MyCustom".
You can override this default behavior by using the CodecNameAttribute to name the codec differently than this convention. Codec names must be all ASCII alphanumeric, and less than 128 characters in length.
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class Codec : object
Constructors
Name | Description |
---|---|
Codec() | Creates a new codec.
The Name will be written into the index segment: in order for
the segment to be read this class should be registered by subclassing DefaultCodecFactory and
calling |
Properties
Name | Description |
---|---|
Default | Expert: returns the default codec used for newly created IndexWriterConfigs. |
DocValuesFormat | Encodes/decodes docvalues. |
FieldInfosFormat | Encodes/decodes field infos file. |
LiveDocsFormat | Encodes/decodes live docs. |
Name | Returns this codec's name. |
NormsFormat | Encodes/decodes document normalization values. |
PostingsFormat | Encodes/decodes postings. |
SegmentInfoFormat | Encodes/decodes segment info file. |
StoredFieldsFormat | Encodes/decodes stored fields. |
TermVectorsFormat | Encodes/decodes term vectors. |
Methods
Name | Description |
---|---|
AvailableCodecs() | Returns a list of all available codec names. |
ForName(String) | Looks up a codec by name. |
GetCodecFactory() | Gets the associated codec factory. |
SetCodecFactory(ICodecFactory) | Sets the ICodecFactory instance used to instantiate Codec subclasses. |
ToString() | Returns the codec's name. Subclasses can override to provide more detail (such as parameters). |