mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
This commit adds sparse float vector support to segcore with the following: 1. data type enum declarations 2. Adds corresponding data structures for handling sparse float vectors in various scenarios, including: * FieldData as a bridge between the binlog and the in memory data structures * mmap::Column as the in memory representation of a sparse float vector column of a sealed segment; * ConcurrentVector as the in memory representation of a sparse float vector of a growing segment which supports inserts. 3. Adds logic in payload reader/writer to serialize/deserialize from/to binlog 4. Adds the ability to allow the index node to build sparse float vector index 5. Adds the ability to allow the query node to build growing index for growing segment and temp index for sealed segment without index built This commit also includes some code cleanness, comment improvement, and some unit tests for sparse vector. https://github.com/milvus-io/milvus/issues/29419 Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
138 lines
3.2 KiB
C++
138 lines
3.2 KiB
C++
// Licensed to the LF AI & Data foundation under one
|
|
// or more contributor license agreements. See the NOTICE file
|
|
// distributed with this work for additional information
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
// to you 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 <iostream>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
namespace milvus::storage {
|
|
|
|
/**
|
|
* @brief This ChunkManager is abstract interface for milvus that
|
|
* used to manager operation and interaction with storage
|
|
*/
|
|
class ChunkManager {
|
|
public:
|
|
/**
|
|
* @brief Whether file exists or not
|
|
* @param filepath
|
|
* @return true
|
|
* @return false
|
|
*/
|
|
virtual bool
|
|
Exist(const std::string& filepath) = 0;
|
|
|
|
/**
|
|
* @brief Get file size
|
|
* @param filepath
|
|
* @return uint64_t
|
|
*/
|
|
virtual uint64_t
|
|
Size(const std::string& filepath) = 0;
|
|
|
|
/**
|
|
* @brief Read file to buffer
|
|
* @param filepath
|
|
* @param buf
|
|
* @param len
|
|
* @return uint64_t
|
|
*/
|
|
virtual uint64_t
|
|
Read(const std::string& filepath, void* buf, uint64_t len) = 0;
|
|
|
|
/**
|
|
* @brief Write buffer to file without offset
|
|
* @param filepath
|
|
* @param buf
|
|
* @param len
|
|
*/
|
|
virtual void
|
|
Write(const std::string& filepath, void* buf, uint64_t len) = 0;
|
|
|
|
/**
|
|
* @brief Read file to buffer with offset
|
|
* @param filepath
|
|
* @param buf
|
|
* @param len
|
|
* @return uint64_t
|
|
*/
|
|
virtual uint64_t
|
|
Read(const std::string& filepath,
|
|
uint64_t offset,
|
|
void* buf,
|
|
uint64_t len) = 0;
|
|
|
|
/**
|
|
* @brief Write buffer to file with offset
|
|
* @param filepath
|
|
* @param buf
|
|
* @param len
|
|
*/
|
|
virtual void
|
|
Write(const std::string& filepath,
|
|
uint64_t offset,
|
|
void* buf,
|
|
uint64_t len) = 0;
|
|
|
|
/**
|
|
* @brief List files with same prefix
|
|
* @param filepath
|
|
* @return std::vector<std::string>
|
|
*/
|
|
virtual std::vector<std::string>
|
|
ListWithPrefix(const std::string& filepath) = 0;
|
|
|
|
/**
|
|
* @brief Remove specified file
|
|
* @param filepath
|
|
*/
|
|
virtual void
|
|
Remove(const std::string& filepath) = 0;
|
|
|
|
/**
|
|
* @brief Get the Name object
|
|
* Used for forming diagnosis messages
|
|
* @return std::string
|
|
*/
|
|
virtual std::string
|
|
GetName() const = 0;
|
|
|
|
/**
|
|
* @brief Get the Root Path
|
|
* @return std::string
|
|
*/
|
|
virtual std::string
|
|
GetRootPath() const = 0;
|
|
};
|
|
|
|
using ChunkManagerPtr = std::shared_ptr<ChunkManager>;
|
|
|
|
enum class ChunkManagerType : int8_t {
|
|
None = 0,
|
|
Local = 1,
|
|
Minio = 2,
|
|
Remote = 3,
|
|
OpenDAL = 4,
|
|
};
|
|
|
|
extern std::map<std::string, ChunkManagerType> ChunkManagerType_Map;
|
|
|
|
} // namespace milvus::storage
|