This package contains the classes for the Storage Manager, which is responsible for how data is stored in and retrieved from database files.
The start-up sequence for the storage layer is as follows:
The Storage Manager is initialized first.
StorageManager.initialize(edu.caltech.nanodb.server.NanoDBServer)method is invoked first.
- The directory for NanoDB's data files is determined.
StorageManagerconstructor is invoked.
FileManageris initialized, with the appropriate data directory.
BufferManageris initialized, wrapping the
- File-managers for table-files and index-files are initialized at this point. Generally they don't need to do anything at initialization time; it's just a convenient time to initialize them.
Implementing New Tuple-File Formats
Adding new tuple-file formats to NanoDB should be reasonably straightforward, but there are several interfaces that must all be implemented for the tuple file to be operational inside NanoDB.
The core implementation of the tuple-file format must be provided as
an implementation of the
TupleFileinterface, or one of its sub-interfaces. Depending on what the tuple-file format can provide, it may be appropriate to implement
SequentialTupleFilefor a format that maintains a logical ordering over all tuples, or
HashedTupleFilefor a format that supports constant-time tuple lookups using a subset of the tuple's columns. If none of these guarantees can be provided, then the
TupleFileinterface is the correct one to implement.
Certain operations on tuple files can't be provided on the
TupleFileimplementation itself, so they are provided by the
Interface Summary Interface Description BufferManagerObserverThis interface allows other classes to respond to operations performed by the
FileManagerThis interface specifies all operations that file managers must provide. HashedTupleFileThis interface extends the
TupleFileinterface, adding operations that can be provided on files of tuples that are hashed on a specific key.
PinnableThis interface provides the basic "pin" and "unpin" operations that pinnable objects need to provide. SequentialTupleFileThis interface extends the
TupleFileinterface, adding operations that can be provided on files of tuples that are stored in a specific sequential order.
TableManagerThis interface specifies the operations performed specifically on table files. TupleFileThis interface defines the most basic operations that all files storing tuples must support. TupleFileManagerThis interface defines the operations that can be performed on
TupleFiles, but that are at a higher level of implementation than the tuple file itself.
Class Summary Class Description BufferManagerThe buffer manager reduces the number of disk IO operations by managing an in-memory cache of data pages. BufferManager.CachedPageInfoThis helper class keeps track of a data page that is currently cached. BufferManager.SessionPinCountThis helper class records the pin-count of a data page as imposed by a given session, so that we can forcibly release the session's pins after each command the session completes. DBFileThis class provides page-level access to a database file, which contains some kind of data utilized in a database system. DBFileReaderThis class provides the basic abilty to read a
DBFileas a single sequential file, obscuring the fact that it is actually broken into pages.
DBFileWriter DBPageThis class represents a single page in a database file. DBPageIDA class representing the unique identity of a
DBPage, used as a key for tracking pages in maps.
FileManagerImplThe File Manager provides unbuffered, low-level operations for working with paged data files. FilePointerThis class represents a pointer to a location within a database file. IndexedTableManagerThis class provides an implementation of the
TableManagerinterface for tables that can have indexes and constraints on them.
PageReaderThis class facilitates sequences of read operations against a single
DBPageobject, by providing "position" state that is also updated after each read is performed.
PageTuple PageWriterThis class extends the
PageReaderclass to provide write operations as well as read operations.
SchemaWriterThis class contains a general purpose implementation for reading and writing a table schema into a data page. StatsWriterThis class encapsulates the operations of reading and writing table-statistics to a data file. StorageManagerThe Storage Manager provides facilities for managing files of tuples, including in-memory buffering of data pages and support for transactions.
Enum Summary Enum Description DBFileTypeThis enumeration specifies the different types of data file that the database knows about.
Exception Summary Exception Description DataFormatExceptionThis class represents runtime issues with data files not being in the proper format, or other such issues occurring. FileSystemExceptionThis class represents errors that occur while opening, closing and manipulating files. InvalidFilePointerExceptionThis exception class can be thrown when a file-pointer is discovered to be invalid for some reason. StorageExceptionThis class and its subclasses represent general storage errors that can be encountered when manipulating the various data files that comprise the database. TableExceptionThis class represents errors that occur while manipulating tables. TupleFileExceptionThis class represents errors that occur while manipulating tuple files.