forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddEdgesProcessor.h
69 lines (52 loc) · 2.4 KB
/
AddEdgesProcessor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Copyright (c) 2018 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/
#ifndef STORAGE_MUTATE_ADDEDGESPROCESSOR_H_
#define STORAGE_MUTATE_ADDEDGESPROCESSOR_H_
#include "common/base/Base.h"
#include "common/stats/StatsManager.h"
#include "kvstore/LogEncoder.h"
#include "kvstore/raftex/RaftPart.h"
#include "storage/BaseProcessor.h"
#include "storage/StorageFlags.h"
namespace nebula {
namespace storage {
extern ProcessorCounters kAddEdgesCounters;
class AddEdgesProcessor : public BaseProcessor<cpp2::ExecResponse> {
friend class TransactionManager;
friend class ChainAddEdgesLocalProcessor;
public:
static AddEdgesProcessor* instance(StorageEnv* env,
const ProcessorCounters* counters = &kAddEdgesCounters) {
return new AddEdgesProcessor(env, counters);
}
void process(const cpp2::AddEdgesRequest& req);
void doProcess(const cpp2::AddEdgesRequest& req);
void doProcessWithIndex(const cpp2::AddEdgesRequest& req);
private:
AddEdgesProcessor(StorageEnv* env, const ProcessorCounters* counters)
: BaseProcessor<cpp2::ExecResponse>(env, counters) {}
kvstore::MergeableAtomicOpResult addEdgesWithIndex(PartitionID partId,
std::vector<kvstore::KV>&& data);
ErrorOr<nebula::cpp2::ErrorCode, std::string> findOldValue(PartitionID partId,
const folly::StringPiece& rawKey);
std::vector<std::string> indexKeys(PartitionID partId,
RowReaderWrapper* reader,
const folly::StringPiece& rawKey,
std::shared_ptr<nebula::meta::cpp2::IndexItem> index,
const meta::NebulaSchemaProvider* latestSchema);
nebula::cpp2::ErrorCode deleteDupEdge(std::vector<cpp2::NewEdge>& edges);
private:
GraphSpaceID spaceId_;
std::vector<std::shared_ptr<nebula::meta::cpp2::IndexItem>> indexes_;
bool ifNotExists_{false};
bool ignoreExistedIndex_{false};
meta::EdgeSchema edgeSchema_;
/// this is a hook function to keep out-edge and in-edge consist
using ConsistOper = std::function<void(kvstore::BatchHolder&, std::vector<kvstore::KV>*)>;
std::optional<ConsistOper> consistOp_;
};
} // namespace storage
} // namespace nebula
#endif // STORAGE_MUTATE_ADDEDGESPROCESSOR_H_