| /* | |
| * 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/position_delete_writer.h | |
| /// Position delete writer for Iceberg tables. | |
| #include <cstdint> | |
| #include <memory> | |
| #include <string> | |
| #include <string_view> | |
| #include <unordered_map> | |
| #include "iceberg/arrow_c_data.h" | |
| #include "iceberg/data/writer.h" | |
| #include "iceberg/file_format.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 Options for creating a PositionDeleteWriter. | |
| struct ICEBERG_DATA_EXPORT PositionDeleteWriterOptions { | |
| std::string path; | |
| std::shared_ptr<Schema> schema; | |
| std::shared_ptr<PartitionSpec> spec; | |
| PartitionValues partition; | |
| FileFormatType format = FileFormatType::kParquet; | |
| std::shared_ptr<FileIO> io; | |
| int64_t flush_threshold = 1000; // Number of buffered deletes before auto-flush | |
| std::unordered_map<std::string, std::string> properties; | |
| }; | |
| /// \brief Writer for Iceberg position delete files. | |
| class ICEBERG_DATA_EXPORT PositionDeleteWriter : public FileWriter { | |
| public: | |
| ~PositionDeleteWriter() override; | |
| /// \brief Create a new PositionDeleteWriter instance. | |
| static Result<std::unique_ptr<PositionDeleteWriter>> Make( | |
| const PositionDeleteWriterOptions& options); | |
| Status Write(ArrowArray* data) override; | |
| Status WriteDelete(std::string_view file_path, int64_t pos); | |
| Result<int64_t> Length() const override; | |
| Status Close() override; | |
| Result<WriteResult> Metadata() override; | |
| private: | |
| class Impl; | |
| std::unique_ptr<Impl> impl_; | |
| explicit PositionDeleteWriter(std::unique_ptr<Impl> impl); | |
| }; | |
| } // namespace iceberg |