// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include #include #include #include #include #include #include namespace DB { class TiDBColumn { public: explicit TiDBColumn(Int8 element_len); void appendNull(); void append(Int64 value); void append(UInt64 value); void append(const StringRef & value); void append(Float64 value); void append(Float32 value); //void appendDuration(); void append(const TiDBTime & time); //void appendJson(); void append(const TiDBDecimal & decimal); void append(const TiDBBit & bit); void append(const TiDBEnum & ti_enum); void appendVectorF32(UInt32 num_elem, StringRef elem_bytes); void encodeColumn(WriteBuffer & ss); void clear(); private: bool isFixed() const { return fixed_size != VAR_SIZE; } void finishAppendFixed(); void finishAppendVar(UInt32 size); void appendNullBitMap(bool value); // WriteBufferFromOwnString is not moveable. std::unique_ptr data; UInt32 length; UInt32 null_cnt; std::vector null_bitmap; std::vector var_offsets; std::string default_value; UInt64 current_data_size; Int8 fixed_size; }; } // namespace DB