コード例 #1
0
 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")
コード例 #2
0
ファイル: test_record.py プロジェクト: marvinHao/PySimpleDB
 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")
コード例 #3
0
ファイル: test_record.py プロジェクト: marvinHao/PySimpleDB
 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")
コード例 #4
0
 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")
コード例 #5
0
ファイル: test_record.py プロジェクト: marvinHao/PySimpleDB
 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")
コード例 #6
0
 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")
コード例 #7
0
 def tearDown(self):
     remove_some_start_with("temp")
コード例 #8
0
 def tearDown(self):
     remove_some_start_with("simple")
コード例 #9
0
 def setUp(self):
     remove_some_start_with("simple")
     SimpleDB.init_file_and_log_mgr("test")
     self.page = MaxPage()
コード例 #10
0
ファイル: test_fileMgr.py プロジェクト: marvinHao/PySimpleDB
 def tearDown(self):
     remove_some_start_with("temp")
コード例 #11
0
 def tearDown(self):
     remove_some_start_with("simple")
コード例 #12
0
 def setUp(self):
     remove_some_start_with("simple")
     SimpleDB.init_file_and_log_mgr("test")
     self.page = MaxPage()
コード例 #13
0
ファイル: test_buffer.py プロジェクト: zesantos/PySimpleDB
 def tearDown(self):
     remove_some_start_with("buffer")