C# Class Lucene.Net.Index.IndexFileNames

this class contains useful constants representing filenames and extensions used by lucene, as well as convenience methods for querying whether a file name matches an extension ({@link #matchesExtension(String, String) matchesExtension}), as well as generating file names from a segment name, generation and extension ( #fileNameFromGeneration(String, String, long) fileNameFromGeneration, #segmentFileName(String, String, String) segmentFileName).

NOTE: extensions used by codecs are not listed here. You must interact with the Codec directly. @lucene.internal

显示文件 Open project: apache/lucenenet Class Usage Examples

Public Properties

Property Type Description
CODEC_FILE_PATTERN System.Text.RegularExpressions.Regex
INDEX_EXTENSIONS string[]
SEGMENTS_GEN string

Public Methods

Method Description
FileNameFromGeneration ( string @base, string ext, long gen ) : string

Computes the full file name from base, extension and generation. If the generation is -1, the file name is null. If it's 0, the file name is <base>.<ext>. If it's > 0, the file name is <base>_<gen>.<ext>.
NOTE: .<ext> is added to the name only if ext is not an empty string.

GetExtension ( string filename ) : string

Return the extension (anything after the first '.'), or null if there is no '.' in the file name.

MatchesExtension ( string filename, string ext ) : bool

Returns true if the given filename ends with the given extension. One should provide a pure extension, without '.'.

ParseSegmentName ( string filename ) : string

Parses the segment name out of the given file name.

SegmentFileName ( string segmentName, string segmentSuffix, string ext ) : string

Returns a file name that includes the given segment name, your own custom name and extension. The format of the filename is: <segmentName>(_<name>)(.<ext>).

NOTE: .<ext> is added to the result file name only if ext is not empty.

NOTE: _<segmentSuffix> is added to the result file name only if it's not the empty string

NOTE: all custom files should be named using this method, or otherwise some structures may fail to handle them properly (such as if they are added to compound files).

StripExtension ( string filename ) : string

Removes the extension (anything after the first '.'), otherwise returns the original filename.

StripSegmentName ( string filename ) : string

Strips the segment name out of the given file name. If you used #segmentFileName or #fileNameFromGeneration to create your files, then this method simply removes whatever comes before the first '.', or the second '_' (excluding both).

Private Methods

Method Description
IndexFileNames ( ) : System.Diagnostics

No instance

IndexOfSegmentName ( string filename ) : int

locates the boundary of the segment name, or -1

Method Details

FileNameFromGeneration() public static method

Computes the full file name from base, extension and generation. If the generation is -1, the file name is null. If it's 0, the file name is <base>.<ext>. If it's > 0, the file name is <base>_<gen>.<ext>.
NOTE: .<ext> is added to the name only if ext is not an empty string.
public static FileNameFromGeneration ( string @base, string ext, long gen ) : string
@base string
ext string extension of the filename
gen long generation
return string

GetExtension() public static method

Return the extension (anything after the first '.'), or null if there is no '.' in the file name.
public static GetExtension ( string filename ) : string
filename string
return string

MatchesExtension() public static method

Returns true if the given filename ends with the given extension. One should provide a pure extension, without '.'.
public static MatchesExtension ( string filename, string ext ) : bool
filename string
ext string
return bool

ParseSegmentName() public static method

Parses the segment name out of the given file name.
public static ParseSegmentName ( string filename ) : string
filename string
return string

SegmentFileName() public static method

Returns a file name that includes the given segment name, your own custom name and extension. The format of the filename is: <segmentName>(_<name>)(.<ext>).

NOTE: .<ext> is added to the result file name only if ext is not empty.

NOTE: _<segmentSuffix> is added to the result file name only if it's not the empty string

NOTE: all custom files should be named using this method, or otherwise some structures may fail to handle them properly (such as if they are added to compound files).

public static SegmentFileName ( string segmentName, string segmentSuffix, string ext ) : string
segmentName string
segmentSuffix string
ext string
return string

StripExtension() public static method

Removes the extension (anything after the first '.'), otherwise returns the original filename.
public static StripExtension ( string filename ) : string
filename string
return string

StripSegmentName() public static method

Strips the segment name out of the given file name. If you used #segmentFileName or #fileNameFromGeneration to create your files, then this method simply removes whatever comes before the first '.', or the second '_' (excluding both).
public static StripSegmentName ( string filename ) : string
filename string
return string

Property Details

CODEC_FILE_PATTERN public_oe static_oe property

All files created by codecs much match this pattern (checked in SegmentInfo).
public static Regex,System.Text.RegularExpressions CODEC_FILE_PATTERN
return System.Text.RegularExpressions.Regex

INDEX_EXTENSIONS public_oe static_oe property

this array contains all filename extensions used by Lucene's index files, with one exception, namely the extension made up from .s + a number. Also note that Lucene's segments_N files do not have any filename extension.
public static string[] INDEX_EXTENSIONS
return string[]

SEGMENTS_GEN public_oe static_oe property

Name of the generation reference file name
public static string SEGMENTS_GEN
return string