mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
issue: #43427 This pr's main goal is merge #37417 to milvus 2.5 without conflicts. # Main Goals 1. Create and describe collections with geospatial type 2. Insert geospatial data into the insert binlog 3. Load segments containing geospatial data into memory 4. Enable query and search can display geospatial data 5. Support using GIS funtions like ST_EQUALS in query 6. Support R-Tree index for geometry type # Solution 1. **Add Type**: Modify the Milvus core by adding a Geospatial type in both the C++ and Go code layers, defining the Geospatial data structure and the corresponding interfaces. 2. **Dependency Libraries**: Introduce necessary geospatial data processing libraries. In the C++ source code, use Conan package management to include the GDAL library. In the Go source code, add the go-geom library to the go.mod file. 3. **Protocol Interface**: Revise the Milvus protocol to provide mechanisms for Geospatial message serialization and deserialization. 4. **Data Pipeline**: Facilitate interaction between the client and proxy using the WKT format for geospatial data. The proxy will convert all data into WKB format for downstream processing, providing column data interfaces, segment encapsulation, segment loading, payload writing, and cache block management. 5. **Query Operators**: Implement simple display and support for filter queries. Initially, focus on filtering based on spatial relationships for a single column of geospatial literal values, providing parsing and execution for query expressions.Now only support brutal search 7. **Client Modification**: Enable the client to handle user input for geospatial data and facilitate end-to-end testing.Check the modification in pymilvus. --------- Signed-off-by: Yinwei Li <yinwei.li@zilliz.com> Signed-off-by: Cai Zhang <cai.zhang@zilliz.com> Co-authored-by: ZhuXi <150327960+Yinwei-Yu@users.noreply.github.com>
86 lines
2.7 KiB
C++
86 lines
2.7 KiB
C++
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License
|
|
|
|
#pragma once
|
|
|
|
#include <pb/schema.pb.h>
|
|
#include <cmath>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "common/EasyAssert.h"
|
|
#include "indexbuilder/IndexCreatorBase.h"
|
|
#include "index/JsonInvertedIndex.h"
|
|
#include "indexbuilder/ScalarIndexCreator.h"
|
|
#include "indexbuilder/VecIndexCreator.h"
|
|
#include "indexbuilder/type_c.h"
|
|
#include "storage/Types.h"
|
|
#include "storage/FileManager.h"
|
|
|
|
namespace milvus::indexbuilder {
|
|
|
|
// consider template factory if too many factories are needed.
|
|
class IndexFactory {
|
|
public:
|
|
IndexFactory() = default;
|
|
IndexFactory(const IndexFactory&) = delete;
|
|
IndexFactory
|
|
operator=(const IndexFactory&) = delete;
|
|
|
|
public:
|
|
static IndexFactory&
|
|
GetInstance() {
|
|
// thread-safe enough after c++ 11
|
|
static IndexFactory instance;
|
|
return instance;
|
|
}
|
|
|
|
IndexCreatorBasePtr
|
|
CreateIndex(DataType type,
|
|
Config& config,
|
|
const storage::FileManagerContext& context) {
|
|
auto invalid_dtype_msg =
|
|
std::string("invalid data type: ") + std::to_string(int(type));
|
|
|
|
switch (type) {
|
|
case DataType::BOOL:
|
|
case DataType::INT8:
|
|
case DataType::INT16:
|
|
case DataType::INT32:
|
|
case DataType::INT64:
|
|
case DataType::FLOAT:
|
|
case DataType::DOUBLE:
|
|
case DataType::VARCHAR:
|
|
case DataType::STRING:
|
|
case DataType::ARRAY:
|
|
case DataType::JSON:
|
|
case DataType::GEOMETRY:
|
|
case DataType::TIMESTAMPTZ:
|
|
return CreateScalarIndex(type, config, context);
|
|
|
|
case DataType::VECTOR_FLOAT:
|
|
case DataType::VECTOR_FLOAT16:
|
|
case DataType::VECTOR_BFLOAT16:
|
|
case DataType::VECTOR_BINARY:
|
|
case DataType::VECTOR_SPARSE_U32_F32:
|
|
case DataType::VECTOR_INT8:
|
|
case DataType::VECTOR_ARRAY:
|
|
return std::make_unique<VecIndexCreator>(type, config, context);
|
|
|
|
default:
|
|
ThrowInfo(DataTypeInvalid,
|
|
fmt::format("invalid type is {}", invalid_dtype_msg));
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace milvus::indexbuilder
|