Context.h 2.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 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 <iostream>
15
#include <map>
16 17
#include <string>
#include <vector>
18
#include "db/meta/MetaTypes.h"
19
#include "db/snapshot/Resources.h"
20
#include "db/snapshot/Snapshot.h"
21 22 23 24 25

namespace milvus {
namespace engine {
namespace snapshot {

26 27 28
struct PartitionContext {
    std::string name;
    ID_TYPE id = 0;
X
XuPeng-SH 已提交
29 30 31 32
    LSN_TYPE lsn = 0;

    std::string
    ToString() const;
33 34
};

35 36 37 38 39
struct SegmentFileContext {
    std::string field_name;
    std::string field_element_name;
    ID_TYPE segment_id;
    ID_TYPE partition_id;
C
Cai Yudong 已提交
40
    ID_TYPE collection_id;
41 42 43 44
};

struct LoadOperationContext {
    ID_TYPE id = 0;
C
Cai Yudong 已提交
45
    State state = INVALID;
46 47 48 49
    std::string name;
};

struct OperationContext {
50 51 52 53 54
    explicit OperationContext(const ScopedSnapshotT& ss = ScopedSnapshotT()) : prev_ss(ss) {
    }

    ScopedSnapshotT latest_ss;
    ScopedSnapshotT prev_ss;
55 56
    SegmentPtr new_segment = nullptr;
    SegmentCommitPtr new_segment_commit = nullptr;
57
    PartitionPtr new_partition = nullptr;
58 59
    PartitionCommitPtr new_partition_commit = nullptr;
    SchemaCommitPtr new_schema_commit = nullptr;
X
XuPeng-SH 已提交
60 61
    CollectionCommitPtr new_collection_commit = nullptr;
    CollectionPtr new_collection = nullptr;
62 63 64 65 66 67 68 69 70 71 72 73

    SegmentFilePtr stale_segment_file = nullptr;
    std::vector<SegmentPtr> stale_segments;

    FieldPtr prev_field = nullptr;
    FieldElementPtr prev_field_element = nullptr;

    SegmentPtr prev_segment = nullptr;
    SegmentCommitPtr prev_segment_commit = nullptr;
    PartitionPtr prev_partition = nullptr;
    PartitionCommitPtr prev_partition_commit = nullptr;
    CollectionCommitPtr prev_collection_commit = nullptr;
74
    PartitionCommitPtr stale_partition_commit = nullptr;
75 76

    SegmentFile::VecT new_segment_files;
77
    CollectionPtr collection = nullptr;
X
XuPeng-SH 已提交
78 79 80 81
    LSN_TYPE lsn = 0;

    std::string
    ToString() const;
82 83 84 85 86 87
};

struct CreateCollectionContext {
    CollectionPtr collection = nullptr;
    std::map<FieldPtr, std::vector<FieldElementPtr>> fields_schema;
    CollectionCommitPtr collection_commit = nullptr;
X
XuPeng-SH 已提交
88 89 90 91
    LSN_TYPE lsn = 0;

    std::string
    ToString() const;
92 93 94 95 96
};

}  // namespace snapshot
}  // namespace engine
}  // namespace milvus