|
| 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/puffin/blob.h |
| 23 | +/// Blob data structure for Puffin files. |
| 24 | + |
| 25 | +#include <cstdint> |
| 26 | +#include <optional> |
| 27 | +#include <string> |
| 28 | +#include <unordered_map> |
| 29 | +#include <vector> |
| 30 | + |
| 31 | +#include "iceberg/iceberg_export.h" |
| 32 | +#include "iceberg/puffin/puffin_compression_codec.h" |
| 33 | + |
| 34 | +namespace iceberg::puffin { |
| 35 | + |
| 36 | +/// \brief A blob to be written to a Puffin file. |
| 37 | +/// |
| 38 | +/// This represents the uncompressed blob data along with its metadata. |
| 39 | +/// The actual compression is handled during writing. |
| 40 | +struct ICEBERG_EXPORT Blob { |
| 41 | + /// Type of the blob. See StandardBlobTypes for known types. |
| 42 | + std::string type; |
| 43 | + /// List of field IDs the blob was computed for. |
| 44 | + /// The order of items is used to compute sketches stored in the blob. |
| 45 | + std::vector<int32_t> input_fields; |
| 46 | + /// ID of the Iceberg table's snapshot the blob was computed from. |
| 47 | + int64_t snapshot_id; |
| 48 | + /// Sequence number of the Iceberg table's snapshot the blob was computed from. |
| 49 | + int64_t sequence_number; |
| 50 | + /// The uncompressed blob data. |
| 51 | + std::vector<uint8_t> data; |
| 52 | + /// Requested compression codec. If not set, the writer's default will be used. |
| 53 | + std::optional<PuffinCompressionCodec> requested_compression; |
| 54 | + /// Additional properties of the blob. |
| 55 | + std::unordered_map<std::string, std::string> properties; |
| 56 | + |
| 57 | + /// \brief Compare two Blobs for equality. |
| 58 | + friend bool operator==(const Blob& lhs, const Blob& rhs) = default; |
| 59 | +}; |
| 60 | + |
| 61 | +/// \brief Returns a string representation of a Blob. |
| 62 | +ICEBERG_EXPORT std::string ToString(const Blob& blob); |
| 63 | + |
| 64 | +} // namespace iceberg::puffin |
0 commit comments