wgtmac commented on code in PR #14803: URL: https://github.com/apache/arrow/pull/14803#discussion_r1040532918
########## cpp/src/parquet/page_index.h: ########## @@ -0,0 +1,119 @@ +// 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 "parquet/exception.h" +#include "parquet/platform.h" +#include "parquet/schema.h" + +#include <vector> + +namespace parquet { + +/// \brief BoundaryOrder is a proxy around format::BoundaryOrder. +enum class PARQUET_EXPORT BoundaryOrder { Unordered = 0, Ascending = 1, Descending = 2 }; + +/// \brief ColumnIndex is a proxy around format::ColumnIndex. +class PARQUET_EXPORT ColumnIndex { + public: + /// \brief Create a ColumnIndex from a serialized thrift message. + static std::unique_ptr<ColumnIndex> Make(const ColumnDescriptor& descr, + const void* serialized_index, + uint32_t index_len, + const ReaderProperties& properties); + + virtual ~ColumnIndex() = default; + + /// \brief Returns a list of boolean values to determine the validity of the + /// corresponding min and max values. + virtual const std::vector<bool>& null_pages() const = 0; + + /// \brief Returns a list of encoded lower bound for the values of each page. For null + /// pages the default value is an empty string. Readers must make sure that list entries + /// are populated before using them by inspecting null_pages. + virtual const std::vector<std::string>& encoded_min_values() const = 0; + + /// \brief Returns a list of encoded upper bound for the values of each page. For null + /// pages the default value is an empty string. Readers must make sure that list entries + /// are populated before using them by inspecting null_pages. + virtual const std::vector<std::string>& encoded_max_values() const = 0; + + /// \brief Returns whether both min_values and max_values are orderd and if so, in which + /// direction. + virtual BoundaryOrder boundary_order() const = 0; + + /// \brief Returns if null count is available. + virtual bool has_null_counts() const = 0; + + /// \brief Returns A list containing the number of null values for each page. + virtual const std::vector<int64_t>& null_counts() const = 0; +}; + +/// \brief Typed implementation of ColumnIndex. +template <typename DType> +class PARQUET_EXPORT TypedColumnIndex : public ColumnIndex { + public: + using T = typename DType::c_type; + + /// \brief Returns a list of lower bound for the values of every non-null page. + /// Excluding non-null pages helps binary search if the values are ordered. + virtual const std::vector<T>& min_values() const = 0; + + /// \brief Returns a list of upper bound for the values of every non-null page. + /// Excluding non-null pages helps binary search if the values are ordered. + virtual const std::vector<T>& max_values() const = 0; + + /// \brief Returns a list of page indices for not-null pages. It is helpful to + /// understand the original page id in the values returned from min_values() + /// and max_values() above. Review Comment: Users cannot simply get decoded min/max values from a generic ColumnIndex. `class Statistics` also have the same issue and thus `class TypedStatistics` is provided to save users from the boilerplate code of decoding min/max values. -- 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]
