public final class IndexFileNames
extends java.lang.Object
matchesExtension
), as well as generating file names from a segment name,
generation and extension (
fileNameFromGeneration
,
segmentFileName
).
NOTE: extensions used by codecs are not
listed here. You must interact with the Codec
directly.
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
CODEC_FILE_PATTERN
All files created by codecs much match this pattern (checked in
SegmentInfo).
|
static java.lang.String |
OLD_SEGMENTS_GEN
Name of the generation reference file name
|
static java.lang.String |
PENDING_SEGMENTS
Name of pending index segment file
|
static java.lang.String |
SEGMENTS
Name of the index segment file
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
fileNameFromGeneration(java.lang.String base,
java.lang.String ext,
long gen)
Computes the full file name from base, extension and generation.
|
static java.lang.String |
getExtension(java.lang.String filename)
Return the extension (anything after the first '.'),
or null if there is no '.' in the file name.
|
static boolean |
matchesExtension(java.lang.String filename,
java.lang.String ext)
Returns true if the given filename ends with the given extension.
|
static long |
parseGeneration(java.lang.String filename)
Returns the generation from this file name, or 0 if there is no
generation.
|
static java.lang.String |
parseSegmentName(java.lang.String filename)
Parses the segment name out of the given file name.
|
static java.lang.String |
segmentFileName(java.lang.String segmentName,
java.lang.String segmentSuffix,
java.lang.String ext)
Returns a file name that includes the given segment name, your own custom
name and extension.
|
static java.lang.String |
stripExtension(java.lang.String filename)
Removes the extension (anything after the first '.'),
otherwise returns the original filename.
|
static java.lang.String |
stripSegmentName(java.lang.String filename)
Strips the segment name out of the given file name.
|
public static final java.lang.String SEGMENTS
public static final java.lang.String PENDING_SEGMENTS
public static final java.lang.String OLD_SEGMENTS_GEN
public static final java.util.regex.Pattern CODEC_FILE_PATTERN
public static java.lang.String fileNameFromGeneration(java.lang.String base, java.lang.String ext, long gen)
ext
is
not an empty string.base
- main part of the file nameext
- extension of the filenamegen
- generationpublic static java.lang.String segmentFileName(java.lang.String segmentName, java.lang.String segmentSuffix, java.lang.String 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 boolean matchesExtension(java.lang.String filename, java.lang.String ext)
public static java.lang.String stripSegmentName(java.lang.String filename)
segmentFileName(java.lang.String, java.lang.String, java.lang.String)
or fileNameFromGeneration(java.lang.String, java.lang.String, long)
to create your
files, then this method simply removes whatever comes before the first '.',
or the second '_' (excluding both).public static long parseGeneration(java.lang.String filename)
public static java.lang.String parseSegmentName(java.lang.String filename)
public static java.lang.String stripExtension(java.lang.String filename)
public static java.lang.String getExtension(java.lang.String filename)
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.