Class DataStructure

    • Constructor Detail

      • DataStructure

        public DataStructure​(String name,
                             int cacheGrpId,
                             @Nullable
                             @Nullable String grpName,
                             PageMemory pageMem,
                             @Nullable
                             @Nullable IgniteWriteAheadLogManager wal,
                             PageLockTrackerManager pageLockTrackerManager,
                             PageIoResolver pageIoRslvr,
                             byte pageFlag)
        Parameters:
        name - Structure name (for debugging purposes).
        cacheGrpId - Cache group id.
        grpName - Group name.
        pageMem - Page memory.
        wal - Write ahead log manager.
        pageLockTrackerManager - Page lock tracker manager.
        pageIoRslvr - Page IO resolver.
        pageFlag - Default flag value for allocated pages.
    • Method Detail

      • name

        public final String name()
        Returns:
        Tree name.
      • groupId

        public final int groupId()
        Returns:
        Cache group ID.
      • randomInt

        public static int randomInt​(int max)
        Parameters:
        max - Max.
        Returns:
        Random value from 0 (inclusive) to the given max value (exclusive).
      • releasePage

        protected final void releasePage​(long pageId,
                                         long page)
        Parameters:
        pageId - Page ID.
        page - Page pointer.
      • tryWriteLock

        protected final long tryWriteLock​(long pageId,
                                          long page)
        Parameters:
        pageId - Page ID
        page - Page pointer.
        Returns:
        Page address or 0 if failed to lock due to recycling.
      • writeLock

        protected final long writeLock​(long pageId,
                                       long page)
        Parameters:
        pageId - Page ID
        page - Page pointer.
        Returns:
        Page address.
      • writeUnlock

        protected final void writeUnlock​(long pageId,
                                         long page,
                                         long pageAddr,
                                         boolean dirty)

        Note: Default WAL record policy will be used.

        Parameters:
        pageId - Page ID
        page - Page pointer.
        pageAddr - Page address.
        dirty - Dirty flag.
      • readLock

        protected final long readLock​(long pageId,
                                      long page)
        Parameters:
        pageId - Page ID
        page - Page pointer.
        Returns:
        Page address.
      • readUnlock

        protected final void readUnlock​(long pageId,
                                        long page,
                                        long pageAddr)
        Parameters:
        pageId - Page ID
        page - Page pointer.
        pageAddr - Page address.
      • writeUnlock

        protected final void writeUnlock​(long pageId,
                                         long page,
                                         long pageAddr,
                                         Boolean walPlc,
                                         boolean dirty)
        Parameters:
        pageId - Page ID
        page - Page pointer.
        pageAddr - Page address.
        walPlc - Full page WAL record policy.
        dirty - Dirty flag.
      • needWalDeltaRecord

        protected final boolean needWalDeltaRecord​(long pageId,
                                                   long page,
                                                   Boolean walPlc)
        Parameters:
        pageId - Page ID.
        page - Page pointer.
        walPlc - Full page WAL record policy.
        Returns:
        true If we need to make a delta WAL record for the change in this page.
      • write

        protected final <R> R write​(long pageId,
                                    PageHandler<?,​R> h,
                                    int intArg,
                                    R lockFailed,
                                    IoStatisticsHolder statHolder)
                             throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        h - Handler.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • write

        protected final <X,​R> R write​(long pageId,
                                            PageHandler<X,​R> h,
                                            X arg,
                                            int intArg,
                                            R lockFailed,
                                            IoStatisticsHolder statHolder)
                                     throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        h - Handler.
        arg - Argument.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • write

        protected final <X,​R> R write​(long pageId,
                                            long page,
                                            PageHandler<X,​R> h,
                                            X arg,
                                            int intArg,
                                            R lockFailed,
                                            IoStatisticsHolder statHolder)
                                     throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        page - Page pointer.
        h - Handler.
        arg - Argument.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • write

        protected final <X,​R> R write​(long pageId,
                                            PageHandler<X,​R> h,
                                            PageIO init,
                                            X arg,
                                            int intArg,
                                            R lockFailed,
                                            IoStatisticsHolder statHolder)
                                     throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        h - Handler.
        init - IO for new page initialization or null if it is an existing page.
        arg - Argument.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • read

        protected final <X,​R> R read​(long pageId,
                                           PageHandler<X,​R> h,
                                           X arg,
                                           int intArg,
                                           R lockFailed,
                                           IoStatisticsHolder statHolder)
                                    throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        h - Handler.
        arg - Argument.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • read

        protected final <X,​R> R read​(long pageId,
                                           long page,
                                           PageHandler<X,​R> h,
                                           X arg,
                                           int intArg,
                                           R lockFailed,
                                           IoStatisticsHolder statHolder)
                                    throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        page - Page pointer.
        h - Handler.
        arg - Argument.
        intArg - Argument of type int.
        lockFailed - Result in case of lock failure due to page recycling.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Handler result.
        Throws:
        IgniteCheckedException - If failed.
      • recyclePage

        protected final long recyclePage​(long pageId,
                                         long page,
                                         long pageAddr,
                                         Boolean walPlc)
                                  throws IgniteCheckedException
        Parameters:
        pageId - Page ID.
        page - Page pointer.
        pageAddr - Page address.
        walPlc - Full page WAL record policy.
        Returns:
        Recycled page ID.
        Throws:
        IgniteCheckedException - If failed.
      • pageSize

        protected int pageSize()
        Returns:
        Page size without encryption overhead.
      • close

        public void close()
        Frees the resources allocated by this structure.