/Users/deen/code/yugabyte-db/src/yb/yql/pggate/util/pg_tuple.h
Line | Count | Source |
1 | | //-------------------------------------------------------------------------------------------------- |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | //-------------------------------------------------------------------------------------------------- |
14 | | |
15 | | #ifndef YB_YQL_PGGATE_UTIL_PG_TUPLE_H_ |
16 | | #define YB_YQL_PGGATE_UTIL_PG_TUPLE_H_ |
17 | | |
18 | | #include "yb/yql/pggate/util/pg_wire.h" |
19 | | #include "yb/yql/pggate/ybc_pg_typedefs.h" |
20 | | |
21 | | namespace yb { |
22 | | namespace pggate { |
23 | | |
24 | | // PgTuple. |
25 | | // TODO(neil) This code needs to be optimize. We might be able to use DocDB buffer directly for |
26 | | // most datatype except numeric. A simpler optimization would be allocate one buffer for each |
27 | | // tuple and write the value there. |
28 | | // |
29 | | // Currently we allocate one individual buffer per column and write result there. |
30 | | class PgTuple { |
31 | | public: |
32 | | PgTuple(uint64_t *datums, bool *isnulls, PgSysColumns *syscols); |
33 | | |
34 | | // Write null value. |
35 | | void WriteNull(int index, const PgWireDataHeader& header); |
36 | | |
37 | | // Write datum to tuple slot. |
38 | | void WriteDatum(int index, uint64_t datum); |
39 | | |
40 | | // Write data in Postgres format. |
41 | | void Write(uint8_t **pgbuf, const PgWireDataHeader& header, const uint8_t *value, int64_t bytes); |
42 | | |
43 | | // Get returning-space for system columns. Tuple writer will save values in this struct. |
44 | 18.7M | PgSysColumns *syscols() { |
45 | 18.7M | return syscols_; |
46 | 18.7M | } |
47 | | |
48 | | private: |
49 | | uint64_t *datums_; |
50 | | bool *isnulls_; |
51 | | PgSysColumns *syscols_; |
52 | | }; |
53 | | |
54 | | } // namespace pggate |
55 | | } // namespace yb |
56 | | |
57 | | #endif // YB_YQL_PGGATE_UTIL_PG_TUPLE_H_ |