Repository navigation
Expand file tree
/
Copy pathentity_graph_decoder.cpp
More file actions
119 lines (111 loc) · 5.53 KB
/
Copy pathentity_graph_decoder.cpp
File metadata and controls
119 lines (111 loc) · 5.53 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <teaql/runtime/entity_graph_decoder.hpp>
namespace teaql {
namespace {
EntityGraphDecodeResult missing(Memory r, std::string_view entity, std::string_view mode) {
String message("entity has no compact identity graph ", r);
message += mode;
message += "decoder in RuntimeModule";
return EntityGraphDecodeResult::err(
r, EntityError(std::allocator_arg, Allocator(r), entity, message));
}
}
Result<bool, EntityError>
InMemoryEntityGraphDecoderRegistry::json_capability(const EntityDescriptor& descriptor) const {
auto r = memory_resource();
auto found = json_.find(descriptor.name);
if (found == json_.end()) {
return Result<bool, EntityError>::err(
r,
EntityError(std::allocator_arg,
Allocator(r),
descriptor.name,
"JSON_ENTITY_INPUT: graph type has no installed typed decoder"));
}
return found->second.capability(r, descriptor);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_json_edge(std::string_view entity,
JsonRows rows,
const EntityRuntimeState& root,
EntityGraphBuilder& graph,
JsonEdgeRequest edge) const {
auto found = json_.find(entity);
if (found == json_.end()) {
auto r = graph.memory_resource();
return EntityGraphDecodeResult::err(
r,
EntityError(std::allocator_arg,
Allocator(r),
entity,
"JSON_ENTITY_INPUT: graph type has no installed typed decoder"));
}
validate_domain(root, graph);
return found->second.edge(std::move(rows), root, graph, edge);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_compact(std::string_view entity,
CompactRow row,
const EntityRuntimeState& root,
EntityGraphBuilder& graph) const {
auto found = compact_.find(entity);
if (found == compact_.end()) {
return missing(graph.memory_resource(), entity, "");
}
validate_domain(root, graph);
return found->second(std::move(row), root, graph);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_compact_batch(std::string_view entity,
Vector<CompactRow> rows,
const EntityRuntimeState& root,
EntityGraphBuilder& graph) const {
auto found = batch_.find(entity);
if (found == batch_.end()) {
return missing(graph.memory_resource(), entity, "batch ");
}
validate_domain(root, graph);
return found->second(std::move(rows), root, graph);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_compact_list(std::string_view entity,
Vector<CompactRow> rows,
const EntityRuntimeState& root,
EntityGraphBuilder& graph,
std::string_view owner,
std::uint64_t id,
std::string_view relation) const {
SmartList<CompactRow> list(
std::allocator_arg, Allocator(graph.memory_resource()), std::move(rows));
return decode_compact_smart_list(entity, std::move(list), root, graph, owner, id, relation);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_compact_smart_list(std::string_view entity,
SmartList<CompactRow> rows,
const EntityRuntimeState& root,
EntityGraphBuilder& graph,
std::string_view owner,
std::uint64_t id,
std::string_view relation) const {
auto found = list_.find(entity);
if (found == list_.end()) {
return missing(graph.memory_resource(), entity, "list ");
}
validate_domain(root, graph);
return found->second(std::move(rows), root, graph, owner, id, relation);
}
EntityGraphDecodeResult
InMemoryEntityGraphDecoderRegistry::decode_compact_option(std::string_view entity,
Vector<CompactRow> rows,
const EntityRuntimeState& root,
EntityGraphBuilder& graph,
std::string_view owner,
std::uint64_t id,
std::string_view relation) const {
auto found = option_.find(entity);
if (found == option_.end()) {
return missing(graph.memory_resource(), entity, "option ");
}
validate_domain(root, graph);
return found->second(std::move(rows), root, graph, owner, id, relation);
}
}