Package edu.caltech.nanodb.storage
This package contains the classes for the Storage Manager, which is responsible for how data is stored in and retrieved from database files.
Startup Sequence
The start-up sequence for the storage layer is as follows:
-
The Storage Manager is initialized first.
- The
StorageManager.initialize(edu.caltech.nanodb.server.NanoDBServer)
method is invoked first. - The directory for NanoDB's data files is determined.
- The
StorageManager
constructor is invoked. - The
FileManager
is initialized, with the appropriate data directory. - The
BufferManager
is initialized, wrapping theFileManager
. - 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.
- The
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
TupleFile
interface, or one of its sub-interfaces. Depending on what the tuple-file format can provide, it may be appropriate to implementSequentialTupleFile
for a format that maintains a logical ordering over all tuples, orHashedTupleFile
for 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 theTupleFile
interface is the correct one to implement. -
Certain operations on tuple files can't be provided on the
TupleFile
implementation itself, so they are provided by theTupleFileManager
interface.
-
Interface Summary Interface Description BufferManagerObserver This interface allows other classes to respond to operations performed by theBufferManager
.FileManager This interface specifies all operations that file managers must provide.HashedTupleFile This interface extends theTupleFile
interface, adding operations that can be provided on files of tuples that are hashed on a specific key.Pinnable This interface provides the basic "pin" and "unpin" operations that pinnable objects need to provide.SequentialTupleFile This interface extends theTupleFile
interface, adding operations that can be provided on files of tuples that are stored in a specific sequential order.TableManager This interface specifies the operations performed specifically on table files.TupleFile This interface defines the most basic operations that all files storing tuples must support.TupleFileManager This interface defines the operations that can be performed onTupleFile
s, but that are at a higher level of implementation than the tuple file itself. -
Class Summary Class Description BufferManager The buffer manager reduces the number of disk IO operations by managing an in-memory cache of data pages.BufferManager.CachedPageInfo This helper class keeps track of a data page that is currently cached.BufferManager.SessionPinCount This 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.DBFile This class provides page-level access to a database file, which contains some kind of data utilized in a database system.DBFileReader This class provides the basic abilty to read aDBFile
as a single sequential file, obscuring the fact that it is actually broken into pages.DBFileWriter A subclass ofDBFileReader
, this class provides the basic ability to read and write aDBFile
as a single sequential file, obscuring the fact that it is actually broken into pages.DBPage This class represents a single page in a database file.DBPageID A class representing the unique identity of aDBPage
, used as a key for tracking pages in maps.FileManagerImpl The File Manager provides unbuffered, low-level operations for working with paged data files.FilePointer This class represents a pointer to a location within a database file.IndexedTableManager This class provides an implementation of theTableManager
interface for tables that can have indexes and constraints on them.PageReader This class facilitates sequences of read operations against a singleDBPage
object, by providing "position" state that is also updated after each read is performed.PageTuple PageWriter This class extends thePageReader
class to provide write operations as well as read operations.SchemaWriter This class contains a general purpose implementation for reading and writing a table schema into a data page.StatsWriter This class encapsulates the operations of reading and writing table-statistics to a data file.StorageManager The Storage Manager provides facilities for managing files of tuples, including in-memory buffering of data pages and support for transactions. -
Enum Summary Enum Description DBFileType This enumeration specifies the different types of data file that the database knows about. -
Exception Summary Exception Description DataFormatException This class represents runtime issues with data files not being in the proper format, or other such issues occurring.FileSystemException This class represents errors that occur while opening, closing and manipulating files.InvalidFilePointerException This exception class can be thrown when a file-pointer is discovered to be invalid for some reason.StorageException This class and its subclasses represent general storage errors that can be encountered when manipulating the various data files that comprise the database.TableException This class represents errors that occur while manipulating tables.TupleFileException This class represents errors that occur while manipulating tuple files.