Ejemplo n.º 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")
Ejemplo n.º 2
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")
Ejemplo n.º 3
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")
Ejemplo n.º 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")
Ejemplo n.º 5
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")
Ejemplo n.º 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")
Ejemplo n.º 7
0
 def tearDown(self):
     remove_some_start_with("temp")
Ejemplo n.º 8
0
 def tearDown(self):
     remove_some_start_with("simple")
Ejemplo n.º 9
0
 def setUp(self):
     remove_some_start_with("simple")
     SimpleDB.init_file_and_log_mgr("test")
     self.page = MaxPage()
Ejemplo n.º 10
0
 def tearDown(self):
     remove_some_start_with("temp")
Ejemplo n.º 11
0
 def tearDown(self):
     remove_some_start_with("simple")
Ejemplo n.º 12
0
 def setUp(self):
     remove_some_start_with("simple")
     SimpleDB.init_file_and_log_mgr("test")
     self.page = MaxPage()
Ejemplo n.º 13
0
 def tearDown(self):
     remove_some_start_with("buffer")