Class DBFileWriter

  • All Implemented Interfaces:

    public class DBFileWriter
    extends DBFileReader

    A subclass of DBFileReader, this class provides the basic ability to read and write a DBFile as a single sequential file, obscuring the fact that it is actually broken into pages. As the file-pointer moves through the file, the Storage Manager is used to load individual pages into the buffer manager.

    It is certainly possible that a value being read or written might span two adjacent data pages. In these cases, the access will be a little slower, as the operation must access partial data from the first page, and then access the remainder of the data from the next page.

    Design Note:
    This class always has the current DBPage pinned, and it will unpin the current page when it moves into the next page. This means that when the writer is closed, it may still have a page that is pinned. Therefore, the class implements AutoCloseable so that users can call DBFileReader.close() on a writer to unpin the last page, or they can use this type with the "try-with-resources" Java syntax.
    • Field Detail

      • logger

        private static org.apache.logging.log4j.Logger logger
        A logging object for reporting anything interesting that happens.
    • Method Detail

      • write

        public void write​(byte[] b,
                          int off,
                          int len)
      • write

        public void write​(byte[] b)
      • writeBoolean

        public void writeBoolean​(boolean v)
      • writeByte

        public void writeByte​(int v)
      • writeShort

        public void writeShort​(int v)
      • writeChar

        public void writeChar​(int v)
      • writeInt

        public void writeInt​(int v)
      • writeLong

        public void writeLong​(long v)
      • writeFloat

        public void writeFloat​(float v)
      • writeDouble

        public void writeDouble​(double v)
      • writeVarString255

        public void writeVarString255​(java.lang.String value)
      • writeVarString65535

        public void writeVarString65535​(java.lang.String value)