milvus/core/src/db/insert/VectorSource.h
Jin Hai 8c7ef47f20
Fix duplicate vector ID issue (#1508)
* #1499 Fix duplicated ID number issue

Signed-off-by: jinhai <hai.jin@zilliz.com>

* #1499 Fix duplicated ID number issue - part 1

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* #1499 Fix duplicated ID number issue - part 2

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* #1499 Fix duplicated ID number issue - part 3

Signed-off-by: jinhai <hai.jin@zilliz.com>

* #1499 Fix duplicated ID number issue - part 4

Signed-off-by: jinhai <hai.jin@zilliz.com>

* Fix format issue

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Update CHANGELOG

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>

* Add return value check

Signed-off-by: JinHai-CN <hai.jin@zilliz.com>
2020-03-05 12:38:22 +08:00

58 lines
1.6 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 <memory>
#include "db/IDGenerator.h"
#include "db/engine/ExecutionEngine.h"
#include "db/meta/Meta.h"
#include "segment/SegmentWriter.h"
#include "utils/Status.h"
namespace milvus {
namespace engine {
// TODO(zhiru): this class needs to be refactored once attributes are added
class VectorSource {
public:
explicit VectorSource(VectorsData vectors);
Status
Add(/*const ExecutionEnginePtr& execution_engine,*/ const segment::SegmentWriterPtr& segment_writer_ptr,
const meta::TableFileSchema& table_file_schema, const size_t& num_vectors_to_add, size_t& num_vectors_added);
size_t
GetNumVectorsAdded();
size_t
SingleVectorSize(uint16_t dimension);
bool
AllAdded();
IDNumbers
GetVectorIds();
private:
VectorsData vectors_;
IDNumbers vector_ids_;
size_t current_num_vectors_added;
}; // VectorSource
using VectorSourcePtr = std::shared_ptr<VectorSource>;
} // namespace engine
} // namespace milvus