diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 2a9146dc07bd367487f4ada81b05f161dd4815c4..a5752779742641d652c08eabe2340ed9201ed741 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -9,6 +9,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-412 - Fix gpu cache logical error - MS-416 - ExecutionEngineImpl::GpuCache has not return value cause crash - MS-417 - YAML sequence load disable cause scheduler startup failed +- MS-413 - Create index failed and server exited ## Improvement - MS-327 - Clean code for milvus diff --git a/cpp/src/wrapper/knowhere/vec_index.cpp b/cpp/src/wrapper/knowhere/vec_index.cpp index 0337f0ab67fc9417ed5707c66e65f435228e02e1..c31c5261dabedf1054d0e8279b33fe4f3dcefbd7 100644 --- a/cpp/src/wrapper/knowhere/vec_index.cpp +++ b/cpp/src/wrapper/knowhere/vec_index.cpp @@ -19,6 +19,8 @@ namespace zilliz { namespace milvus { namespace engine { +static constexpr float TYPICAL_COUNT = 1000000.0; + struct FileIOWriter { std::fstream fs; std::string name; @@ -192,7 +194,13 @@ server::KnowhereError write_index(VecIndexPtr index, const std::string &location // TODO(linxj): redo here. void AutoGenParams(const IndexType &type, const long &size, zilliz::knowhere::Config &cfg) { auto nlist = cfg.get_with_default("nlist", 0); - if (int(size/1000000.0) * nlist == 0) { cfg["nlist"] = int(size / 1000000.0 * 16384); } + if (size <= TYPICAL_COUNT/16384 + 1) { + //handle less row count, avoid nlist set to 0 + cfg["nlist"] = 1; + } else if (int(size/TYPICAL_COUNT) * nlist == 0) { + //calculate a proper nlist if nlist not specified or size less than TYPICAL_COUNT + cfg["nlist"] = int(size / TYPICAL_COUNT * 16384); + } if (!cfg.contains("gpu_id")) { cfg["gpu_id"] = int(0); } if (!cfg.contains("metric_type")) { cfg["metric_type"] = "L2"; }