File indexing completed on 2026-04-17 08:28:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <set>
0021 #include <string>
0022 #include <unordered_map>
0023
0024 #include "arrow/filesystem/filesystem.h"
0025
0026 #include "parquet/encryption/file_key_material_store.h"
0027
0028 namespace parquet::encryption {
0029
0030
0031
0032 class PARQUET_EXPORT FileSystemKeyMaterialStore : public FileKeyMaterialStore {
0033 public:
0034 static constexpr const char kKeyMaterialFilePrefix[] = "_KEY_MATERIAL_FOR_";
0035 static constexpr const char kTempFilePrefix[] = "_TMP";
0036 static constexpr const char kKeyMaterialFileSuffix[] = ".json";
0037
0038 FileSystemKeyMaterialStore() {}
0039 FileSystemKeyMaterialStore(std::string key_material_file_path,
0040 std::shared_ptr<::arrow::fs::FileSystem> file_system);
0041
0042
0043
0044
0045
0046
0047 static std::shared_ptr<FileSystemKeyMaterialStore> Make(
0048 std::string parquet_file_path, std::shared_ptr<::arrow::fs::FileSystem> file_system,
0049 bool use_tmp_prefix);
0050
0051
0052 void AddKeyMaterial(std::string key_id_in_file, std::string key_material) {
0053 key_material_map_.emplace(std::move(key_id_in_file), std::move(key_material));
0054 }
0055
0056
0057 std::string GetKeyMaterial(std::string key_id_in_file) {
0058 if (key_material_map_.empty()) {
0059 LoadKeyMaterialMap();
0060 }
0061 auto found = key_material_map_.find(key_id_in_file);
0062 return found->second;
0063 }
0064
0065
0066
0067 void SaveMaterial();
0068
0069
0070 void RemoveMaterial();
0071
0072
0073 void MoveMaterialTo(std::shared_ptr<FileKeyMaterialStore> target_key_store);
0074
0075
0076 std::vector<std::string> GetKeyIDSet();
0077
0078 private:
0079 std::string GetStorageFilePath() { return key_material_file_path_; }
0080
0081 std::string BuildKeyMaterialMapJson();
0082 void LoadKeyMaterialMap();
0083 std::string key_material_file_path_;
0084 std::shared_ptr<::arrow::fs::FileSystem> file_system_;
0085
0086 std::unordered_map<std::string, std::string> key_material_map_;
0087 };
0088
0089 }