iceberg-cpp
Loading...
Searching...
No Matches
dv_writer.h
Go to the documentation of this file.
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
24
25#include <cstdint>
26#include <functional>
27#include <memory>
28#include <optional>
29#include <string>
30#include <string_view>
31#include <vector>
32
35#include "iceberg/result.h"
37#include "iceberg/type_fwd.h"
38
39namespace iceberg {
40
42struct ICEBERG_EXPORT DeleteWriteResult {
44 std::vector<std::shared_ptr<DataFile>> data_files;
46 std::vector<std::string> referenced_data_files;
48 std::vector<std::shared_ptr<DataFile>> rewritten_delete_files;
49};
50
52struct ICEBERG_EXPORT DVWriterOptions {
53 std::string path;
54 std::shared_ptr<FileIO> io;
56 std::function<Result<std::optional<PositionDeleteIndex>>(std::string_view)>
57 load_previous_deletes;
58};
59
61class ICEBERG_EXPORT DVWriter {
62 public:
63 ~DVWriter();
64
67
69 Status Delete(std::string_view referenced_data_file, int64_t pos,
70 const std::shared_ptr<PartitionSpec>& spec,
71 const PartitionValues& partition);
72
74 Status Delete(std::string_view referenced_data_file,
75 const PositionDeleteIndex& positions,
76 const std::shared_ptr<PartitionSpec>& spec,
77 const PartitionValues& partition);
78
80 Status Close();
81
84
85 private:
86 class Impl;
87 std::unique_ptr<Impl> impl_;
88
89 explicit DVWriter(std::unique_ptr<Impl> impl);
90};
91
92} // namespace iceberg
A deletion vector file writer.
Definition dv_writer.h:61
Result< DeleteWriteResult > Metadata()
The result of writing; valid only after Close().
Status Delete(std::string_view referenced_data_file, const PositionDeleteIndex &positions, const std::shared_ptr< PartitionSpec > &spec, const PartitionValues &partition)
Mark all positions in the given index as deleted for a data file.
static Result< std::unique_ptr< DVWriter > > Make(DVWriterOptions options)
Create a new DVWriter.
Status Close()
Write all accumulated deletion vectors to the Puffin file and close.
Status Delete(std::string_view referenced_data_file, int64_t pos, const std::shared_ptr< PartitionSpec > &spec, const PartitionValues &partition)
Mark a row position as deleted for the given data file.
StructLike wrapper for a vector of literals that represent partition values.
Definition partition_values.h:36
Tracks deleted row positions using a bitmap.
Definition position_delete_index.h:42
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.
Options for creating a DVWriter.
Definition dv_writer.h:52
File metadata for deletion vectors produced by DVWriter.
Definition dv_writer.h:42
std::vector< std::string > referenced_data_files
Data files referenced by the produced deletion vectors.
Definition dv_writer.h:46
std::vector< std::shared_ptr< DataFile > > rewritten_delete_files
Previously written file-scoped delete files merged into the new vectors.
Definition dv_writer.h:48
std::vector< std::shared_ptr< DataFile > > data_files
Deletion vector files produced by the writer.
Definition dv_writer.h:44