Class AbstractStoringPageFile<P extends Page>

  • Type Parameters:
    P - Page type
    All Implemented Interfaces:
    PageFile<P>
    Direct Known Subclasses:
    MemoryPageFile, OnDiskArrayPageFile, PersistentPageFile

    public abstract class AbstractStoringPageFile<P extends Page>
    extends AbstractPageFile<P>
    Abstract class implementing general methods of a PageFile. A PageFile stores objects that implement the Page interface.
    Since:
    0.1
    Author:
    Elke Achtert
    • Field Detail

      • emptyPages

        protected IntegerArray emptyPages
        A stack holding the empty page ids.
      • nextPageID

        protected int nextPageID
        The last page ID.
      • pageSize

        protected int pageSize
        The size of a page in Bytes.
    • Constructor Detail

      • AbstractStoringPageFile

        protected AbstractStoringPageFile​(int pageSize)
        Creates a new PageFile.
    • Method Detail

      • setPageID

        public int setPageID​(P page)
        Sets the id of the given page.
        Parameters:
        page - the page to set the id
        Returns:
        the page id
      • deletePage

        public void deletePage​(int pageID)
        Deletes the node with the specified id from this file.
        Parameters:
        pageID - the id of the node to be deleted
      • getNextEmptyPageID

        private int getNextEmptyPageID()
        Returns the next empty page id.
        Returns:
        the next empty page id
      • getNextPageID

        public int getNextPageID()
        Returns the next page id.
        Returns:
        the next page id
      • setNextPageID

        public void setNextPageID​(int nextPageID)
        Sets the next page id.
        Parameters:
        nextPageID - the next page id to be set
      • getPageSize

        public int getPageSize()
        Get the page size of this page file.
        Returns:
        page size
      • initialize

        public boolean initialize​(PageHeader header)
        Initialize the page file with the given header - return "true" if the file already existed.
        Parameters:
        header - Header
        Returns:
        true when the file already existed.