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).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
Inherited Members
Namespace: Lucene.Net.Codecs
Assembly: Lucene.Net.dll
Syntax
public abstract class Codec
Constructors
| Improve this Doc View SourceCodec()
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 ScanForCodecs(Assembly) in the class constructor. The new ICodecFactory can be registered by calling SetCodecFactory(ICodecFactory) at application startup.
Declaration
protected Codec()
Properties
| Improve this Doc View SourceAvailableCodecs
Returns a list of all available codec names.
Declaration
public static ICollection<string> AvailableCodecs { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> |
Default
Expert: returns the default codec used for newly created IndexWriterConfigs.
Declaration
public static Codec Default { get; set; }
Property Value
Type | Description |
---|---|
Codec |
DocValuesFormat
Encodes/decodes docvalues.
Declaration
public abstract DocValuesFormat DocValuesFormat { get; }
Property Value
Type | Description |
---|---|
DocValuesFormat |
FieldInfosFormat
Encodes/decodes field infos file.
Declaration
public abstract FieldInfosFormat FieldInfosFormat { get; }
Property Value
Type | Description |
---|---|
FieldInfosFormat |
LiveDocsFormat
Encodes/decodes live docs.
Declaration
public abstract LiveDocsFormat LiveDocsFormat { get; }
Property Value
Type | Description |
---|---|
LiveDocsFormat |
Name
Returns this codec's name.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
NormsFormat
Encodes/decodes document normalization values.
Declaration
public abstract NormsFormat NormsFormat { get; }
Property Value
Type | Description |
---|---|
NormsFormat |
PostingsFormat
Encodes/decodes postings.
Declaration
public abstract PostingsFormat PostingsFormat { get; }
Property Value
Type | Description |
---|---|
PostingsFormat |
SegmentInfoFormat
Encodes/decodes segment info file.
Declaration
public abstract SegmentInfoFormat SegmentInfoFormat { get; }
Property Value
Type | Description |
---|---|
SegmentInfoFormat |
StoredFieldsFormat
Encodes/decodes stored fields.
Declaration
public abstract StoredFieldsFormat StoredFieldsFormat { get; }
Property Value
Type | Description |
---|---|
StoredFieldsFormat |
TermVectorsFormat
Encodes/decodes term vectors.
Declaration
public abstract TermVectorsFormat TermVectorsFormat { get; }
Property Value
Type | Description |
---|---|
TermVectorsFormat |
Methods
| Improve this Doc View SourceForName(String)
Looks up a codec by name.
Declaration
public static Codec ForName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type | Description |
---|---|
Codec |
GetCodecFactory()
Gets the associated codec factory.
Declaration
public static ICodecFactory GetCodecFactory()
Returns
Type | Description |
---|---|
ICodecFactory | The codec factory. |
SetCodecFactory(ICodecFactory)
Sets the ICodecFactory instance used to instantiate Codec subclasses.
Declaration
public static void SetCodecFactory(ICodecFactory codecFactory)
Parameters
Type | Name | Description |
---|---|---|
ICodecFactory | codecFactory | The new ICodecFactory. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
ToString()
Returns the codec's name. Subclasses can override to provide more detail (such as parameters).
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |