Package org.apache.iotdb.db.wal.utils
Class WALFileUtils
- java.lang.Object
-
- org.apache.iotdb.db.wal.utils.WALFileUtils
-
public class WALFileUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringWAL_FILE_NAME_FORMATstatic java.util.regex.PatternWAL_FILE_NAME_PATTERNversionId is a self-incremented id number, helping to maintain the order of wal files.
-
Constructor Summary
Constructors Constructor Description WALFileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidascSortByVersionId(java.io.File[] walFiles)Sort wal files by version id with ascending orderstatic intbinarySearchFileBySearchIndex(java.io.File[] files, long targetSearchIndex)Find index of the file which probably contains target insert plan.static java.lang.StringgetLogFileName(long versionId, long startSearchIndex, WALFileStatus status)Get .wal filenamestatic java.io.File[]listAllWALFiles(java.io.File dir)List all .wal files in the directorystatic longparseStartSearchIndex(java.lang.String filename)Parse start search index from filenamestatic WALFileStatusparseStatusCode(java.lang.String filename)Parse status code from filenamestatic longparseVersionId(java.lang.String filename)Parse version id from filenamestatic booleanwalFilenameFilter(java.io.File dir, java.lang.String name)Return true when this file is .wal file
-
-
-
Field Detail
-
WAL_FILE_NAME_PATTERN
public static final java.util.regex.Pattern WAL_FILE_NAME_PATTERN
versionId is a self-incremented id number, helping to maintain the order of wal files. startSearchIndex is the valid search index of last flushed wal entry. statusCode is the. For example:
_0-0-1.wal: 1, 2, 3, -1, -1, 4, 5, -1
_1-5-0.wal: -1, -1, -1, -1
_2-5-1.wal: 6, 7, 8, 9, -1, -1, -1, 10, 11, -1, 12, 12
_3-12-1.wal: 12, 12, 12, 12, 12
_4-12-1.wal: 12, 13, 14, 15, 16, -1
-
WAL_FILE_NAME_FORMAT
public static final java.lang.String WAL_FILE_NAME_FORMAT
- See Also:
- Constant Field Values
-
-
Method Detail
-
walFilenameFilter
public static boolean walFilenameFilter(java.io.File dir, java.lang.String name)Return true when this file is .wal file
-
listAllWALFiles
public static java.io.File[] listAllWALFiles(java.io.File dir)
List all .wal files in the directory
-
parseVersionId
public static long parseVersionId(java.lang.String filename)
Parse version id from filename
-
parseStartSearchIndex
public static long parseStartSearchIndex(java.lang.String filename)
Parse start search index from filename
-
parseStatusCode
public static WALFileStatus parseStatusCode(java.lang.String filename)
Parse status code from filename
-
ascSortByVersionId
public static void ascSortByVersionId(java.io.File[] walFiles)
Sort wal files by version id with ascending order
-
binarySearchFileBySearchIndex
public static int binarySearchFileBySearchIndex(java.io.File[] files, long targetSearchIndex)Find index of the file which probably contains target insert plan.
Given wal files [ _0-0-1.wal, _1-5-0.wal, _2-5-1.wal, _3-12-1.wal, _4-12-1.wal ], details as below:
_0-0-1.wal: 1, 2, 3, -1, -1, 4, 5, -1
_1-5-0.wal: -1, -1, -1, -1
_2-5-1.wal: 6, 7, 8, 9, -1, -1, -1, 10, 11, -1, 12, 12
_3-12-1.wal: 12, 12, 12, 12, 12
_4-12-1.wal: 12, 13, 14, 15, 16, -1
searching [1, 5] will return 0, searching [6, 12] will return 1, search [13, infinity) will return 3, others will return -1- Parameters:
files- files to be searchedtargetSearchIndex- search index of target insert plan- Returns:
- index of the file which probably contains target insert plan , -1 if the target insert plan definitely doesn't exist
-
getLogFileName
public static java.lang.String getLogFileName(long versionId, long startSearchIndex, WALFileStatus status)Get .wal filename
-
-