Interface ISchemaPage

  • All Known Implementing Classes:
    SchemaPage

    public interface ISchemaPage
    • Method Detail

      • write

        long write​(short segIdx,
                   java.lang.String key,
                   java.nio.ByteBuffer buffer)
            throws org.apache.iotdb.commons.exception.MetadataException
        Insert a content directly into specified segment, without considering preallocate and reallocate segment.
        Find the right segment instance which MUST exists, cache the segment and insert the record.
        If not enough, reallocate inside page first, or throw exception for new page then.

        Notice that, since SchemaFile.reEstimateSegSize(int) may increase segment with very small extent, which originates from design of SchemaFile.estimateSegmentSize(IMNode), a twice relocate will suffice any nodes smaller than 1024 KiB.
        This reason works for update(short, String, ByteBuffer) as well.

        Returns:
        return 0 if write succeed, a positive for next segment address
        Throws:
        SchemaPageOverflowException - no next segment, no spare space inside page
        org.apache.iotdb.commons.exception.MetadataException
      • update

        void update​(short segIdx,
                    java.lang.String key,
                    java.nio.ByteBuffer buffer)
             throws org.apache.iotdb.commons.exception.MetadataException
        The record is definitely inside specified segment. This method compare old and new buffer to decide whether update in place.
        If segment not enough, it will reallocate in this page first, and update segment offset list.
        If no more space for reallocation, throw SchemaPageOverflowException and return a negative for new page.

        See write(short, String, ByteBuffer) for the detail reason of a twice try.

        Throws:
        org.apache.iotdb.commons.exception.MetadataException
      • hasRecordKeyInSegment

        boolean hasRecordKeyInSegment​(java.lang.String key,
                                      short segId)
                               throws SegmentNotFoundException
        Check if record exists with name or alias.
        Parameters:
        key - name or alias of target child
        segId - target segment index
        Throws:
        SegmentNotFoundException
      • getPageIndex

        int getPageIndex()
      • getSpareSize

        short getSpareSize()
      • getPageBuffer

        void getPageBuffer​(java.nio.ByteBuffer dst)
      • isCapableForSize

        boolean isCapableForSize​(short size)
      • syncPageBuffer

        void syncPageBuffer()
        While segments are always synchronized with buffer SchemaPage.pageBuffer, header and tail are not. This method will synchronize them with in mem attributes.
      • allocNewSegment

        short allocNewSegment​(short size)
                       throws java.io.IOException,
                              SchemaPageOverflowException
        Allocate space for a new segment inside this page
        Parameters:
        size - expected segment size
        Returns:
        segment index in this page, negative for not enough space
        Throws:
        java.io.IOException
        SchemaPageOverflowException
      • transplantSegment

        long transplantSegment​(ISchemaPage srcPage,
                               short segId,
                               short newSegSize)
                        throws org.apache.iotdb.commons.exception.MetadataException
        Transplant designated segment from srcPage, to spare space of the page
        Parameters:
        srcPage - source page conveys source segment
        segId - id of the target segment
        newSegSize - size of new segment in this page
        Throws:
        org.apache.iotdb.commons.exception.MetadataException - if spare not enough, segment not found or inconsistency