iceberg-cpp
Loading...
Searching...
No Matches
json_serde_internal.h
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#include <map>
23#include <memory>
24#include <optional>
25#include <string>
26#include <string_view>
27#include <unordered_map>
28
29#include <nlohmann/json_fwd.hpp>
30
32#include "iceberg/result.h"
35#include "iceberg/type_fwd.h"
36
37namespace iceberg {
38
47ICEBERG_EXPORT nlohmann::json ToJson(const SortField& sort_field);
48
58ICEBERG_EXPORT Result<std::unique_ptr<SortField>> SortFieldFromJson(
59 const nlohmann::json& json);
60
69ICEBERG_EXPORT nlohmann::json ToJson(const SortOrder& sort_order);
70
81ICEBERG_EXPORT Result<std::unique_ptr<SortOrder>> SortOrderFromJson(
82 const nlohmann::json& json, const std::shared_ptr<Schema>& current_schema);
83
89ICEBERG_EXPORT Result<std::unique_ptr<SortOrder>> SortOrderFromJson(
90 const nlohmann::json& json);
91
96ICEBERG_EXPORT Result<nlohmann::json> ToJson(const Schema& schema);
97
102ICEBERG_EXPORT Result<std::string> ToJsonString(const Schema& schema);
103
108ICEBERG_EXPORT Result<std::unique_ptr<Schema>> SchemaFromJson(const nlohmann::json& json);
109
114ICEBERG_EXPORT Result<nlohmann::json> ToJson(const Type& type);
115
120ICEBERG_EXPORT Result<std::unique_ptr<Type>> TypeFromJson(const nlohmann::json& json);
121
126ICEBERG_EXPORT Result<nlohmann::json> ToJson(const SchemaField& field);
127
132ICEBERG_EXPORT Result<std::unique_ptr<SchemaField>> FieldFromJson(
133 const nlohmann::json& json);
134
144ICEBERG_EXPORT nlohmann::json ToJson(const PartitionField& partition_field);
145
157ICEBERG_EXPORT Result<std::unique_ptr<PartitionField>> PartitionFieldFromJson(
158 const nlohmann::json& json, bool allow_field_id_missing = false);
159
170ICEBERG_EXPORT nlohmann::json ToJson(const PartitionSpec& partition_spec);
171
182ICEBERG_EXPORT Result<std::string> ToJsonString(const PartitionSpec& partition_spec);
183
196ICEBERG_EXPORT Result<std::unique_ptr<PartitionSpec>> PartitionSpecFromJson(
197 const std::shared_ptr<Schema>& schema, const nlohmann::json& json,
198 int32_t default_spec_id);
199
205ICEBERG_EXPORT Result<std::unique_ptr<PartitionSpec>> PartitionSpecFromJson(
206 const nlohmann::json& json);
207
212ICEBERG_EXPORT nlohmann::json ToJson(const SnapshotRef& snapshot_ref);
213
218ICEBERG_EXPORT Result<std::unique_ptr<SnapshotRef>> SnapshotRefFromJson(
219 const nlohmann::json& json);
220
225ICEBERG_EXPORT nlohmann::json ToJson(const Snapshot& snapshot);
226
231ICEBERG_EXPORT Result<std::unique_ptr<Snapshot>> SnapshotFromJson(
232 const nlohmann::json& json);
233
238ICEBERG_EXPORT nlohmann::json ToJson(const StatisticsFile& statistics_file);
239
244ICEBERG_EXPORT Result<std::unique_ptr<StatisticsFile>> StatisticsFileFromJson(
245 const nlohmann::json& json);
246
251ICEBERG_EXPORT nlohmann::json ToJson(
252 const PartitionStatisticsFile& partition_statistics_file);
253
258ICEBERG_EXPORT Result<std::unique_ptr<PartitionStatisticsFile>>
259PartitionStatisticsFileFromJson(const nlohmann::json& json);
260
265ICEBERG_EXPORT nlohmann::json ToJson(const SnapshotLogEntry& snapshot_log_entry);
266
271ICEBERG_EXPORT Result<SnapshotLogEntry> SnapshotLogEntryFromJson(
272 const nlohmann::json& json);
273
278ICEBERG_EXPORT nlohmann::json ToJson(const MetadataLogEntry& metadata_log_entry);
279
284ICEBERG_EXPORT Result<MetadataLogEntry> MetadataLogEntryFromJson(
285 const nlohmann::json& json);
286
291ICEBERG_EXPORT nlohmann::json ToJson(const EncryptedKey& encrypted_key);
292
297ICEBERG_EXPORT Result<EncryptedKey> EncryptedKeyFromJson(const nlohmann::json& json);
298
303ICEBERG_EXPORT Result<nlohmann::json> ToJson(const TableMetadata& table_metadata);
304
309ICEBERG_EXPORT Result<std::string> ToJsonString(const TableMetadata& table_metadata);
310
315ICEBERG_EXPORT Result<std::unique_ptr<TableMetadata>> TableMetadataFromJson(
316 const nlohmann::json& json);
317
322ICEBERG_EXPORT Result<nlohmann::json> FromJsonString(const std::string& json_string);
323
328ICEBERG_EXPORT Result<std::string> ToJsonString(const nlohmann::json& json);
329
334ICEBERG_EXPORT nlohmann::json ToJson(const MappedField& field);
335
340ICEBERG_EXPORT Result<MappedField> MappedFieldFromJson(const nlohmann::json& json);
341
346ICEBERG_EXPORT nlohmann::json ToJson(const MappedFields& mapped_fields);
347
352ICEBERG_EXPORT Result<std::unique_ptr<MappedFields>> MappedFieldsFromJson(
353 const nlohmann::json& json);
354
359ICEBERG_EXPORT nlohmann::json ToJson(const NameMapping& name_mapping);
360
365ICEBERG_EXPORT Result<std::unique_ptr<NameMapping>> NameMappingFromJson(
366 const nlohmann::json& json);
367
372ICEBERG_EXPORT Result<std::string> UpdateMappingFromJsonString(
373 std::string_view mapping_json,
374 const std::unordered_map<int32_t, std::shared_ptr<SchemaField>>& updates,
375 const std::multimap<int32_t, int32_t>& adds);
376
382ICEBERG_EXPORT nlohmann::json ToJson(const TableIdentifier& identifier);
383
388ICEBERG_EXPORT Result<TableIdentifier> TableIdentifierFromJson(
389 const nlohmann::json& json);
390
395ICEBERG_EXPORT nlohmann::json ToJson(const Namespace& ns);
396
401ICEBERG_EXPORT Result<Namespace> NamespaceFromJson(const nlohmann::json& json);
402
407ICEBERG_EXPORT Result<nlohmann::json> ToJson(const TableUpdate& update);
408
413ICEBERG_EXPORT Result<std::unique_ptr<TableUpdate>> TableUpdateFromJson(
414 const nlohmann::json& json);
415
420ICEBERG_EXPORT nlohmann::json ToJson(const TableRequirement& requirement);
421
426ICEBERG_EXPORT Result<std::unique_ptr<TableRequirement>> TableRequirementFromJson(
427 const nlohmann::json& json);
428
429} // namespace iceberg