Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsaka committed Sep 26, 2024
1 parent 2c1688c commit 4f4c6e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions velox/functions/prestosql/types/IPPrefixType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ class IPPrefixCastOperator : public exec::CastOperator {
memcpy(&addrBytes, intAddr.data(), kIPAddressBytes);
folly::IPAddressV6 v6Addr(addrBytes);

exec::StringWriter<false> result(flatResult, row);
exec::StringWriter<false> resultWriter(flatResult, row);
if (v6Addr.isIPv4Mapped()) {
result.append(fmt::format(
resultWriter.append(fmt::format(
"{}/{}",
v6Addr.createIPv4().str(),
(uint8_t)intAddr.data()[kIPAddressBytes]));
} else {
result.append(fmt::format(
resultWriter.append(fmt::format(
"{}/{}", v6Addr.str(), (uint8_t)intAddr.data()[kIPAddressBytes]));
}
result.finalize();
resultWriter.finalize();
});
}

Expand Down Expand Up @@ -245,11 +245,11 @@ class IPPrefixCastOperator : public exec::CastOperator {
.toByteArray();
}

exec::StringWriter<false> result(flatResult, row);
result.resize(kIPPrefixBytes);
memcpy(result.data(), &addrBytes, kIPAddressBytes);
result.data()[kIPAddressBytes] = net.second;
result.finalize();
exec::StringWriter<false> resultWriter(flatResult, row);
resultWriter.resize(kIPPrefixBytes);
memcpy(resultWriter.data(), &addrBytes, kIPAddressBytes);
resultWriter.data()[kIPAddressBytes] = net.second;
resultWriter.finalize();
});
}

Expand Down Expand Up @@ -286,21 +286,21 @@ class IPPrefixCastOperator : public exec::CastOperator {
auto ipAddress = ipAddresses->valueAt(row);
folly::ByteArray16 addrBytes;

exec::StringWriter<false> result(flatResult, row);
result.resize(kIPPrefixBytes);
exec::StringWriter<false> resultWriter(flatResult, row);
resultWriter.resize(kIPPrefixBytes);

memcpy(&addrBytes, &ipAddress, kIPAddressBytes);
std::reverse(addrBytes.begin(), addrBytes.end());
memcpy(result.data(), &addrBytes, kIPAddressBytes);
memcpy(resultWriter.data(), &addrBytes, kIPAddressBytes);

folly::IPAddressV6 v6Addr(addrBytes);
if (v6Addr.isIPv4Mapped()) {
result.data()[kIPAddressBytes] = kIPV4Bits;
resultWriter.data()[kIPAddressBytes] = kIPV4Bits;
} else {
result.data()[kIPAddressBytes] = kIPV6Bits;
resultWriter.data()[kIPAddressBytes] = kIPV6Bits;
}

result.finalize();
resultWriter.finalize();
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion velox/functions/prestosql/types/UuidType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class UuidCastOperator : public exec::CastOperator {
castFromString(input, context, rows, *result);
} else {
VELOX_UNSUPPORTED(
"Cast from {} to UUID not yet supported", input.type()->toString());
"Cast from {} to UUID not yet supported", resultType->toString());
}
}

Expand Down

0 comments on commit 4f4c6e7

Please sign in to comment.