Class OnDiskArrayPageFile<P extends Page>

  • Type Parameters:
    P - Page type
    All Implemented Interfaces:

    public class OnDiskArrayPageFile<P extends Page>
    extends AbstractStoringPageFile<P>
    A OnDiskArrayPageFile stores objects persistently that implement the Page interface. For convenience each page is represented by a single file. All pages are stored in a specified directory.
    Elke Achtert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger.
      • EMPTY_PAGE

        private static final int EMPTY_PAGE
        Indicates an empty page.
        See Also:
        Constant Field Values

        private static final int FILLED_PAGE
        Indicates a filled page.
        See Also:
        Constant Field Values
      • filename

        private java.nio.file.Path filename
        The file name to use
      • file

        private OnDiskArray file
        The file storing the pages.
      • header

        protected PageHeader header
        The header of this page file.
      • existed

        private final boolean existed
        Whether or not the file originally existed
    • Constructor Detail

      • OnDiskArrayPageFile

        public OnDiskArrayPageFile​(int pageSize,
                                   java.nio.file.Path filename)
        Creates a new OnDiskArrayPageFile from an existing file.
        pageSize - page size
        filename - the name of the file
    • Method Detail

      • readPage

        public P readPage​(int pageID)
        Reads the page with the given id from this file.
        pageID - the id of the page to be returned
        the page with the given pageId
      • writePage

        public void writePage​(int pageID,
                              P page)
        Write page to disk.
        Specified by:
        writePage in class AbstractPageFile<P extends Page>
        pageID - page id
        page - the page which has to be written to disk
      • clear

        public void clear()
        Clears this PageFile.
      • byteBufferToPage

        private P byteBufferToPage​(java.nio.ByteBuffer buffer)
        Reconstruct a serialized object from the specified byte array.
        buffer - the buffer from which the object should be reconstructed
        a serialized object from the specified byte array
      • pageToByteArray

        private byte[] pageToByteArray​(P page)
        Serializes an object into a byte array.
        page - the object to be serialized
        the byte array