Class DefaultDocValuesFormatFactory
LUCENENET specific class that implements the default functionality for the IDocValuesFormatFactory.
The most common use cases are:
- Initialize DefaultDocValuesFormatFactory with a set of CustomDocValuesFormatTypes.
- Subclass DefaultDocValuesFormatFactory and override GetDocValuesFormat(Type) so an external dependency injection container can be used to supply the instances (lifetime should be singleton). Note that you could alternately use the "named type" feature that many DI containers have to supply the type based on name by overriding GetDocValuesFormat(String).
- Subclass DefaultDocValuesFormatFactory and override GetDocValuesFormatType(String) so a type new type can be supplied that is not in the Lucene.Net.Codecs.DefaultDocValuesFormatFactory.docValuesFormatNameToTypeMap.
- Subclass DefaultDocValuesFormatFactory to add new or override the default DocValuesFormat types by overriding Initialize() and calling PutDocValuesFormatType(Type).
- Subclass DefaultDocValuesFormatFactory to scan additional assemblies for DocValuesFormat subclasses in by overriding Initialize() and calling ScanForDocValuesFormats(Assembly). For performance reasons, the default behavior only loads Lucene.Net codecs.
To set the IDocValuesFormatFactory, call SetDocValuesFormatFactory(IDocValuesFormatFactory).
Inherited Members
Namespace: Lucene.Net.Codecs
Assembly: Lucene.Net.dll
Syntax
public class DefaultDocValuesFormatFactory : NamedServiceFactory<DocValuesFormat>, IDocValuesFormatFactory, IServiceListable
Constructors
| Improve this Doc View SourceDefaultDocValuesFormatFactory()
Creates a new instance of DefaultDocValuesFormatFactory.
Declaration
public DefaultDocValuesFormatFactory()
Properties
| Improve this Doc View SourceAvailableServices
Gets a list of the available DocValuesFormats (by name).
Declaration
public virtual ICollection<string> AvailableServices { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | A ICollection{string} of DocValuesFormat names. |
CustomDocValuesFormatTypes
An array of custom DocValuesFormat-derived types to be registered. This property can be initialized during construction of DefaultDocValuesFormatFactory to make your custom codecs known to Lucene.
These types will be registered after the default Lucene types, so if a custom type has the same name as a Lucene DocValuesFormat (via DocValuesFormatNameAttribute) the custom type will replace the Lucene type with the same name.
Declaration
public IEnumerable<Type> CustomDocValuesFormatTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> |
Methods
| Improve this Doc View SourceGetDocValuesFormat(String)
Gets the DocValuesFormat instance from the provided name
.
Declaration
public virtual DocValuesFormat GetDocValuesFormat(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the DocValuesFormat instance to retrieve. |
Returns
Type | Description |
---|---|
DocValuesFormat | The DocValuesFormat instance. |
GetDocValuesFormat(Type)
Gets the DocValuesFormat instance from the provided type
.
Declaration
protected virtual DocValuesFormat GetDocValuesFormat(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of DocValuesFormat to retrieve. |
Returns
Type | Description |
---|---|
DocValuesFormat | The DocValuesFormat instance. |
GetDocValuesFormatType(String)
Gets the DocValuesFormat System.Type from the provided name
.
Declaration
protected virtual Type GetDocValuesFormatType(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the DocValuesFormat System.Type to retrieve. |
Returns
Type | Description |
---|---|
System.Type | The DocValuesFormat System.Type. |
Initialize()
Initializes the doc values type cache with the known DocValuesFormat types.
Override this method (and optionally call base.Initialize()
) to add your
own DocValuesFormat types by calling PutDocValuesFormatType(Type)
or ScanForDocValuesFormats(Assembly).
If two types have the same name by using the DocValuesFormatNameAttribute, the last one registered wins.
Declaration
protected override void Initialize()
Overrides
NewDocValuesFormat(Type)
Instantiates a DocValuesFormat based on the provided type
.
Declaration
protected virtual DocValuesFormat NewDocValuesFormat(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of DocValuesFormat to instantiate. |
Returns
Type | Description |
---|---|
DocValuesFormat | The new instance. |
PutDocValuesFormatType(Type)
Adds a DocValuesFormat type to the Lucene.Net.Codecs.DefaultDocValuesFormatFactory.docValuesFormatNameToTypeMap, using the name provided in the DocValuesFormatNameAttribute, if present, or the name of the codec class minus the "DocValuesFormat" suffix as the name by default.
Note that if a DocValuesFormat with the same name already exists in the map, calling this method will update it to the new type.
Declaration
protected virtual void PutDocValuesFormatType(Type docValuesFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Type | docValuesFormat | A type that subclasses DocValuesFormat. |
ScanForDocValuesFormats(IEnumerable<Assembly>)
Scans the given assemblies
for subclasses of Codec
and adds their names to the Lucene.Net.Codecs.DefaultDocValuesFormatFactory.docValuesFormatNameToTypeMap. Note that names will be
automatically overridden if the DocValuesFormat name appears multiple times - the last match wins.
Declaration
protected virtual void ScanForDocValuesFormats(IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | A list of assemblies to scan. The assemblies will be scanned from first to last, and the last match for each DocValuesFormat name wins. |
ScanForDocValuesFormats(Assembly)
Scans the given assembly
for subclasses of DocValuesFormat
and adds their names to the Lucene.Net.Codecs.DefaultDocValuesFormatFactory.docValuesFormatNameToTypeMap. Note that names will be
automatically overridden if the DocValuesFormat name appears multiple times - the last match wins.
Declaration
protected virtual void ScanForDocValuesFormats(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly to scan. |