Skip to content

Commit

Permalink
Fix usage of base64 to use string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Abraham committed Oct 1, 2024
1 parent 7fec6e9 commit df1bc36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions velox/core/Expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ folly::dynamic ConstantTypedExpr::serialize() const {
if (valueVector_) {
std::ostringstream out;
saveVector(*valueVector_, out);
auto serializedValue = out.str();
obj["valueVector"] = encoding::Base64::encode(
serializedValue.data(), serializedValue.size());
obj["valueVector"] = encoding::Base64::encode(std::string_view(out.str()));
} else {
obj["value"] = value_.serialize();
}
Expand All @@ -105,7 +103,7 @@ TypedExprPtr ConstantTypedExpr::create(
}

auto encodedData = obj["valueVector"].asString();
auto serializedData = encoding::Base64::decode(encodedData);
auto serializedData = encoding::Base64::decode(std::string_view(encodedData));
std::istringstream dataStream(serializedData);

auto* pool = static_cast<memory::MemoryPool*>(context);
Expand Down
8 changes: 4 additions & 4 deletions velox/exec/fuzzer/PrestoQueryRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ class ServerResponse {
// contains base64-encoded PrestoPage of results.

std::vector<RowVectorPtr> vectors;
for (auto& encodedData : response_["binaryData"]) {
const std::string data =
encoding::Base64::decode(encodedData.stringPiece());
vectors.push_back(deserialize(rowType, data, pool));
for (const auto& encodedData : response_["binaryData"]) {
const std::string decodedData =
encoding::Base64::decode(std::string_view(encodedData.stringPiece()));
vectors.push_back(deserialize(rowType, decodedData, pool));
}
return vectors;
}
Expand Down

0 comments on commit df1bc36

Please sign in to comment.