forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResultSchemaProvider.h
65 lines (47 loc) · 1.92 KB
/
ResultSchemaProvider.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
/* Copyright (c) 2018 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License,
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/
#ifndef DATAMAN_RESULTSCHEMAPROVIDER_H_
#define DATAMAN_RESULTSCHEMAPROVIDER_H_
#include "base/Base.h"
#include "meta/SchemaProviderIf.h"
namespace nebula {
class ResultSchemaProvider : public meta::SchemaProviderIf {
using ColumnDefs = std::vector<cpp2::ColumnDef>;
public:
class ResultSchemaField : public meta::SchemaProviderIf::Field {
public:
explicit ResultSchemaField(
const cpp2::ColumnDef* col = nullptr);
const char* getName() const override;
const cpp2::ValueType& getType() const override;
bool isValid() const override;
private:
const cpp2::ColumnDef* column_;
};
public:
explicit ResultSchemaProvider(cpp2::Schema);
virtual ~ResultSchemaProvider() = default;
SchemaVer getVersion() const noexcept override {
return schemaVer_;
}
size_t getNumFields() const noexcept override;
int64_t getFieldIndex(const folly::StringPiece name) const override;
const char* getFieldName(int64_t index) const override;
const cpp2::ValueType& getFieldType(int64_t index) const override;
const cpp2::ValueType& getFieldType(const folly::StringPiece name) const override;
std::shared_ptr<const meta::SchemaProviderIf::Field> field(int64_t index) const override;
std::shared_ptr<const meta::SchemaProviderIf::Field> field(
const folly::StringPiece name) const override;
protected:
SchemaVer schemaVer_{0};
ColumnDefs columns_;
// Map of Hash64(field_name) -> array index
UnorderedMap<uint64_t, int64_t> nameIndex_;
// Default constructor, only used by SchemaWriter
explicit ResultSchemaProvider(SchemaVer ver = 0) : schemaVer_(ver) {}
};
} // namespace nebula
#endif // DATAMAN_RESULTSCHEMAPROVIDER_H_