Class ModificationFile

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class ModificationFile
    extends java.lang.Object
    implements java.lang.AutoCloseable
    ModificationFile 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.
    • Constructor Detail

      • ModificationFile

        public ModificationFile​(java.lang.String filePath)
        Construct a ModificationFile using a file as its storage.
        Parameters:
        filePath - the path of the storage file.
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Release resources such as streams and caches.
        Specified by:
        close in interface java.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.