Interface IMappedPageFactory

  • All Known Implementing Classes:
    MappedPageFactoryImpl

    public interface IMappedPageFactory
    Memory mapped page management ADT
    Author:
    bulldog
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      IMappedPage acquirePage​(long index)
      Acquire a mapped page with specific index from the factory
      void deleteAllPages()
      delete all mapped pages currently available in this factory, this call will remove all pages from the cache and delete all back files.
      void deletePage​(long index)
      delete a mapped page with specific index in this factory, this call will remove the page from the cache if it is cached and delete back file.
      void deletePages​(Set<Long> indexes)
      delete mapped pages with a set of specific indexes in this factory, this call will remove the pages from the cache if they ware cached and delete back files.
      void deletePagesBefore​(long timestamp)
      Delete all pages with last modified timestamp before the specific timestamp.
      void deletePagesBeforePageIndex​(long pageIndex)
      Delete all pages before the specific index
      void flush()
      Persist any changes in cached mapped pages
      Set<String> getBackPageFileSet()
      A set of back page file names
      long getBackPageFileSize()
      Total size of all page files
      int getCacheSize()
      For test, get current cache size
      Set<Long> getExistingBackFileIndexSet()
      For test, get a list of indexes of current existing back files.
      long getFirstPageIndexBefore​(long timestamp)
      Get index of a page file with last modified timestamp closest to specific timestamp.
      String getPageDir()
      Current set page directory.
      long getPageFileLastModifiedTime​(long index)
      Get last modified timestamp of page file index
      Set<Long> getPageIndexSetBefore​(long timestamp)
      Get all indexes of pages with last modified timestamp before the specific timestamp.
      int getPageSize()
      Current set page size, when creating pages, the factory will only create pages with this size.
      void releaseCachedPages()
      remove all cached pages from the cache and close resources associated with the cached pages.
      void releasePage​(long index)
      Return the mapped page to the factory, calling thread release the page to inform the factory that it has finished with the page, so the factory get a chance to recycle the page to save memory.
    • Method Detail

      • acquirePage

        IMappedPage acquirePage​(long index)
                         throws IOException
        Acquire a mapped page with specific index from the factory
        Parameters:
        index - the index of the page
        Returns:
        a mapped page
        Throws:
        IOException - exception thrown if there was any IO error during the acquire operation
      • releasePage

        void releasePage​(long index)
        Return the mapped page to the factory, calling thread release the page to inform the factory that it has finished with the page, so the factory get a chance to recycle the page to save memory.
        Parameters:
        index - the index of the page
      • getPageSize

        int getPageSize()
        Current set page size, when creating pages, the factory will only create pages with this size.
        Returns:
        an integer number
      • getPageDir

        String getPageDir()
        Current set page directory.
        Returns:
        directory name
      • deletePage

        void deletePage​(long index)
                 throws IOException
        delete a mapped page with specific index in this factory, this call will remove the page from the cache if it is cached and delete back file.
        Parameters:
        index - the index of the page
        Throws:
        IOException - exception thrown if there was any IO error during the delete operation.
      • deletePages

        void deletePages​(Set<Long> indexes)
                  throws IOException
        delete mapped pages with a set of specific indexes in this factory, this call will remove the pages from the cache if they ware cached and delete back files.
        Parameters:
        indexes - the indexes of the pages
        Throws:
        IOException - exception thrown if IO error occurs
      • deleteAllPages

        void deleteAllPages()
                     throws IOException
        delete all mapped pages currently available in this factory, this call will remove all pages from the cache and delete all back files.
        Throws:
        IOException - exception thrown if there was any IO error during the delete operation.
      • releaseCachedPages

        void releaseCachedPages()
                         throws IOException
        remove all cached pages from the cache and close resources associated with the cached pages.
        Throws:
        IOException - exception thrown if there was any IO error during the release operation.
      • getPageIndexSetBefore

        Set<Long> getPageIndexSetBefore​(long timestamp)
        Get all indexes of pages with last modified timestamp before the specific timestamp.
        Parameters:
        timestamp - the timestamp to check
        Returns:
        a set of indexes
      • deletePagesBefore

        void deletePagesBefore​(long timestamp)
                        throws IOException
        Delete all pages with last modified timestamp before the specific timestamp.
        Parameters:
        timestamp - the timestamp to check
        Throws:
        IOException - exception thrown if there was any IO error during the delete operation.
      • deletePagesBeforePageIndex

        void deletePagesBeforePageIndex​(long pageIndex)
                                 throws IOException
        Delete all pages before the specific index
        Parameters:
        pageIndex - page file index to check
        Throws:
        IOException - exception thrown if there was any IO error during the delete operation.
      • getPageFileLastModifiedTime

        long getPageFileLastModifiedTime​(long index)
        Get last modified timestamp of page file index
        Parameters:
        index - page index
        Returns:
        last modified time
      • getFirstPageIndexBefore

        long getFirstPageIndexBefore​(long timestamp)
        Get index of a page file with last modified timestamp closest to specific timestamp.
        Parameters:
        timestamp - the timestamp to check
        Returns:
        a page index
      • getExistingBackFileIndexSet

        Set<Long> getExistingBackFileIndexSet()
        For test, get a list of indexes of current existing back files.
        Returns:
        a set of indexes
      • getCacheSize

        int getCacheSize()
        For test, get current cache size
        Returns:
        an integer number
      • flush

        void flush()
        Persist any changes in cached mapped pages
      • getBackPageFileSet

        Set<String> getBackPageFileSet()
        A set of back page file names
        Returns:
        file name set
      • getBackPageFileSize

        long getBackPageFileSize()
        Total size of all page files
        Returns:
        total size