| 182 | } |
| 183 | |
| 184 | static bool LoadFromVecsFile(aitheta2::IndexThreads::TaskGroup *group, |
| 185 | index::Collection *collection) { |
| 186 | tools::VecsReader reader; |
| 187 | if (!reader.load(FLAGS_file)) { |
| 188 | LOG_ERROR("Load vecs file failed."); |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | for (uint32_t i = 0; i < reader.num_vecs(); i++) { |
| 193 | Record record; |
| 194 | uint64_t key = reader.get_key(i); |
| 195 | const char *feature = (const char *)reader.get_vector(i); |
| 196 | |
| 197 | record.key = key; |
| 198 | record.vector.append(feature, reader.index_meta().element_size()); |
| 199 | record.dimension = reader.index_meta().dimension(); |
| 200 | group->submit(ailego::Closure::New(DoInsertCollection, collection, record)); |
| 201 | } |
| 202 | return true; |
| 203 | } |
| 204 | |
| 205 | static bool LoadFromTextFile(aitheta2::IndexThreads::TaskGroup *group, |
| 206 | index::Collection *collection) { |
no test coverage detected