gortiz commented on code in PR #16872:
URL: https://github.com/apache/pinot/pull/16872#discussion_r2378011147
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/channel/MailboxContentObserver.java:
##########
@@ -48,16 +48,15 @@ public class MailboxContentObserver implements
StreamObserver<MailboxContent> {
private final MailboxService _mailboxService;
private final StreamObserver<MailboxStatus> _responseObserver;
- private final List<ByteBuffer> _mailboxBuffers;
+ private final List<ByteBuffer> _mailboxBuffers =
Collections.synchronizedList(new ArrayList<>());
Review Comment:
I don't understand this change. As defined by `StreamObserver` javadoc, the
class doesn't have to be thread safe. It explicitly says that if multiple
threads need to use the observer access must be synchronized.
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/GrpcSendingMailboxTest.java:
##########
@@ -46,55 +46,53 @@ public class GrpcSendingMailboxTest {
@Test(dataProvider = "byteBuffersDataProvider")
public void testByteBuffersToByteStrings(int[] byteBufferSizes, int
maxByteStringSize) {
- List<ByteBuffer> input = Arrays.stream(byteBufferSizes)
- .mapToObj(this::randomByteBuffer).collect(Collectors.toList());
+ List<ByteBuffer> input =
+
Arrays.stream(byteBufferSizes).mapToObj(this::randomByteBuffer).collect(Collectors.toList());
ByteBuffer expected = concatenateBuffers(input);
List<ByteString> output = GrpcSendingMailbox.toByteStrings(input,
maxByteStringSize);
- for (ByteString chunk: output.subList(0, output.size() - 1)) {
+ for (ByteString chunk : output.subList(0, output.size() - 1)) {
assertEquals(chunk.size(), maxByteStringSize);
}
assertTrue(output.get(output.size() - 1).size() <= maxByteStringSize);
- ByteBuffer actual = concatenateBuffers(
-
output.stream().map(ByteString::asReadOnlyByteBuffer).collect(Collectors.toList()));
+ ByteBuffer actual =
+
concatenateBuffers(output.stream().map(ByteString::asReadOnlyByteBuffer).collect(Collectors.toList()));
assertEquals(actual, expected);
}
@Test(dataProvider = "testDataBlockToByteStringsProvider")
- public void testDataBlockToByteStrings(String name, int maxByteStringSize)
throws IOException {
+ public void testDataBlockToByteStrings(String name, int maxByteStringSize)
+ throws IOException {
DataBlock dataBlock = buildTestDataBlock();
List<ByteString> output = GrpcSendingMailbox.toByteStrings(dataBlock,
maxByteStringSize);
- for (ByteString chunk: output) {
+ for (ByteString chunk : output) {
assertTrue(chunk.size() <= maxByteStringSize);
}
- DataBlock actual = DataBlockUtils.deserialize(
-
output.stream().map(ByteString::asReadOnlyByteBuffer).collect(Collectors.toList()));
+ DataBlock deserialized = DataBlockUtils.deserialize(
+ output.stream().map(byteString ->
byteString.asReadOnlyByteBuffer().slice()).collect(Collectors.toList()));
Review Comment:
Do we actually need to slice it?
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/GrpcSendingMailboxTest.java:
##########
@@ -46,55 +46,53 @@ public class GrpcSendingMailboxTest {
@Test(dataProvider = "byteBuffersDataProvider")
public void testByteBuffersToByteStrings(int[] byteBufferSizes, int
maxByteStringSize) {
- List<ByteBuffer> input = Arrays.stream(byteBufferSizes)
- .mapToObj(this::randomByteBuffer).collect(Collectors.toList());
+ List<ByteBuffer> input =
+
Arrays.stream(byteBufferSizes).mapToObj(this::randomByteBuffer).collect(Collectors.toList());
ByteBuffer expected = concatenateBuffers(input);
List<ByteString> output = GrpcSendingMailbox.toByteStrings(input,
maxByteStringSize);
- for (ByteString chunk: output.subList(0, output.size() - 1)) {
+ for (ByteString chunk : output.subList(0, output.size() - 1)) {
assertEquals(chunk.size(), maxByteStringSize);
}
assertTrue(output.get(output.size() - 1).size() <= maxByteStringSize);
- ByteBuffer actual = concatenateBuffers(
-
output.stream().map(ByteString::asReadOnlyByteBuffer).collect(Collectors.toList()));
+ ByteBuffer actual =
+
concatenateBuffers(output.stream().map(ByteString::asReadOnlyByteBuffer).collect(Collectors.toList()));
Review Comment:
We need to reduce the style changes. This appears to be a reformatting done
by the IDE. These changes are opinionated (not mandated by the coding style),
subjective (some people may think the previous code is easier to read), and
they make the PR more difficult to review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]