iceberg-cpp
Loading...
Searching...
No Matches
puffin_format.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 <array>
26#include <cstddef>
27#include <cstdint>
28#include <span>
29#include <vector>
30
31#include "iceberg/iceberg_data_export.h"
33#include "iceberg/result.h"
34
35namespace iceberg::puffin {
36
38struct ICEBERG_DATA_EXPORT PuffinFormat {
40 static constexpr std::array<uint8_t, 4> kMagicV1 = {0x50, 0x46, 0x41, 0x31};
41
42 static constexpr int32_t kMagicLength = 4;
43 static constexpr int32_t kFooterStartMagicOffset = 0;
44 static constexpr int32_t kFooterStartMagicLength = kMagicLength;
45 static constexpr int32_t kFooterStructPayloadSizeOffset = 0;
46 static constexpr int32_t kFooterStructFlagsOffset = kFooterStructPayloadSizeOffset + 4;
47 static constexpr int32_t kFooterStructFlagsLength = 4;
48 static constexpr int32_t kFooterStructMagicOffset =
49 kFooterStructFlagsOffset + kFooterStructFlagsLength;
50
52 static constexpr int32_t kFooterStructLength = kFooterStructMagicOffset + kMagicLength;
53
55 static constexpr PuffinCompressionCodec kDefaultFooterCompressionCodec =
56 PuffinCompressionCodec::kLz4;
57};
58
60enum class PuffinFlag : uint8_t {
63};
64
66ICEBERG_DATA_EXPORT bool IsFlagSet(std::span<const uint8_t, 4> flags, PuffinFlag flag);
67
69ICEBERG_DATA_EXPORT void SetFlag(std::span<uint8_t, 4> flags, PuffinFlag flag);
70
72ICEBERG_DATA_EXPORT Result<std::vector<std::byte>> Compress(
73 PuffinCompressionCodec codec, std::span<const std::byte> input);
74
76ICEBERG_DATA_EXPORT Result<std::vector<std::byte>> Decompress(
77 PuffinCompressionCodec codec, std::span<const std::byte> input);
78
79} // namespace iceberg::puffin
PuffinCompressionCodec
Compression codecs supported by Puffin files.
Definition file_metadata.h:38
PuffinFlag
Footer flags for Puffin files.
Definition puffin_format.h:60
@ kFooterPayloadCompressed
Whether the footer payload is compressed.
Puffin file format constants.
Definition puffin_format.h:38