-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change distribution value type to ByteString #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with my limited understanding of the scope or strategic level, it LGTM :)
ByteBuffer out = ByteBuffer.allocate(bytes.length); | ||
out.put(bytes); | ||
return out; | ||
return ByteString.copyFrom(out.array()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary to go from byte[] -> ByteBuffer -> ByteString
Simplify to ByteString.copyFromUtf8(...)?
@@ -94,7 +94,8 @@ public void testSerializeDistributionValue() throws InvalidProtocolBufferExcepti | |||
final byte [] pointVal = DISTRIBUTION_DATA_POINT.getBytes(StandardCharsets.UTF_8); | |||
ByteBuffer byteBuffer = ByteBuffer.allocate(pointVal.length); | |||
byteBuffer.put(pointVal); | |||
Metric metricV1 = (new Metric()).value(Value.distributionValue(byteBuffer)); | |||
Metric metricV1 = (new Metric()).value(Value | |||
.distributionValue(ByteString.copyFrom(byteBuffer.array()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ByteString.copyFrom(byteBuffer) might be cleaner, but perhaps you would then first need to flip the buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually - just do ByteString.copyFromUtf8(DISTRIBUTION_DATA_POINT) instead
@@ -40,14 +40,14 @@ public static Value doubleValue(double value) { | |||
return DoubleValue.create(value); | |||
} | |||
|
|||
public static Value distributionValue(ByteBuffer byteBuffer) { | |||
return DistributionValue.create(byteBuffer); | |||
public static Value distributionValue(ByteString byteString) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a breaking change, which I think we can live with if we are sure no one is depending on this.
Otherwise, we would need to keep the old method signature too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No one is using it. Nothing will break.
No description provided.