/Users/deen/code/yugabyte-db/src/yb/docdb/ql_storage_interface.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_DOCDB_QL_STORAGE_INTERFACE_H |
15 | | #define YB_DOCDB_QL_STORAGE_INTERFACE_H |
16 | | |
17 | | #include <limits> |
18 | | #include <string> |
19 | | #include <type_traits> |
20 | | |
21 | | #include "yb/common/common_fwd.h" |
22 | | |
23 | | #include "yb/docdb/docdb_fwd.h" |
24 | | #include "yb/docdb/ql_rowwise_iterator_interface.h" |
25 | | |
26 | | #include "yb/util/monotime.h" |
27 | | |
28 | | namespace yb { |
29 | | namespace docdb { |
30 | | |
31 | | // An interface to support various different storage backends for a QL table. |
32 | | class YQLStorageIf { |
33 | | public: |
34 | | typedef std::unique_ptr<YQLStorageIf> UniPtr; |
35 | | typedef std::shared_ptr<YQLStorageIf> SharedPtr; |
36 | | |
37 | 209k | virtual ~YQLStorageIf() {} |
38 | | |
39 | | //------------------------------------------------------------------------------------------------ |
40 | | // CQL Support. |
41 | | virtual CHECKED_STATUS GetIterator(const QLReadRequestPB& request, |
42 | | const Schema& projection, |
43 | | const Schema& schema, |
44 | | const TransactionOperationContext& txn_op_context, |
45 | | CoarseTimePoint deadline, |
46 | | const ReadHybridTime& read_time, |
47 | | const QLScanSpec& spec, |
48 | | std::unique_ptr<YQLRowwiseIteratorIf>* iter) const = 0; |
49 | | |
50 | | virtual CHECKED_STATUS BuildYQLScanSpec( |
51 | | const QLReadRequestPB& request, |
52 | | const ReadHybridTime& read_time, |
53 | | const Schema& schema, |
54 | | bool include_static_columns, |
55 | | const Schema& static_projection, |
56 | | std::unique_ptr<QLScanSpec>* spec, |
57 | | std::unique_ptr<QLScanSpec>* static_row_spec) const = 0; |
58 | | |
59 | | //------------------------------------------------------------------------------------------------ |
60 | | // PGSQL Support. |
61 | | |
62 | | // TODO(neil) Need to replace GetIterator(ybctid) with CreateIterator and InitIterator. |
63 | | // I leave Create and Init code here, so I don't have to rewrite them in the near future. |
64 | | // |
65 | | // - Replacement is not done yet because reusing iterator is not yet allowed. When reusing it, |
66 | | // doc_key.get_next() asserts that an infinite loop is detected even though we're calling |
67 | | // get_next() for a different hash codes. |
68 | | // - Create and init can be used to create iterator once and initialize with different ybctid for |
69 | | // different execution. |
70 | | // - Doc_key needs to be changed to allow reusing iterator. |
71 | | virtual CHECKED_STATUS CreateIterator(const Schema& projection, |
72 | | const Schema& schema, |
73 | | const TransactionOperationContext& txn_op_context, |
74 | | CoarseTimePoint deadline, |
75 | | const ReadHybridTime& read_time, |
76 | | std::unique_ptr<YQLRowwiseIteratorIf>* iter) const = 0; |
77 | | |
78 | | virtual CHECKED_STATUS InitIterator(docdb::YQLRowwiseIteratorIf* doc_iter, |
79 | | const PgsqlReadRequestPB& request, |
80 | | const Schema& schema, |
81 | | const QLValuePB& ybctid) const = 0; |
82 | | |
83 | | // Create iterator for querying by partition and range key. |
84 | | virtual CHECKED_STATUS GetIterator(const PgsqlReadRequestPB& request, |
85 | | const Schema& projection, |
86 | | const Schema& schema, |
87 | | const TransactionOperationContext& txn_op_context, |
88 | | CoarseTimePoint deadline, |
89 | | const ReadHybridTime& read_time, |
90 | | const docdb::DocKey& start_doc_key, |
91 | | std::unique_ptr<YQLRowwiseIteratorIf>* iter) const = 0; |
92 | | |
93 | | // Create iterator for querying by ybctid. |
94 | | virtual CHECKED_STATUS GetIterator(uint64 stmt_id, |
95 | | const Schema& projection, |
96 | | const Schema& schema, |
97 | | const TransactionOperationContext& txn_op_context, |
98 | | CoarseTimePoint deadline, |
99 | | const ReadHybridTime& read_time, |
100 | | const QLValuePB& ybctid, |
101 | | std::unique_ptr<YQLRowwiseIteratorIf>* iter) const = 0; |
102 | | }; |
103 | | |
104 | | } // namespace docdb |
105 | | } // namespace yb |
106 | | |
107 | | #endif // YB_DOCDB_QL_STORAGE_INTERFACE_H |