Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnavBalyan committed Aug 12, 2024
1 parent 961c922 commit 2bad963
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions cpp/core/config/GlutenConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,48 @@
*/

#include <jni.h>

#include <optional>
#include <regex>
#include "compute/ProtobufUtils.h"
#include "config.pb.h"
#include "jni/JniError.h"
#include <regex>
#include <optional>

namespace gluten {

const std::string REDACTED_VALUE = "*********(redacted)";
const std::string REGEX_REDACT_KEY = "spark.gluten.redaction.regex";

std::unordered_map<std::string, std::string>
parseConfMap(JNIEnv* env, const uint8_t* planData, const int32_t planDataLength) {
std::unordered_map<std::string, std::string> sparkConfs;
ConfigMap pConfigMap;
gluten::parseProtobuf(planData, planDataLength, &pConfigMap);
for (const auto& pair : pConfigMap.configs()) {
sparkConfs.emplace(pair.first, pair.second);
parseConfMap(JNIEnv* env, const uint8_t* planData, const int32_t planDataLength) {
std::unordered_map<std::string, std::string> sparkConfs;
ConfigMap pConfigMap;
gluten::parseProtobuf(planData, planDataLength, &pConfigMap);
for (const auto& pair : pConfigMap.configs()) {
sparkConfs.emplace(pair.first, pair.second);
}

return sparkConfs;
}

std::optional<std::regex> getRedactionRegex(const std::unordered_map<std::string, std::string>& conf) {
auto it = conf.find(REGEX_REDACT_KEY);
if (it != conf.end()) {
return std::regex(it->second);
}
return std::nullopt;
auto it = conf.find(REGEX_REDACT_KEY);
if (it != conf.end()) {
return std::regex(it->second);
}
return std::nullopt;
}

std::string printConfig(const std::unordered_map<std::string, std::string>& conf) {
std::ostringstream oss;
oss << std::endl;

auto redactionRegex = getRedactionRegex(conf);
auto redactionRegex = getRedactionRegex(conf);

for (const auto& [k, v] : conf) {
if (redactionRegex && std::regex_match(k, *redactionRegex)) {
oss << " [" << k << ", " << REDACTED_VALUE << "]\n";
oss << " [" << k << ", " << REDACTED_VALUE << "]\n";
} else {
oss << " [" << k << ", " << v << "]\n";
oss << " [" << k << ", " << v << "]\n";
}
}
return oss.str();
Expand Down

0 comments on commit 2bad963

Please sign in to comment.