def test_recordpage(self): SimpleDB.init_file_log_and_buffer_mgr("test") schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) blk = Block(ti1.file_name(), 0) tx = Transaction() rp = RecordPage(blk, ti1, tx) self.assertFalse(rp.next()) self.assertTrue(rp.insert()) rp.set_int("IntField", 256) rp.set_string("StringField", "Sample") ID = rp.current_id() self.assertFalse(rp.next()) rp.move_to_id(ID - 1) self.assertTrue(rp.next()) rp.move_to_id(ID) self.assertEqual(rp.get_int("IntField"), 256) self.assertEqual(rp.get_string("StringField"), "Sample") tx.commit() #keep("table") #keep("simple") tx.pin(blk) rp.delete() rp.move_to_id(ID - 1) self.assertFalse(rp.next()) rp.close() self.assertIsNone(rp._blk) tx.commit() remove_some_start_with("table") remove_some_start_with("simple")
def test_recordpage(self): SimpleDB.init_file_log_and_buffer_mgr("test") schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) blk = Block(ti1.file_name(), 0) tx = Transaction() rp = RecordPage(blk, ti1, tx) self.assertFalse(rp.next()) self.assertTrue(rp.insert()) rp.set_int("IntField", 256) rp.set_string("StringField", "Sample") ID = rp.current_id() self.assertFalse(rp.next()) rp.move_to_id(ID-1) self.assertTrue(rp.next()) rp.move_to_id(ID) self.assertEqual(rp.get_int("IntField"), 256) self.assertEqual(rp.get_string("StringField"), "Sample") tx.commit() #keep("table") #keep("simple") tx.pin(blk) rp.delete() rp.move_to_id(ID-1) self.assertFalse(rp.next()) rp.close() self.assertIsNone(rp._blk) tx.commit() remove_some_start_with("table") remove_some_start_with("simple")
def test_tableinfor(self): schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) ti2 = TableInfo("table2", ti1.schema(), ti1._offset, ti1.record_length()) self.assertEqual(ti2.file_name(), "table2.tbl") self.assertEqual(ti1.offset("IntField"), ti2.offset("IntField")) remove_some_start_with("table")
def test_tableinfor(self): schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) ti2 = TableInfo("table2", ti1.schema(), ti1._offset, ti1.record_length()) self.assertEqual(ti2.file_name(), "table2.tbl") self.assertEqual(ti1.offset("IntField"), ti2.offset("IntField")) remove_some_start_with("table")
def test_recordformatter(self): SimpleDB.init_file_log_and_buffer_mgr("test") schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) fmtr = RecordFormatter(ti1) page = MaxPage() page.read(Block(ti1.file_name(), 0)) fmtr.format(page) page.write(Block(ti1.file_name(), 0)) remove_some_start_with("table")
def test_recordformatter(self): SimpleDB.init_file_log_and_buffer_mgr("test") schema = Schema() schema.add_int_field("IntField") schema.add_string_field("StringField", 8) ti1 = TableInfo("table1", schema) fmtr = RecordFormatter(ti1) page = MaxPage() page.read(Block(ti1.file_name(), 0)) fmtr.format(page) page.write(Block(ti1.file_name(), 0)) remove_some_start_with("table")
def tearDown(self): remove_some_start_with("temp")
def tearDown(self): remove_some_start_with("simple")
def setUp(self): remove_some_start_with("simple") SimpleDB.init_file_and_log_mgr("test") self.page = MaxPage()
def tearDown(self): remove_some_start_with("temp")
def tearDown(self): remove_some_start_with("simple")
def setUp(self): remove_some_start_with("simple") SimpleDB.init_file_and_log_mgr("test") self.page = MaxPage()
def tearDown(self): remove_some_start_with("buffer")