wgtmac commented on code in PR #34616:
URL: https://github.com/apache/arrow/pull/34616#discussion_r1255257802
##########
cpp/src/arrow/dataset/file_parquet.h:
##########
@@ -136,6 +137,40 @@ class ARROW_DS_EXPORT ParquetFileFormat : public
FileFormat {
fs::FileLocator destination_locator) const override;
std::shared_ptr<FileWriteOptions> DefaultWriteOptions() override;
+
+ /// \brief A getter function to retrieve the dataset encryption configuration
+ std::shared_ptr<DatasetEncryptionConfiguration> GetDatasetEncryptionConfig()
const {
+#ifdef PARQUET_REQUIRE_ENCRYPTION
+ return dataset_encryption_config_;
+#else
+ return NULLPTR;
+#endif
+ }
+ /// \brief A getter function to retrieve the dataset decryption configuration
+ std::shared_ptr<DatasetDecryptionConfiguration> GetDatasetDecryptionConfig()
const {
+#ifdef PARQUET_REQUIRE_ENCRYPTION
+ return dataset_decryption_config_;
+#else
+ return NULLPTR;
+#endif
+ }
+ /// \brief A setter for DatasetEncryptionConfiguration
+ void SetDatasetEncryptionConfig(
+ std::shared_ptr<DatasetEncryptionConfiguration>
dataset_encryption_config) {
+ dataset_encryption_config_ = std::move(dataset_encryption_config);
+ }
+ /// \brief A setter for DatasetDecryptionConfiguration
+ void SetDatasetDecryptionConfig(
+ std::shared_ptr<DatasetDecryptionConfiguration>
dataset_decryption_config) {
+ dataset_decryption_config_ = std::move(dataset_decryption_config);
+ }
+
+ private:
+ // A configuration structure that provides per file encryption properties
for a dataset
+ std::shared_ptr<DatasetEncryptionConfiguration> dataset_encryption_config_ =
NULLPTR;
Review Comment:
Could you make this change and below?
##########
cpp/src/arrow/dataset/parquet_encryption_config.h:
##########
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "arrow/dataset/type_fwd.h"
+#include "parquet/encryption/crypto_factory.h"
+#include "parquet/encryption/encryption.h"
+#include "parquet/encryption/kms_client.h"
+
+namespace arrow {
+namespace dataset {
+
+/// core class, that translates the parameters of high level encryption
+struct ARROW_DS_EXPORT DatasetEncryptionConfiguration {
+ DatasetEncryptionConfiguration()
+ : kms_connection_config(
+ std::make_shared<parquet::encryption::KmsConnectionConfig>()) {}
+
+ void Setup(
+ std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory,
+ std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config,
+ std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config) {
+ this->crypto_factory = std::move(crypto_factory);
+ this->kms_connection_config = std::move(kms_connection_config);
+ this->encryption_config = std::move(encryption_config);
+ }
+
+ std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory;
+ std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config;
+ std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config;
+};
Review Comment:
Thanks for the explanation! Then I think we still can consolidate
DatasetEncryptionConfiguration and DatasetDecryptionConfiguration into a single
DatasetEncryptionConfiguration and do not provide default values. WDYT?
Something like
```cpp
struct ARROW_DS_EXPORT DatasetEncryptionConfiguration {
void Setup(
std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory,
std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config,
std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config,
std::shared_ptr<parquet::encryption::DecryptionConfiguration>
decryption_config) {
this->crypto_factory = std::move(crypto_factory);
this->kms_connection_config = std::move(kms_connection_config);
this->encryption_config = std::move(encryption_config);
this->decryption_config = std::move(decryption_config);
}
std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory;
std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config;
std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config;
std::shared_ptr<parquet::encryption::DecryptionConfiguration>
decryption_config;
};
```
##########
cpp/src/arrow/dataset/parquet_encryption_config.h:
##########
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "arrow/dataset/type_fwd.h"
+#include "parquet/encryption/crypto_factory.h"
+#include "parquet/encryption/encryption.h"
+#include "parquet/encryption/kms_client.h"
+
+namespace arrow {
+namespace dataset {
+
+/// core class, that translates the parameters of high level encryption
+struct ARROW_DS_EXPORT DatasetEncryptionConfiguration {
+ DatasetEncryptionConfiguration()
+ : kms_connection_config(
+ std::make_shared<parquet::encryption::KmsConnectionConfig>()) {}
+
+ void Setup(
+ std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory,
+ std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config,
+ std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config) {
+ this->crypto_factory = std::move(crypto_factory);
+ this->kms_connection_config = std::move(kms_connection_config);
+ this->encryption_config = std::move(encryption_config);
+ }
+
+ std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory;
+ std::shared_ptr<parquet::encryption::KmsConnectionConfig>
kms_connection_config;
+ std::shared_ptr<parquet::encryption::EncryptionConfiguration>
encryption_config;
+};
Review Comment:
If there is a minimum requirement for some fields to be not null, we should
also check them in the Setup call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]