Code for all 6.830 labs will be available in this repo. Once you have set up your class repo, you pull lab code from here.
Directions can be here
Instructions for labs (including how to submit answers) are here
simple DB structure:
8585347487
Type:
- INT_TYPE
- STRING_TYPE
TupleDesc:
- TDItem 1. Type (fieldType) 2. String (fieldName)
RecordId (to a specific page of a specific table):
Field: 1. StringField 2. IntField
Tuple:
- TupleDesc (schema)
- RecordId 1. pageID 2. tupleNum
- array of Fields (Field)
Catalog:
- String (table name)
- String (primary key)
- DbFile 1. ID
HeapFile (one for each table):
- set of HeapPage (each page has BufferPool.DEFAULT_PAGE_SIZE bytes)
HeapPage:
- a set of slots (一个slot一个tuple, tuple有固定的大小 )
- a header (bitmap)
class fields:
- pageID
- tuple description
- header (bitmap)
- array of Tuples
- number of slots (maximum number of tuples)
- number of empty slots
Predicate: 1. 1 field (field ID that is the index of field in the Tuple object. Tuple里面的第几个field) 2. 1 operator (op) 3. 1 operand (Field)
"->" means "use"
HeapFile iterator -> Bufferpool.getPage() -> HeapFile readPage (read from disk)
HeapFile insert -> Bufferpool.getPage() -> HeapFile readPage
HeapFile delete -> Bufferpool.getPage() -> HeapFile readPage
Bufferpool insertTuple -> HeapFile insertTuple -> 1. HeapPage insert (on a free one or a new page) 2. writePage(). (write to disk)
Bufferpool deleteTuple -> HeapFile deleteTuple -> 1. HeapPage insert () 2. put page in the buffer pool
-
HeapFile.insertTuple(), HeapFile.deleteTuple() and HeapFile.iterator() should both use BufferPool.getPage()
-
BufferPool.insertTuple() and BufferPool.deleteTupe() call markDirty()
-
Release all locks associated with a transaction after it has committed or aborted to ensure strict 2PL