mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
fix: fix index compatibility after upgrade (#45373)
issue: https://github.com/milvus-io/milvus/issues/45380 --------- Signed-off-by: SpadeA <tangchenjie1210@gmail.com>
This commit is contained in:
parent
50f198e346
commit
929dc65882
@ -86,12 +86,16 @@ IndexFactory::CreatePrimitiveScalarIndex<std::string>(
|
|||||||
}
|
}
|
||||||
if (index_type == BITMAP_INDEX_TYPE) {
|
if (index_type == BITMAP_INDEX_TYPE) {
|
||||||
return std::make_unique<BitmapIndex<std::string>>(file_manager_context);
|
return std::make_unique<BitmapIndex<std::string>>(file_manager_context);
|
||||||
}
|
} else if (index_type == HYBRID_INDEX_TYPE) {
|
||||||
if (index_type == HYBRID_INDEX_TYPE) {
|
|
||||||
return std::make_unique<HybridScalarIndex<std::string>>(
|
return std::make_unique<HybridScalarIndex<std::string>>(
|
||||||
create_index_info.tantivy_index_version, file_manager_context);
|
create_index_info.tantivy_index_version, file_manager_context);
|
||||||
}
|
} else if (index_type == MARISA_TRIE || index_type == MARISA_TRIE_UPPER) {
|
||||||
|
return CreateStringIndexMarisa(file_manager_context);
|
||||||
|
} else if (index_type == ASCENDING_SORT) {
|
||||||
return CreateStringIndexSort(file_manager_context);
|
return CreateStringIndexSort(file_manager_context);
|
||||||
|
} else {
|
||||||
|
ThrowInfo(Unsupported, "unsupported index type: {}", index_type);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ThrowInfo(Unsupported, "unsupported platform");
|
ThrowInfo(Unsupported, "unsupported platform");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -883,7 +883,7 @@ TEST(Sealed, LoadPkScalarIndex) {
|
|||||||
LoadIndexInfo pk_index;
|
LoadIndexInfo pk_index;
|
||||||
pk_index.field_id = pk_id.get();
|
pk_index.field_id = pk_id.get();
|
||||||
pk_index.field_type = DataType::INT64;
|
pk_index.field_type = DataType::INT64;
|
||||||
pk_index.index_params["index_type"] = "sort";
|
pk_index.index_params["index_type"] = "STL_SORT";
|
||||||
auto pk_data = dataset.get_col<int64_t>(pk_id);
|
auto pk_data = dataset.get_col<int64_t>(pk_id);
|
||||||
auto index = GenScalarIndexing<int64_t>(N, pk_data.data());
|
auto index = GenScalarIndexing<int64_t>(N, pk_data.data());
|
||||||
pk_index.index_params = GenIndexParams(index.get());
|
pk_index.index_params = GenIndexParams(index.get());
|
||||||
@ -962,7 +962,7 @@ TEST(Sealed, LoadScalarIndex) {
|
|||||||
LoadIndexInfo counter_index;
|
LoadIndexInfo counter_index;
|
||||||
counter_index.field_id = counter_id.get();
|
counter_index.field_id = counter_id.get();
|
||||||
counter_index.field_type = DataType::INT64;
|
counter_index.field_type = DataType::INT64;
|
||||||
counter_index.index_params["index_type"] = "sort";
|
counter_index.index_params["index_type"] = "STL_SORT";
|
||||||
auto counter_data = dataset.get_col<int64_t>(counter_id);
|
auto counter_data = dataset.get_col<int64_t>(counter_id);
|
||||||
auto index = GenScalarIndexing<int64_t>(N, counter_data.data());
|
auto index = GenScalarIndexing<int64_t>(N, counter_data.data());
|
||||||
counter_index.index_params = GenIndexParams(index.get());
|
counter_index.index_params = GenIndexParams(index.get());
|
||||||
@ -972,7 +972,7 @@ TEST(Sealed, LoadScalarIndex) {
|
|||||||
LoadIndexInfo double_index;
|
LoadIndexInfo double_index;
|
||||||
double_index.field_id = double_id.get();
|
double_index.field_id = double_id.get();
|
||||||
double_index.field_type = DataType::DOUBLE;
|
double_index.field_type = DataType::DOUBLE;
|
||||||
double_index.index_params["index_type"] = "sort";
|
double_index.index_params["index_type"] = "STL_SORT";
|
||||||
auto double_data = dataset.get_col<double>(double_id);
|
auto double_data = dataset.get_col<double>(double_id);
|
||||||
auto temp1 = GenScalarIndexing<double>(N, double_data.data());
|
auto temp1 = GenScalarIndexing<double>(N, double_data.data());
|
||||||
double_index.index_params = GenIndexParams(temp1.get());
|
double_index.index_params = GenIndexParams(temp1.get());
|
||||||
@ -982,7 +982,7 @@ TEST(Sealed, LoadScalarIndex) {
|
|||||||
LoadIndexInfo nothing_index;
|
LoadIndexInfo nothing_index;
|
||||||
nothing_index.field_id = nothing_id.get();
|
nothing_index.field_id = nothing_id.get();
|
||||||
nothing_index.field_type = DataType::INT32;
|
nothing_index.field_type = DataType::INT32;
|
||||||
nothing_index.index_params["index_type"] = "sort";
|
nothing_index.index_params["index_type"] = "STL_SORT";
|
||||||
auto nothing_data = dataset.get_col<int32_t>(nothing_id);
|
auto nothing_data = dataset.get_col<int32_t>(nothing_id);
|
||||||
auto temp2 = GenScalarIndexing<int32_t>(N, nothing_data.data());
|
auto temp2 = GenScalarIndexing<int32_t>(N, nothing_data.data());
|
||||||
nothing_index.index_params = GenIndexParams(temp2.get());
|
nothing_index.index_params = GenIndexParams(temp2.get());
|
||||||
|
|||||||
@ -406,7 +406,8 @@ GenSortedArr<std::string>(int64_t n) {
|
|||||||
std::vector<ScalarTestParams>
|
std::vector<ScalarTestParams>
|
||||||
GenBoolParams() {
|
GenBoolParams() {
|
||||||
std::vector<ScalarTestParams> ret;
|
std::vector<ScalarTestParams> ret;
|
||||||
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "sort"}}));
|
ret.emplace_back(
|
||||||
|
ScalarTestParams(MapParams(), {{"index_type", "STL_SORT"}}));
|
||||||
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}}));
|
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}}));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -414,7 +415,7 @@ GenBoolParams() {
|
|||||||
std::vector<ScalarTestParams>
|
std::vector<ScalarTestParams>
|
||||||
GenStringParams() {
|
GenStringParams() {
|
||||||
std::vector<ScalarTestParams> ret;
|
std::vector<ScalarTestParams> ret;
|
||||||
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "marisa"}}));
|
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "Trie"}}));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +433,8 @@ GenParams() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ScalarTestParams> ret;
|
std::vector<ScalarTestParams> ret;
|
||||||
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "sort"}}));
|
ret.emplace_back(
|
||||||
|
ScalarTestParams(MapParams(), {{"index_type", "STL_SORT"}}));
|
||||||
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}}));
|
ret.emplace_back(ScalarTestParams(MapParams(), {{"index_type", "flat"}}));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -465,27 +467,28 @@ GenDsFromPB(const google::protobuf::Message& msg) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::vector<std::string>
|
inline std::vector<std::string>
|
||||||
GetIndexTypes() {
|
GetIndexTypes() {
|
||||||
return std::vector<std::string>{"sort", milvus::index::BITMAP_INDEX_TYPE};
|
return std::vector<std::string>{"STL_SORT",
|
||||||
|
milvus::index::BITMAP_INDEX_TYPE};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline std::vector<std::string>
|
inline std::vector<std::string>
|
||||||
GetIndexTypes<std::string>() {
|
GetIndexTypes<std::string>() {
|
||||||
return std::vector<std::string>{
|
return std::vector<std::string>{
|
||||||
"sort", "marisa", milvus::index::BITMAP_INDEX_TYPE};
|
"STL_SORT", "Trie", milvus::index::BITMAP_INDEX_TYPE};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline std::vector<std::string>
|
inline std::vector<std::string>
|
||||||
GetIndexTypesV2() {
|
GetIndexTypesV2() {
|
||||||
return std::vector<std::string>{"sort", milvus::index::INVERTED_INDEX_TYPE};
|
return std::vector<std::string>{"STL_SORT",
|
||||||
|
milvus::index::INVERTED_INDEX_TYPE};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline std::vector<std::string>
|
inline std::vector<std::string>
|
||||||
GetIndexTypesV2<std::string>() {
|
GetIndexTypesV2<std::string>() {
|
||||||
return std::vector<std::string>{"marisa",
|
return std::vector<std::string>{"Trie", milvus::index::INVERTED_INDEX_TYPE};
|
||||||
milvus::index::INVERTED_INDEX_TYPE};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@ -723,7 +723,7 @@ func Test_parseIndexParams(t *testing.T) {
|
|||||||
ExtraParams: []*commonpb.KeyValuePair{
|
ExtraParams: []*commonpb.KeyValuePair{
|
||||||
{
|
{
|
||||||
Key: common.IndexTypeKey,
|
Key: common.IndexTypeKey,
|
||||||
Value: "marisa-trie",
|
Value: "Trie",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
IndexName: "",
|
IndexName: "",
|
||||||
|
|||||||
@ -274,14 +274,7 @@ func genScalarIndexCases(dtype schemapb.DataType) []indexTestCase {
|
|||||||
dtype: dtype,
|
dtype: dtype,
|
||||||
typeParams: nil,
|
typeParams: nil,
|
||||||
indexParams: map[string]string{
|
indexParams: map[string]string{
|
||||||
common.IndexTypeKey: "sort",
|
common.IndexTypeKey: "STL_SORT",
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dtype: dtype,
|
|
||||||
typeParams: nil,
|
|
||||||
indexParams: map[string]string{
|
|
||||||
common.IndexTypeKey: "flat",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -293,14 +286,14 @@ func genStringIndexCases(dtype schemapb.DataType) []indexTestCase {
|
|||||||
dtype: dtype,
|
dtype: dtype,
|
||||||
typeParams: nil,
|
typeParams: nil,
|
||||||
indexParams: map[string]string{
|
indexParams: map[string]string{
|
||||||
common.IndexTypeKey: "sort",
|
common.IndexTypeKey: "STL_SORT",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dtype: dtype,
|
dtype: dtype,
|
||||||
typeParams: nil,
|
typeParams: nil,
|
||||||
indexParams: map[string]string{
|
indexParams: map[string]string{
|
||||||
common.IndexTypeKey: "marisa-trie",
|
common.IndexTypeKey: "Trie",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user