类 FileReaderManager


  • public class FileReaderManager
    extends java.lang.Object
    FileReaderManager is a singleton, which is used to manage all file readers(opened file streams) to ensure that each file is opened at most once.
    • 方法详细资料

      • closeFileAndRemoveReader

        public void closeFileAndRemoveReader​(java.lang.String filePath)
                                      throws java.io.IOException
        抛出:
        java.io.IOException
      • get

        public org.apache.iotdb.tsfile.read.TsFileSequenceReader get​(java.lang.String filePath,
                                                                     boolean isClosed)
                                                              throws java.io.IOException
        Get the reader of the file(tsfile or unseq tsfile) indicated by filePath. If the reader already exists, just get it from closedFileReaderMap or unclosedFileReaderMap depending on isClosing . Otherwise a new reader will be created and cached.
        参数:
        filePath - the path of the file, of which the reader is desired.
        isClosed - whether the corresponding file still receives insertions or not.
        返回:
        the reader of the file specified by filePath.
        抛出:
        java.io.IOException - when reader cannot be created.
      • increaseFileReaderReference

        public void increaseFileReaderReference​(TsFileResource tsFile,
                                                boolean isClosed)
        Increase the reference count of the reader specified by filePath. Only when the reference count of a reader equals zero, the reader can be closed and removed.
      • decreaseFileReaderReference

        public void decreaseFileReaderReference​(TsFileResource tsFile,
                                                boolean isClosed)
        Decrease the reference count of the reader specified by filePath. This method is latch-free. Only when the reference count of a reader equals zero, the reader can be closed and removed.
      • closeAndRemoveAllOpenedReaders

        public void closeAndRemoveAllOpenedReaders()
                                            throws java.io.IOException
        Only for EnvironmentUtils.cleanEnv method. To make sure that unit tests and integration tests will not conflict with each other.
        抛出:
        java.io.IOException
      • contains

        public boolean contains​(TsFileResource tsFile,
                                boolean isClosed)
        This method is only for unit tests.
      • writeFileReferenceInfo

        public void writeFileReferenceInfo()
      • getClosedFileReaderMap

        public java.util.Map<java.lang.String,​org.apache.iotdb.tsfile.read.TsFileSequenceReader> getClosedFileReaderMap()
      • getUnclosedFileReaderMap

        public java.util.Map<java.lang.String,​org.apache.iotdb.tsfile.read.TsFileSequenceReader> getUnclosedFileReaderMap()