MCPcopy Create free account
hub / github.com/apache/arrow / NormalizerKeyValueMetadata

Function NormalizerKeyValueMetadata

cpp/src/arrow/filesystem/azurefs_test.cc:2939–2969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2937
2938namespace {
2939std::shared_ptr<const KeyValueMetadata> NormalizerKeyValueMetadata(
2940 std::shared_ptr<const KeyValueMetadata> metadata) {
2941 auto normalized = std::make_shared<KeyValueMetadata>();
2942 for (int64_t i = 0; i < metadata->size(); ++i) {
2943 auto key = metadata->key(i);
2944 auto value = metadata->value(i);
2945 if (key == "Content-Hash") {
2946 std::vector<uint8_t> output;
2947 output.resize(value.size() / 2);
2948 if (ParseHexValues(value, output.data()).ok()) {
2949 // Valid value
2950 value = std::string(value.size(), 'F');
2951 }
2952 } else if (key == "Last-Modified" || key == "Created-On" ||
2953 key == "Access-Tier-Changed-On") {
2954 auto parser = TimestampParser::MakeISO8601();
2955 int64_t output;
2956 if ((*parser)(value.data(), value.size(), TimeUnit::NANO, &output)) {
2957 // Valid value
2958 value = "2023-10-31T08:15:20Z";
2959 }
2960 } else if (key == "ETag") {
2961 if (value.starts_with("\"") && value.ends_with("\"")) {
2962 // Valid value
2963 value = "\"ETagValue\"";
2964 }
2965 }
2966 normalized->Append(key, value);
2967 }
2968 return normalized;
2969}
2970}; // namespace
2971
2972TEST_F(TestAzuriteFileSystem, OpenInputStreamReadMetadata) {

Callers 1

TEST_FFunction · 0.85

Calls 8

ParseHexValuesFunction · 0.85
resizeMethod · 0.80
sizeMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
okMethod · 0.45
dataMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected