def test_resize_to_new_table(self): shared_proto_table_storage = ShardedProtoTableStorage() shared_proto_table_storage.initialize_from_dir( dir_name=self.TEST_DATA_DIR_1) new_table = shared_proto_table_storage.resize_to_new_table( new_size_per_shard=2, new_dir_name=self.TEST_DATA_DIR_3) self.assertEqual(new_table.get_num_entries(), 9) self.assertEqual(new_table.get_num_shards(), 5) gclient.rm_dir(self.TEST_DATA_DIR_3)
def test_write_1(self): shared_proto_table_storage = ShardedProtoTableStorage(size_per_shard=3) shared_proto_table_storage.initialize_from_dir( dir_name=self.TEST_DATA_DIR_1) shared_proto_table_storage.write(data={ 'test_7': self.EXAMPLE_PROTO, }) self.assertFalse(shared_proto_table_storage.is_empty()) self.assertEqual(shared_proto_table_storage.get_num_shards(), 3) gclient.rm_dir(self.TEST_DATA_DIR_1) gclient_ext.cp_folder(self.TEST_DATA_DIR_2, self.TEST_DATA_DIR_1)
def test_read_5(self): shared_proto_table_storage = ShardedProtoTableStorage() shared_proto_table_storage.initialize_from_dir( dir_name=self.TEST_DATA_DIR_1) shared_proto_table_storage.write( data={ 'test_7': self.EXAMPLE_PROTO, 'test_8': self.EXAMPLE_PROTO, 'test_9': self.EXAMPLE_PROTO, }) data = shared_proto_table_storage.read_multiple( params={'keys': ['test_9']}) self.assertTrue('test_9' in data) gclient.rm_dir(self.TEST_DATA_DIR_1) gclient_ext.cp_folder(self.TEST_DATA_DIR_2, self.TEST_DATA_DIR_1)