Show / Hide Table of Contents

    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:

    1. Subclass this class.
    2. 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.
    3. set the new ICodecFactory by calling SetCodecFactory(ICodecFactory) at application startup.
    If your codec has dependencies, you may also override GetCodec(Type) to inject them via pure DI or a DI container. See DI-Friendly Framework to understand the approach used.

    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
    System.Object
    Codec
    FilterCodec
    Lucene3xCodec
    Lucene40Codec
    Lucene41Codec
    Lucene42Codec
    Lucene45Codec
    Lucene46Codec
    Namespace: Lucene.Net.Codecs
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class Codec : object

    Constructors

    | Improve this Doc View Source

    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 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 Source

    AvailableCodecs

    Returns a list of all available codec names.

    Declaration
    public static ICollection<string> AvailableCodecs { get; }
    Property Value
    Type Description
    ICollection<System.String>
    | Improve this Doc View Source

    Default

    Expert: returns the default codec used for newly created IndexWriterConfigs.

    Declaration
    public static Codec Default { get; set; }
    Property Value
    Type Description
    Codec
    | Improve this Doc View Source

    DocValuesFormat

    Encodes/decodes docvalues.

    Declaration
    public abstract DocValuesFormat DocValuesFormat { get; }
    Property Value
    Type Description
    DocValuesFormat
    | Improve this Doc View Source

    FieldInfosFormat

    Encodes/decodes field infos file.

    Declaration
    public abstract FieldInfosFormat FieldInfosFormat { get; }
    Property Value
    Type Description
    FieldInfosFormat
    | Improve this Doc View Source

    LiveDocsFormat

    Encodes/decodes live docs.

    Declaration
    public abstract LiveDocsFormat LiveDocsFormat { get; }
    Property Value
    Type Description
    LiveDocsFormat
    | Improve this Doc View Source

    Name

    Returns this codec's name.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    NormsFormat

    Encodes/decodes document normalization values.

    Declaration
    public abstract NormsFormat NormsFormat { get; }
    Property Value
    Type Description
    NormsFormat
    | Improve this Doc View Source

    PostingsFormat

    Encodes/decodes postings.

    Declaration
    public abstract PostingsFormat PostingsFormat { get; }
    Property Value
    Type Description
    PostingsFormat
    | Improve this Doc View Source

    SegmentInfoFormat

    Encodes/decodes segment info file.

    Declaration
    public abstract SegmentInfoFormat SegmentInfoFormat { get; }
    Property Value
    Type Description
    SegmentInfoFormat
    | Improve this Doc View Source

    StoredFieldsFormat

    Encodes/decodes stored fields.

    Declaration
    public abstract StoredFieldsFormat StoredFieldsFormat { get; }
    Property Value
    Type Description
    StoredFieldsFormat
    | Improve this Doc View Source

    TermVectorsFormat

    Encodes/decodes term vectors.

    Declaration
    public abstract TermVectorsFormat TermVectorsFormat { get; }
    Property Value
    Type Description
    TermVectorsFormat

    Methods

    | Improve this Doc View Source

    ForName(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
    | Improve this Doc View Source

    GetCodecFactory()

    Gets the associated codec factory.

    Declaration
    public static ICodecFactory GetCodecFactory()
    Returns
    Type Description
    ICodecFactory

    The codec factory.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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

    See Also

    DefaultCodecFactory
    ICodecFactory
    CodecNameAttribute
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)