emkornfield commented on code in PR #50252: URL: https://github.com/apache/arrow/pull/50252#discussion_r3841240387
########## cpp/src/parquet/variant/builder.h: ########## @@ -0,0 +1,331 @@ +// 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 <cstdint> +#include <memory> +#include <string_view> +#include <vector> + +#include "arrow/buffer.h" +#include "arrow/extension/parquet_variant.h" +#include "arrow/memory_pool.h" +#include "arrow/type_fwd.h" +#include "parquet/platform.h" + +namespace parquet::variant { + +using ::arrow::Array; +using ::arrow::BinaryViewArray; +using ::arrow::Buffer; +using ::arrow::DataType; +using ::arrow::MemoryPool; +using ::arrow::StructArray; +using ::arrow::extension::VariantArray; + +class VariantMetadataView; +class VariantObjectBuilder; +class VariantListBuilder; +class VariantValueRowBuilder; + +struct PARQUET_EXPORT EncodedVariantValue { + std::shared_ptr<Buffer> metadata; + std::shared_ptr<Buffer> value; +}; + +class PARQUET_EXPORT VariantBuilder { + public: + explicit VariantBuilder(MemoryPool* pool = ::arrow::default_memory_pool(), + bool validate = true); + ~VariantBuilder(); + VariantBuilder(const VariantBuilder&) = delete; + VariantBuilder& operator=(const VariantBuilder&) = delete; + VariantBuilder(VariantBuilder&&) noexcept; + VariantBuilder& operator=(VariantBuilder&&) noexcept; + + void ReserveFieldNames(int64_t capacity); + uint32_t AddFieldName(std::string_view name); + + void AppendVariantNull(); Review Comment: given the contracts here, would it make more sense to possibly separate this builder into two parts: 1. One part that handles collecting the "metadata component" used by other builders for adding names to the dictionary. 2. static factor methods for each of the type (which would leave no dictionary). Struct/Array/Primitive 3. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
