SegmentGrowing.h 2.3 KB
Newer Older
F
FluorineDog 已提交
1 2 3 4 5 6 7 8 9 10 11
// 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

12 13 14
#pragma once
#include <vector>

N
neza2017 已提交
15
#include "common/Types.h"
16
#include "common/Schema.h"
F
FluorineDog 已提交
17
#include <memory>
18

19
#include "query/deprecated/GeneralQuery.h"
20
#include "query/Plan.h"
21
#include "common/LoadInfo.h"
22
#include "segcore/SegmentInterface.h"
23 24

namespace milvus {
G
GuoRentong 已提交
25
namespace segcore {
26
using SearchResult = milvus::SearchResult;
27 28 29 30 31
struct RowBasedRawData {
    void* raw_data;      // schema
    int sizeof_per_row;  // alignment
    int64_t count;
};
32

33 34 35 36 37
struct ColumnBasedRawData {
    std::vector<aligned_vector<uint8_t>> columns_;
    int64_t count;
};

38 39
int
TestABI();
40

41
class SegmentGrowing : public SegmentInternalInterface {
42
 public:
43 44 45
    virtual void
    debug_disable_small_index() = 0;

46 47
    virtual int64_t
    PreInsert(int64_t size) = 0;
48

49
    virtual Status
50 51
    Insert(int64_t reserved_offset,
           int64_t size,
G
GuoRentong 已提交
52
           const int64_t* row_ids,
53
           const Timestamp* timestamps,
G
GuoRentong 已提交
54
           const RowBasedRawData& values) = 0;
55

56 57 58 59 60 61 62
    virtual void
    Insert(int64_t reserved_offset,
           int64_t size,
           const int64_t* row_ids,
           const Timestamp* timestamps,
           const ColumnBasedRawData& values) = 0;

63 64
    virtual int64_t
    PreDelete(int64_t size) = 0;
65

66
    virtual Status
G
GuoRentong 已提交
67
    Delete(int64_t reserved_offset, int64_t size, const int64_t* row_ids, const Timestamp* timestamps) = 0;
68 69 70 71 72 73

 public:
    virtual ssize_t
    get_deleted_count() const = 0;
};

X
XuanYang-cn 已提交
74
using SegmentGrowingPtr = std::unique_ptr<SegmentGrowing>;
75

X
XuanYang-cn 已提交
76
SegmentGrowingPtr
F
FluorineDog 已提交
77 78 79 80 81 82 83
CreateGrowingSegment(SchemaPtr schema, const SegcoreConfig& segcore_config);

inline SegmentGrowingPtr
CreateGrowingSegment(SchemaPtr schema) {
    auto seg_conf = SegcoreConfig::default_config();
    return CreateGrowingSegment(schema, seg_conf);
}
84

G
GuoRentong 已提交
85
}  // namespace segcore
86
}  // namespace milvus