|
| 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_metadata.h |
| 23 | +/// Blob metadata 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 | + |
| 33 | +namespace iceberg::puffin { |
| 34 | + |
| 35 | +/// \brief Metadata about a blob stored in a Puffin file. |
| 36 | +/// |
| 37 | +/// This represents the metadata stored in the Puffin file footer, |
| 38 | +/// including the blob's location within the file. |
| 39 | +struct ICEBERG_EXPORT BlobMetadata { |
| 40 | + /// Type of the blob. See StandardBlobTypes for known types. |
| 41 | + std::string type; |
| 42 | + /// List of field IDs the blob was computed for. |
| 43 | + std::vector<int32_t> input_fields; |
| 44 | + /// ID of the Iceberg table's snapshot the blob was computed from. |
| 45 | + int64_t snapshot_id; |
| 46 | + /// Sequence number of the Iceberg table's snapshot the blob was computed from. |
| 47 | + int64_t sequence_number; |
| 48 | + /// Offset in the file where the blob data starts. |
| 49 | + int64_t offset; |
| 50 | + /// Length of the blob data in the file. If compression_codec is set, this is |
| 51 | + /// the compressed size; otherwise it is the raw size. |
| 52 | + int64_t length; |
| 53 | + /// Compression codec name (e.g. "lz4", "zstd"), or std::nullopt if the blob |
| 54 | + /// is not compressed. |
| 55 | + std::optional<std::string> compression_codec; |
| 56 | + /// Additional properties of the blob. |
| 57 | + std::unordered_map<std::string, std::string> properties; |
| 58 | + |
| 59 | + /// \brief Compare two BlobMetadatas for equality. |
| 60 | + friend bool operator==(const BlobMetadata& lhs, const BlobMetadata& rhs) = default; |
| 61 | +}; |
| 62 | + |
| 63 | +/// \brief Returns a string representation of a BlobMetadata. |
| 64 | +ICEBERG_EXPORT std::string ToString(const BlobMetadata& blob_metadata); |
| 65 | + |
| 66 | +} // namespace iceberg::puffin |
0 commit comments