Class SchemaFile

  • All Implemented Interfaces:
    ISchemaFile

    public class SchemaFile
    extends java.lang.Object
    implements ISchemaFile
    This class is mainly aimed to manage space all over the file.

    This class is meant to open a .pmt(Persistent MTree) file, and maintains the header of the file. It Loads or writes a page length bytes at once, with an 32 bits int to index a page inside a file. Use SlottedFile to manipulate segment(sp) inside a page(an array of bytes).

    • Field Detail

      • FILE_HEADER_SIZE

        public static int FILE_HEADER_SIZE
      • PAGE_LENGTH

        public static int PAGE_LENGTH
      • PAGE_INDEX_MASK

        public static long PAGE_INDEX_MASK
      • PAGE_HEADER_SIZE

        public static short PAGE_HEADER_SIZE
      • PAGE_CACHE_SIZE

        public static int PAGE_CACHE_SIZE
      • ROOT_INDEX

        public static int ROOT_INDEX
      • INDEX_LENGTH

        public static int INDEX_LENGTH
      • SEG_OFF_DIG

        public static short SEG_OFF_DIG
      • SEG_MAX_SIZ

        public static short SEG_MAX_SIZ
      • SEG_SIZE_LST

        public static short[] SEG_SIZE_LST
      • SEG_MIN_SIZ

        public static short SEG_MIN_SIZ
      • SEG_INDEX_DIGIT

        public static int SEG_INDEX_DIGIT
      • SEG_INDEX_MASK

        public static long SEG_INDEX_MASK
      • SCHEMA_FOLDER

        public static java.lang.String SCHEMA_FOLDER
    • Method Detail

      • initSchemaFile

        public static ISchemaFile initSchemaFile​(java.lang.String sgName,
                                                 int schemaRegionId)
                                          throws java.io.IOException,
                                                 org.apache.iotdb.commons.exception.MetadataException
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • loadSchemaFile

        public static ISchemaFile loadSchemaFile​(java.lang.String sgName,
                                                 int schemaRegionId)
                                          throws java.io.IOException,
                                                 org.apache.iotdb.commons.exception.MetadataException
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • loadSchemaFile

        public static ISchemaFile loadSchemaFile​(java.io.File file)
                                          throws java.io.IOException,
                                                 org.apache.iotdb.commons.exception.MetadataException
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • init

        public IMNode init()
                    throws org.apache.iotdb.commons.exception.MetadataException
        Description copied from interface: ISchemaFile
        Get the storage group node, with its segment address of 0.
        Specified by:
        init in interface ISchemaFile
        Returns:
        node instance, template name as hash code
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • updateStorageGroupNode

        public boolean updateStorageGroupNode​(IStorageGroupMNode sgNode)
                                       throws java.io.IOException
        Description copied from interface: ISchemaFile
        Modify header of schema file corresponding to the storage group node synchronously
        Specified by:
        updateStorageGroupNode in interface ISchemaFile
        Parameters:
        sgNode - node to be updated
        Returns:
        true if success
        Throws:
        java.io.IOException
      • writeMNode

        public void writeMNode​(IMNode node)
                        throws org.apache.iotdb.commons.exception.MetadataException,
                               java.io.IOException
        Description copied from interface: ISchemaFile
        Only storage group node along with its descendents could be flushed into schema file.
        Specified by:
        writeMNode in interface ISchemaFile
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • delete

        public void delete​(IMNode node)
                    throws java.io.IOException,
                           org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        delete in interface ISchemaFile
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • getChildNode

        public IMNode getChildNode​(IMNode parent,
                                   java.lang.String childName)
                            throws org.apache.iotdb.commons.exception.MetadataException,
                                   java.io.IOException
        Specified by:
        getChildNode in interface ISchemaFile
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • getChildren

        public java.util.Iterator<IMNode> getChildren​(IMNode parent)
                                               throws org.apache.iotdb.commons.exception.MetadataException,
                                                      java.io.IOException
        Specified by:
        getChildren in interface ISchemaFile
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface ISchemaFile
        Throws:
        java.io.IOException
      • sync

        public void sync()
                  throws java.io.IOException
        Specified by:
        sync in interface ISchemaFile
        Throws:
        java.io.IOException
      • clear

        public void clear()
                   throws java.io.IOException,
                          org.apache.iotdb.commons.exception.MetadataException
        Specified by:
        clear in interface ISchemaFile
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • inspect

        public java.lang.String inspect()
                                 throws org.apache.iotdb.commons.exception.MetadataException,
                                        java.io.IOException
        Throws:
        org.apache.iotdb.commons.exception.MetadataException
        java.io.IOException
      • getGlobalIndex

        public static long getGlobalIndex​(int pageIndex,
                                          short segIndex)
      • getPageIndex

        public static int getPageIndex​(long globalIndex)
      • getSegIndex

        public static short getSegIndex​(long globalIndex)
      • getNodeAddress

        public static long getNodeAddress​(IMNode node)
      • setNodeAddress

        public static IMNode setNodeAddress​(IMNode node,
                                            long addr)
      • getPageOnTest

        public SchemaPage getPageOnTest​(int index)
                                 throws java.io.IOException,
                                        org.apache.iotdb.commons.exception.MetadataException
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException
      • getTargetSegmentOnTest

        public long getTargetSegmentOnTest​(long srcSegAddr,
                                           java.lang.String key)
                                    throws java.io.IOException,
                                           org.apache.iotdb.commons.exception.MetadataException
        Throws:
        java.io.IOException
        org.apache.iotdb.commons.exception.MetadataException