wgtmac commented on code in PR #777: URL: https://github.com/apache/iceberg-cpp/pull/777#discussion_r3503976406
########## src/iceberg/data/deletion_vector_writer.h: ########## @@ -0,0 +1,114 @@ +/* + * 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 + +/// \file iceberg/data/deletion_vector_writer.h +/// Writer that emits deletion vectors as `deletion-vector-v1` blobs in a Puffin file. + +#include <cstdint> +#include <functional> +#include <memory> +#include <string> +#include <string_view> +#include <unordered_map> +#include <vector> + +#include "iceberg/deletes/position_delete_index.h" +#include "iceberg/iceberg_data_export.h" +#include "iceberg/result.h" +#include "iceberg/row/partition_values.h" +#include "iceberg/type_fwd.h" + +namespace iceberg { + +/// \brief The result of writing deletion vectors. +struct ICEBERG_DATA_EXPORT DeleteWriteResult { + /// Deletion vector files produced, one per referenced data file. + std::vector<std::shared_ptr<DataFile>> delete_files; + /// Data files referenced by the produced deletion vectors. + std::vector<std::string> referenced_data_files; + /// Previously written, file-scoped delete files that were merged and should be + /// removed from table state. + std::vector<std::shared_ptr<DataFile>> rewritten_delete_files; +}; + +/// \brief Previously written deletes for a data file, used to merge before +/// writing a new deletion vector. +struct ICEBERG_DATA_EXPORT PreviousDeletes { + /// The previously deleted positions, or null if none. + std::shared_ptr<PositionDeleteIndex> index; + /// The delete files the positions came from; file-scoped ones are reported as + /// rewritten. + std::vector<std::shared_ptr<DataFile>> delete_files; +}; + +/// \brief Options for creating a DeletionVectorWriter. +struct ICEBERG_DATA_EXPORT DeletionVectorWriterOptions { + /// Output Puffin file location. + std::string path; + /// FileIO used to create the Puffin file. + std::shared_ptr<FileIO> io; + /// File-level Puffin properties (e.g. "created-by"). + std::unordered_map<std::string, std::string> properties; + /// Optional hook to load previously written deletes for a data file so they + /// can be merged into the new deletion vector, with the old delete files + /// reported as rewritten. + std::function<Result<PreviousDeletes>(std::string_view)> load_previous_deletes; Review Comment: Please make this loader explicit instead of optional. Java BaseDVFileWriter always receives loadPreviousDeletes, even when it returns null. A default no-merge path makes it easy to write a DV that does not replace existing deletes. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
