Skip to content
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

Merged
merged 1 commit into from
Sep 16, 2020
Merged

Change distribution value type to ByteString #14

merged 1 commit into from
Sep 16, 2020

Conversation

ao2017
Copy link
Contributor

@ao2017 ao2017 commented Sep 15, 2020

No description provided.

@ao2017 ao2017 requested review from a team and spkrka September 15, 2020 17:52
Copy link

@sming sming left a 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());
Copy link
Member

@spkrka spkrka Sep 16, 2020

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())));
Copy link
Member

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

Copy link
Member

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) {
Copy link
Member

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

Copy link
Contributor Author

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.

@ao2017 ao2017 merged commit 68a0ab9 into spotify:master Sep 16, 2020
@ao2017 ao2017 deleted the adele/distribution_2 branch September 16, 2020 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants