def init_collection_general(self, prefix="test", insert_data=False, nb=ct.default_nb, partition_num=0, is_binary=False, is_all_data_type=False, auto_id=False, dim=ct.default_dim, is_index=False, primary_field=ct.default_int64_field_name, is_flush=True, name=None, **kwargs): """ target: create specified collections method: 1. create collections (binary/non-binary, default/all data type, auto_id or not) 2. create partitions if specified 3. insert specified (binary/non-binary, default/all data type) data into each partition if any 4. not load if specifying is_index as True expected: return collection and raw data, insert ids """ log.info("Test case of search interface: initialize before test case") self._connect() collection_name = cf.gen_unique_str(prefix) if name is not None: collection_name = name vectors = [] binary_raw_vectors = [] insert_ids = [] time_stamp = 0 # 1 create collection default_schema = cf.gen_default_collection_schema( auto_id=auto_id, dim=dim, primary_field=primary_field) if is_binary: default_schema = cf.gen_default_binary_collection_schema( auto_id=auto_id, dim=dim, primary_field=primary_field) if is_all_data_type: default_schema = cf.gen_collection_schema_all_datatype( auto_id=auto_id, dim=dim, primary_field=primary_field) log.info("init_collection_general: collection creation") collection_w = self.init_collection_wrap(name=collection_name, schema=default_schema, **kwargs) # 2 add extra partitions if specified (default is 1 partition named "_default") if partition_num > 0: cf.gen_partitions(collection_w, partition_num) # 3 insert data if specified if insert_data: collection_w, vectors, binary_raw_vectors, insert_ids, time_stamp = \ cf.insert_data(collection_w, nb, is_binary, is_all_data_type, auto_id=auto_id, dim=dim) if is_flush: assert collection_w.is_empty is False assert collection_w.num_entities == nb # This condition will be removed after auto index feature if not is_index: collection_w.load() return collection_w, vectors, binary_raw_vectors, insert_ids, time_stamp
def init_collection_general(self, prefix, insert_data=False, nb=ct.default_nb, partition_num=0, is_binary=False, is_all_data_type=False, auto_id=False, dim=ct.default_dim, is_index=False): """ target: create specified collections method: 1. create collections (binary/non-binary) 2. create partitions if specified 3. insert specified binary/non-binary data into each partition if any expected: return collection and raw data """ log.info("Test case of search interface: initialize before test case") self._connect() collection_name = cf.gen_unique_str(prefix) vectors = [] binary_raw_vectors = [] insert_ids = [] # 1 create collection default_schema = cf.gen_default_collection_schema(auto_id=auto_id, dim=dim) if is_binary: default_schema = cf.gen_default_binary_collection_schema( auto_id=auto_id, dim=dim) if is_all_data_type: default_schema = cf.gen_collection_schema_all_datatype( auto_id=auto_id, dim=dim) log.info("init_collection_general: collection creation") collection_w = self.init_collection_wrap(name=collection_name, schema=default_schema) # 2 add extra partitions if specified (default is 1 partition named "_default") if partition_num > 0: cf.gen_partitions(collection_w, partition_num) # 3 insert data if specified if insert_data: collection_w, vectors, binary_raw_vectors, insert_ids = \ cf.insert_data(collection_w, nb, is_binary, is_all_data_type, auto_id=auto_id, dim=dim) assert collection_w.is_empty is False assert collection_w.num_entities == nb # This condition will be removed after auto index feature if not is_index: collection_w.load() return collection_w, vectors, binary_raw_vectors, insert_ids
def init_collection_general(self, prefix, insert_data=False, nb=ct.default_nb, partition_num=0, is_binary=False): """ target: create specified collections method: 1. create collections (binary/non-binary) 2. create partitions if specified 3. insert specified binary/non-binary data into each partition if any expected: return collection and raw data """ log.info("Test case of search interface: initialize before test case") conn = self._connect() collection_name = cf.gen_unique_str(prefix) vectors = [] binary_raw_vectors = [] # 1 create collection if is_binary: default_schema = cf.gen_default_binary_collection_schema() else: default_schema = cf.gen_default_collection_schema() log.info("init_collection_general: collection creation") collection_w = self.init_collection_wrap(name=collection_name, schema=default_schema) # 2 add extra partitions if specified (default is 1 partition named "_default") if partition_num > 0: cf.gen_partitions(collection_w, partition_num) # 3 insert data if specified if insert_data: collection_w, vectors, binary_raw_vectors = cf.insert_data( collection_w, nb, is_binary) if nb <= 32000: conn.flush([collection_w.name]) assert collection_w.is_empty == False assert collection_w.num_entities == nb collection_w.load() return collection_w, vectors, binary_raw_vectors