Class PagePartitionCountersIO


  • public class PagePartitionCountersIO
    extends PageIO
    Page IO for Partition Counters, IO for pages containing cache ID mapping to its size. Used only for caches in shared cache groups.
    • Constructor Detail

      • PagePartitionCountersIO

        public PagePartitionCountersIO​(int ver)
        Parameters:
        ver - Page format version.
    • Method Detail

      • serializeCacheSizes

        public byte[] serializeCacheSizes​(Map<Integer,​Long> cacheSizes)
        Parameters:
        cacheSizes - Cache sizes: cache Id in shared group mapped to its size. Not null.
        Returns:
        Serialized cache sizes or 0-byte length array if map was empty.
      • initNewPage

        public void initNewPage​(long pageAddr,
                                long pageId,
                                int pageSize,
                                PageMetrics metrics)
        Overrides:
        initNewPage in class PageIO
        Parameters:
        pageAddr - Page address.
        pageId - Page ID.
        pageSize - Page size.
        metrics - Page metrics for tracking page allocation. Can be null if no tracking is required.
        See Also:
        EncryptionSpi.encryptedSize(int)
      • getNextCountersPageId

        public long getNextCountersPageId​(long pageAddr)
        Parameters:
        pageAddr - Page address.
        Returns:
        Next counters page ID or 0 if it does not exist.
      • setNextCountersPageId

        public void setNextCountersPageId​(long pageAddr,
                                          long partMetaPageId)
        Parameters:
        pageAddr - Page address.
        partMetaPageId - Next counters page ID.
      • writeCacheSizes

        public int writeCacheSizes​(int pageSize,
                                   long pageAddr,
                                   byte[] cacheSizes,
                                   int itemsOff)
        Parameters:
        pageSize - Page size without encryption overhead.
        pageAddr - Page address.
        cacheSizes - Serialized cache size items (pairs of cache ID and its size).
        Returns:
        Number of written pairs.
      • readCacheSizes

        public boolean readCacheSizes​(long pageAddr,
                                      Map<Integer,​Long> res)
        Parameters:
        pageAddr - Page address.
        res - Result map of cache sizes.
        Returns:
        True if the map was fully read.
      • getCapacity

        public int getCapacity​(int pageSize)
        Parameters:
        pageSize - Page size.
        Returns:
        Maximum number of items which can be stored in buffer.
      • getFreeSpace

        public int getFreeSpace​(int pageSize,
                                long pageAddr)
        Count of bytes that is currently free in this page and possibly can be used to place additional payload.
        Specified by:
        getFreeSpace in class PageIO
        Parameters:
        pageSize - Page size.
        pageAddr - Page address.
        Returns:
        Free space.