// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you 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 "runtime/descriptors.h" #include "vec/columns/column_nullable.h" #include "vec/core/block.h" namespace doris::vectorized { class VectorizedUtils { public: static Block create_empty_columnswithtypename(const RowDescriptor& row_desc) { // Block block; return create_columns_with_type_and_name(row_desc); } static ColumnsWithTypeAndName create_columns_with_type_and_name(const RowDescriptor& row_desc) { ColumnsWithTypeAndName columns_with_type_and_name; for (const auto& tuple_desc : row_desc.tuple_descriptors()) { for (const auto& slot_desc : tuple_desc->slots()) { columns_with_type_and_name.emplace_back(nullptr, slot_desc->get_data_type_ptr(), slot_desc->col_name()); } } return columns_with_type_and_name; } static void update_null_map(NullMap& dst, const NullMap& src) { size_t size = dst.size(); auto* __restrict l = dst.data(); auto* __restrict r = src.data(); for (size_t i = 0; i < size; ++i) l[i] |= r[i]; } static DataTypes get_data_types(const RowDescriptor& row_desc) { DataTypes data_types; for (const auto& tuple_desc : row_desc.tuple_descriptors()) { for (const auto& slot_desc : tuple_desc->slots()) { data_types.push_back(slot_desc->get_data_type_ptr()); } } return data_types; } }; } // namespace doris::vectorized namespace apache::thrift { template ThriftStruct from_json_string(const std::string& json_val) { using namespace apache::thrift::transport; using namespace apache::thrift::protocol; ThriftStruct ts; TMemoryBuffer* buffer = new TMemoryBuffer((uint8_t*)json_val.c_str(), (uint32_t)json_val.size()); std::shared_ptr trans(buffer); TJSONProtocol protocol(trans); ts.read(&protocol); return ts; } } // namespace apache::thrift