Class ModificationFile
- java.lang.Object
-
- org.apache.iotdb.db.engine.modification.ModificationFile
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class ModificationFile extends java.lang.Object implements java.lang.AutoCloseableModificationFile stores the Modifications of a TsFile or unseq file in another file in the same directory. Methods in this class are highly synchronized for concurrency safety.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMPACTION_FILE_SUFFIXstatic java.lang.StringFILE_SUFFIX
-
Constructor Summary
Constructors Constructor Description ModificationFile(java.lang.String filePath)Construct a ModificationFile using a file as its storage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()voidclose()Release resources such as streams and caches.ModificationFilecreateHardlink()Create a hardlink for the modification file.booleanexists()static ModificationFilegetCompactionMods(TsFileResource tsFileResource)java.lang.StringgetFilePath()java.util.Collection<Modification>getModifications()Get all modifications stored in this file.static ModificationFilegetNormalMods(TsFileResource tsFileResource)voidremove()voidsetFilePath(java.lang.String filePath)voidwrite(Modification mod)Write a modification in this file.
-
-
-
Field Detail
-
FILE_SUFFIX
public static final java.lang.String FILE_SUFFIX
- See Also:
- Constant Field Values
-
COMPACTION_FILE_SUFFIX
public static final java.lang.String COMPACTION_FILE_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close() throws java.io.IOExceptionRelease resources such as streams and caches.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.io.IOException
-
abort
public void abort() throws java.io.IOException- Throws:
java.io.IOException
-
write
public void write(Modification mod) throws java.io.IOException
Write a modification in this file. The modification will first be written to the persistent store then the memory cache.- Parameters:
mod- the modification to be written.- Throws:
java.io.IOException- if IOException is thrown when writing the modification to the store.
-
getModifications
public java.util.Collection<Modification> getModifications()
Get all modifications stored in this file.- Returns:
- an ArrayList of modifications.
-
getFilePath
public java.lang.String getFilePath()
-
setFilePath
public void setFilePath(java.lang.String filePath)
-
remove
public void remove() throws java.io.IOException- Throws:
java.io.IOException
-
exists
public boolean exists()
-
createHardlink
public ModificationFile createHardlink()
Create a hardlink for the modification file. The hardlink with have a suffix like ".{sysTime}_{randomLong}"- Returns:
- a new ModificationFile with its path changed to the hardlink, or null if the origin file does not exist or the hardlink cannot be created.
-
getNormalMods
public static ModificationFile getNormalMods(TsFileResource tsFileResource)
-
getCompactionMods
public static ModificationFile getCompactionMods(TsFileResource tsFileResource)
-
-