Ejemplo n.º 1
0
 def test_Btree_with_pricerange(self):
     """Test building Btree index on column: pricerange"""
     R = Table.inputfromfile('test_csv/sales1.csv')
     Table.Btree(R, 'pricerange')
     self.assertIsNotNone(R.index)
     self.assertIsNotNone(R.index['pricerange'])
     test_index = R.index['pricerange']
     self.assertEqual([0, 1], test_index.get('moderate'))
     self.assertEqual([2, 3, 5, 6, 7, 10, 11], test_index.get('outrageous'))
     self.assertEqual([4], test_index.get('supercheap'))
     self.assertEqual([9], test_index.get('cheap'))
     self.assertEqual([8], test_index.get('expensive'))
Ejemplo n.º 2
0
 def test_select_with_index_btree(self):
     """Test select with btree index on column pricerage"""
     R = Table.inputfromfile('test_csv/real_sales1.csv')
     condition = "pricerange = 'cheap'"
     start = time.time()
     for i in range(10):
         R1 = Table.select(R, condition)
     end = time.time()
     without_index = end - start
     Table.Btree(R, 'pricerange')
     start = time.time()
     for i in range(10):
         R1 = Table.select(R, condition)
     end = time.time()
     with_index = end - start
     for row in R1.table:
         self.assertEqual(row['pricerange'], 'cheap')
     self.assertLess(with_index, without_index / 5)