|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#pragma once |
| 21 | + |
| 22 | +/// \file iceberg/data/equality_delete_writer.h |
| 23 | +/// Equality delete writer for Iceberg tables. |
| 24 | + |
| 25 | +#include <cstdint> |
| 26 | +#include <memory> |
| 27 | +#include <optional> |
| 28 | +#include <string> |
| 29 | +#include <vector> |
| 30 | + |
| 31 | +#include "iceberg/arrow_c_data.h" |
| 32 | +#include "iceberg/data/writer.h" |
| 33 | +#include "iceberg/file_format.h" |
| 34 | +#include "iceberg/iceberg_export.h" |
| 35 | +#include "iceberg/result.h" |
| 36 | +#include "iceberg/row/partition_values.h" |
| 37 | +#include "iceberg/type_fwd.h" |
| 38 | + |
| 39 | +namespace iceberg { |
| 40 | + |
| 41 | +/// \brief Options for creating an EqualityDeleteWriter. |
| 42 | +/// |
| 43 | +/// \note The following features from Java EqualityDeleteWriter are not yet supported: |
| 44 | +/// - Encryption key metadata |
| 45 | +/// - Metrics collection and reporting |
| 46 | +/// - Split offsets tracking |
| 47 | +struct ICEBERG_EXPORT EqualityDeleteWriterOptions { |
| 48 | + std::string path; |
| 49 | + std::shared_ptr<Schema> schema; |
| 50 | + std::shared_ptr<PartitionSpec> spec; |
| 51 | + PartitionValues partition; |
| 52 | + FileFormatType format = FileFormatType::kParquet; |
| 53 | + std::shared_ptr<FileIO> io; |
| 54 | + std::vector<int32_t> equality_field_ids; |
| 55 | + std::optional<int32_t> sort_order_id; |
| 56 | + std::shared_ptr<class WriterProperties> properties; |
| 57 | +}; |
| 58 | + |
| 59 | +/// \brief Writer for Iceberg equality delete files. |
| 60 | +/// |
| 61 | +/// \warning Thread Safety: Writer instances are NOT thread-safe. Each writer should only |
| 62 | +/// be used by a single thread. Do not call Write(), Close(), or Metadata() concurrently. |
| 63 | +class ICEBERG_EXPORT EqualityDeleteWriter : public FileWriter { |
| 64 | + public: |
| 65 | + ~EqualityDeleteWriter() override; |
| 66 | + |
| 67 | + Status Write(ArrowArray* data) override; |
| 68 | + Result<int64_t> Length() const override; |
| 69 | + Status Close() override; |
| 70 | + Result<WriteResult> Metadata() override; |
| 71 | + |
| 72 | + const std::vector<int32_t>& equality_field_ids() const; |
| 73 | + |
| 74 | + private: |
| 75 | + friend class FileWriterFactory; |
| 76 | + friend std::unique_ptr<EqualityDeleteWriter> MakeEqualityDeleteWriterInternal( |
| 77 | + const EqualityDeleteWriterOptions&); |
| 78 | + class Impl; |
| 79 | + std::unique_ptr<Impl> impl_; |
| 80 | + explicit EqualityDeleteWriter(std::unique_ptr<Impl> impl); |
| 81 | +}; |
| 82 | + |
| 83 | +} // namespace iceberg |
0 commit comments