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

Function NormalizerKeyValueMetadata

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

Source from the content-addressed store, hash-verified

2917
2918namespace {
2919std::shared_ptr<const KeyValueMetadata> NormalizerKeyValueMetadata(
2920 std::shared_ptr<const KeyValueMetadata> metadata) {
2921 auto normalized = std::make_shared<KeyValueMetadata>();
2922 for (int64_t i = 0; i < metadata->size(); ++i) {
2923 auto key = metadata->key(i);
2924 auto value = metadata->value(i);
2925 if (key == "Content-Hash") {
2926 std::vector<uint8_t> output;
2927 output.resize(value.size() / 2);
2928 if (ParseHexValues(value, output.data()).ok()) {
2929 // Valid value
2930 value = std::string(value.size(), 'F');
2931 }
2932 } else if (key == "Last-Modified" || key == "Created-On" ||
2933 key == "Access-Tier-Changed-On") {
2934 auto parser = TimestampParser::MakeISO8601();
2935 int64_t output;
2936 if ((*parser)(value.data(), value.size(), TimeUnit::NANO, &output)) {
2937 // Valid value
2938 value = "2023-10-31T08:15:20Z";
2939 }
2940 } else if (key == "ETag") {
2941 if (value.starts_with("\"") && value.ends_with("\"")) {
2942 // Valid value
2943 value = "\"ETagValue\"";
2944 }
2945 }
2946 normalized->Append(key, value);
2947 }
2948 return normalized;
2949}
2950}; // namespace
2951
2952TEST_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