You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "gortiz (via GitHub)" <gi...@apache.org> on 2025/03/11 10:34:48 UTC
[PR] Substitute TransferableBlock with MseBlock [pinot]
gortiz opened a new pull request, #15245:
URL: https://github.com/apache/pinot/pull/15245
# Introduction
This is a large mechanical PR that replaces `TransferableBlock` with a new `MseBlock`. I’ve wanted to apply this refactor for over a year but postponed it for other reasons. Now, with the need to add multi-stage stats on failures, implementing that change within `TransferableBlock` proved too complex. As a result, I also redesigned how stats are communicated between operators.
# From TransferableBlock to MseBlock
`TransferableBlock` tried to model too many different things at once. It had three logical types:
* Data blocks (containing actual data)
* Successful End-of-stream (EOS) blocks (signaling completion)
* Erroneous End-of-stream (EOS) blocks (indicating failures)
Additionally, blocks could be in either a serialized or deserialized form, significantly increasing complexity. A single implementation had to support all cases, leading to an API where many methods were illegal in certain contexts. This made it difficult to determine when a method was safe to call.
For instance, `TransferableBlock` was designed to store stats only in EOS blocks, but the API allowed stats in other block types, potentially breaking invariants.
## MseBlock: A More Structured Approach
The new `MseBlock` follows a different design principle. Instead of a single class handling all cases, we now have separate interfaces for each block type. The actual methods are defined in these interfaces, reducing ambiguity.
For example, `MseBlock` itself does *not* have a `getNumRows()` method. Instead, that method is part of `MseBlock.Data`. This forces callers to explicitly cast their `MseBlock` to the appropriate type, making the API safer.
While this may initially seem more restrictive, it actually simplifies development. Previously, developers had to rely on context to determine whether a method could be called. Now, the Java compiler enforces correctness, reducing potential errors.
## New MseBlock Structure
```mermaid
classDiagram
class MseBlock {
<<interface>>
+boolean isData()
+boolean isEos()
+boolean isSuccess()
+boolean isError()
}
class MseBlock.Data {
<<interface>>
+int getNumRows()
+DataSchema getDataSchema()
+RowHeapDataBlock asRowHeap()
+SerializedDataBlock asSerialized()
+boolean isRowHeap()
+boolean isSerialized()
}
class MseBlock.Eos {
<<interface>>
}
class RowHeapDataBlock {
-DataSchema _dataSchema
-List<Object[]> _rows
-AggregationFunction[] _aggFunctions
+List<Object[]> getRows()
+AggregationFunction[] getAggFunctions()
}
class SerializedDataBlock {
-DataBlock _dataBlock
+DataSchema getDataSchema()
}
class SuccessMseBlock {
}
class ErrorMseBlock {
-EnumMap<QueryErrorCode, String> _errorMessages
+Map<QueryErrorCode, String> getErrorMessages()
}
MseBlock <|-- MseBlock.Data
MseBlock <|-- MseBlock.Eos
MseBlock.Data <|-- RowHeapDataBlock
MseBlock.Data <|-- SerializedDataBlock
MseBlock.Eos <|-- SuccessMseBlock
MseBlock.Eos <|-- ErrorMseBlock
```
Currently, this structure requires explicit casting (or use the visitor pattern), but once Pinot upgrades to Java 17 or 21, we can use sealed classes and pattern matching, further simplifying the API.
# A New Way to Communicate Stats
Another key design change is that `MseBlock` never stores stats.
In `TransferableBlock`, stats were added as a workaround inside `DataBlock`, making the API more complex. This also polluted `MultiStageOperator.nextBlock` with unnecessary logic for collecting stats.
`MseBlock`, instead, does not contain stats at all. `MultiStageOperator.nextBlock()` now only deals with data blocks, EOS blocks, and error blocks. Instead of storing stats within blocks, we compute them separately using a new method:
## `calculateStats()` Workflow
1. Call `calculateStats()` on each input operator to retrieve upstream stats. If no inputs exist, start with empty stats.
2. Merge upstream stats.
3. Add stats from the current operator.
The exception is `MailboxReceivaeOperator`, which cannot directly call `calculateStats()` on upstream operators in other
stages (as they may be running in separate JVMs). Instead, stats are sent through `SendingMailbox`, packaged with EOS blocks.
## How Stats Are Transmitted
* When a `MailboxSendOperator` receives an EOS or error block, it calls `calculateStats()` and calls `Exchange.send(MseBlock.Eos, Stats)`
* Exchange ends up calling `SendingMailbox.send(MseBlock.Eos, Stats)`, whose implementation depends on the transport layer.
* In the gRPC implementation, this is packaged into the same `DataBlock` format as before.
* In the memory implementation, we directly add the pair (EOS block, Stats) into the `ReceivingMailbox` queue.
* When `ReceivingMailbox` reads messages, it extracts the stats, which are then retrieved when
`MailboxReceiveOperator.calculateStats()` is called.
This system ensures transparent multi-stage stat propagation while keeping `MseBlock` clean. It also shows how the new `MseBlock` API can be used to enforce a cleaner design. The new `SendingMailbox` and `Exchange` methods define their restrictions using Java typesystem:
- Data blocks are never sent with stats
- EOS blocks are always sent with stats (even if empty)
# Summary of Benefits
- Simplified API: MseBlock eliminates ambiguous method calls and enforces correctness at the compiler level.
- Cleaner Stats Handling: Stats are no longer a hack inside data blocks, reducing unnecessary complexity.
- Better Type Safety: Separate interfaces prevent illegal operations on blocks.
- Future-Proof Design: Once Pinot upgrades to Java 17/21, pattern matching and sealed classes will further improve usability.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991798395
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
Review Comment:
Typo: `relay on` -> `rely on` .
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032823867
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/MultiStageOperator.java:
##########
@@ -122,24 +123,37 @@ protected void earlyTerminate() {
}
}
+ @Override
+ public abstract List<MultiStageOperator> getChildOperators();
+
/**
- * Adds the current operator stats as the last operator in the open stats of the given holder.
+ * Calculates and returns the stats for the operator.
*
- * It is assumed that:
- * <ol>
- * <li>The current stage of the holder is equal to the stage id of this operator.</li>
- * <li>The holder already contains the stats of the previous operators of the same stage in inorder</li>
- * </ol>
+ * Each time this method is called, a new instance of the stats is created. This is because the stats are mutable and
+ * can be updated by the operator or the caller after the stats are returned.
*/
- protected void addStats(MultiStageQueryStats holder, StatMap<?> statMap) {
- Preconditions.checkArgument(holder.getCurrentStageId() == _context.getStageId(),
+ public final MultiStageQueryStats calculateStats() {
+ MultiStageQueryStats upstreamStats = calculateUpstreamStats();
+
+ Preconditions.checkArgument(upstreamStats.getCurrentStageId() == _context.getStageId(),
"The holder's stage id should be the same as the current operator's stage id. Expected %s, got %s",
- _context.getStageId(), holder.getCurrentStageId());
- holder.getCurrentStats().addLastOperator(getOperatorType(), statMap);
+ _context.getStageId(), upstreamStats.getCurrentStageId());
+ upstreamStats.getCurrentStats().addLastOperator(getOperatorType(), copyStatMaps());
+ return upstreamStats;
}
- @Override
- public abstract List<MultiStageOperator> getChildOperators();
+ protected MultiStageQueryStats calculateUpstreamStats() {
Review Comment:
I've added a utility method in MultiStageQueryStats to document how it works
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991802263
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can relay on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
Review Comment:
`alternative of` -> `alternative to`
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1992036645
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/QueryRunner.java:
##########
@@ -244,10 +245,10 @@ public void processQuery(WorkerMetadata workerMetadata, StagePlan stagePlan, Map
// Send error block to all the receivers if pipeline breaker fails
if (pipelineBreakerResult != null && pipelineBreakerResult.getErrorBlock() != null) {
- TransferableBlock errorBlock = pipelineBreakerResult.getErrorBlock();
+ ErrorMseBlock errorBlock = pipelineBreakerResult.getErrorBlock();
int stageId = stageMetadata.getStageId();
LOGGER.error("Error executing pipeline breaker for request: {}, stage: {}, sending error block: {}", requestId,
Review Comment:
Won't this just use default version of toString() method, producing useless message ?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032718409
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// At the time of writing, this class is used almost every time we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
Review Comment:
Yes, but that is not problematic, right?
I'm removing anyway to avoid confusion
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2024207226
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can rely on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative to this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
Review Comment:
It is a design decision. MseBlock not having stats improves the quality of the code. Current TransferableBlocks include stats just because we use them as the mechanism to collect stats. This PR uses a different mechanism that is cleaner: Once the send operator is going to send the EOS or Error block, stats are calculated. You can see that new operators are easier to read because of that and we even fixed a bug in the intersection operator.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2051935586
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/MailboxServiceTest.java:
##########
@@ -610,18 +604,32 @@ public void testRemoteEarlyTerminated()
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// receiving-side early terminates after pulling the first block
TestUtils.waitForCondition(aVoid -> {
- TransferableBlock block = receivingMailbox.poll();
- return block != null && block.getNumRows() == 1;
+ MseBlock block = readBlock(receivingMailbox);
+ return block != null && block.isData() && ((MseBlock.Data) block).getNumRows() == 1;
Review Comment:
This change is causing https://github.com/apache/pinot/issues/15580 - we can't assert that the polled block is non-null in `readBlock` here because we're using actual gRPC mailboxes here and the mailbox might not have received the block yet in which case it'd return `null` initially.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032856832
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/SerializedDataBlock.java:
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.util.DataBlockExtractUtils;
+
+/// A block that contains data in serialized format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in serialized format.
+/// This is the most efficient way to store data, but it is also the hardest to work with.
+/// As the day this comment was written, this class is only used when we need to shuffle data through the network.
+/// In all other cases, we use [RowHeapDataBlock].
+public class SerializedDataBlock implements MseBlock.Data {
+ private final DataBlock _dataBlock;
+
+ /// Creates a new block with the given data block.
+ /// @param dataBlock The data block to store in this block. It cannot be a metadata block.
+ /// @throws IllegalArgumentException If the data block is a metadata block.
+ public SerializedDataBlock(DataBlock dataBlock) {
+ Preconditions.checkArgument(dataBlock.getDataBlockType() != DataBlock.Type.METADATA,
+ "SerializedDataBlock cannot be used to decorate metadata block");
+ _dataBlock = dataBlock;
+ }
+
+ /// Returns the data block stored in this block.
+ /// It is guaranteed that the returned data block is not a metadata block.
+ public DataBlock getDataBlock() {
+ return _dataBlock;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _dataBlock.getNumberOfRows();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataBlock.getDataSchema();
+ }
+
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ List<Object[]> rows = DataBlockExtractUtils.extractRows(_dataBlock);
+ return new RowHeapDataBlock(rows, _dataBlock.getDataSchema(), null);
Review Comment:
I've added a comment (and a deprecation note) on the attribute
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #15245:
URL: https://github.com/apache/pinot/pull/15245#issuecomment-2713751499
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/15245?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `0.38388%` with `519 lines` in your changes missing coverage. Please review.
> Project coverage is 34.17%. Comparing base [(`59551e4`)](https://app.codecov.io/gh/apache/pinot/commit/59551e45224f1535c4863fd577622b37366ccc97?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`5a80dbb`)](https://app.codecov.io/gh/apache/pinot/commit/5a80dbb0b45a321fc2f27331bd73b722357cb50e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 1832 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/15245?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...g/apache/pinot/query/mailbox/ReceivingMailbox.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fmailbox%2FReceivingMailbox.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvbWFpbGJveC9SZWNlaXZpbmdNYWlsYm94LmphdmE=) | 0.00% | [41 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...inot/query/runtime/operator/AggregateOperator.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2FAggregateOperator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci9BZ2dyZWdhdGVPcGVyYXRvci5qYXZh) | 0.00% | [27 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...pinot/query/runtime/operator/BaseJoinOperator.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2FBaseJoinOperator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci9CYXNlSm9pbk9wZXJhdG9yLmphdmE=) | 0.00% | [26 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ot/query/runtime/operator/MailboxSendOperator.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2FMailboxSendOperator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci9NYWlsYm94U2VuZE9wZXJhdG9yLmphdmE=) | 0.00% | [24 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...query/runtime/operator/exchange/BlockExchange.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2Fexchange%2FBlockExchange.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci9leGNoYW5nZS9CbG9ja0V4Y2hhbmdlLmphdmE=) | 0.00% | [24 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...apache/pinot/query/mailbox/GrpcSendingMailbox.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fmailbox%2FGrpcSendingMailbox.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvbWFpbGJveC9HcnBjU2VuZGluZ01haWxib3guamF2YQ==) | 0.00% | [23 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ache/pinot/query/runtime/blocks/BlockSplitter.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Fblocks%2FBlockSplitter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9ibG9ja3MvQmxvY2tTcGxpdHRlci5qYXZh) | 0.00% | [21 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...pinot/query/runtime/plan/MultiStageQueryStats.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Fplan%2FMultiStageQueryStats.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9wbGFuL011bHRpU3RhZ2VRdWVyeVN0YXRzLmphdmE=) | 0.00% | [20 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...ache/pinot/query/runtime/operator/SetOperator.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2FSetOperator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci9TZXRPcGVyYXRvci5qYXZh) | 0.00% | [19 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...me/operator/utils/BlockingMultiStreamConsumer.java](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&filepath=pinot-query-runtime%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fquery%2Fruntime%2Foperator%2Futils%2FBlockingMultiStreamConsumer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtcXVlcnktcnVudGltZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvcXVlcnkvcnVudGltZS9vcGVyYXRvci91dGlscy9CbG9ja2luZ011bHRpU3RyZWFtQ29uc3VtZXIuamF2YQ==) | 0.00% | [18 Missing :warning: ](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [34 more](https://app.codecov.io/gh/apache/pinot/pull/15245?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
> :exclamation: There is a different number of reports uploaded between BASE (59551e4) and HEAD (5a80dbb). Click for more details.
>
> <details><summary>HEAD has 53 uploads less than BASE</summary>
>
>| Flag | BASE (59551e4) | HEAD (5a80dbb) |
>|------|------|------|
>|integration|7|0|
>|integration2|3|0|
>|temurin|12|1|
>|java-21|7|1|
>|skip-bytebuffers-true|3|0|
>|skip-bytebuffers-false|7|1|
>|unittests|5|1|
>|unittests1|2|0|
>|java-11|5|0|
>|unittests2|3|1|
>|integration1|2|0|
>|custom-integration1|2|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #15245 +/- ##
=============================================
- Coverage 61.75% 34.17% -27.58%
- Complexity 207 684 +477
=============================================
Files 2436 2776 +340
Lines 133233 156177 +22944
Branches 20636 23934 +3298
=============================================
- Hits 82274 53369 -28905
- Misses 44911 98537 +53626
+ Partials 6048 4271 -1777
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-11](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-21](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.17% <0.38%> (-27.46%)` | :arrow_down: |
| [skip-bytebuffers-false](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.17% <0.38%> (-27.58%)` | :arrow_down: |
| [skip-bytebuffers-true](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.17% <0.38%> (-27.58%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.17% <0.38%> (-27.58%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/15245/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `34.17% <0.38%> (+6.44%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/15245?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary>🚀 New features to boost your workflow: </summary>
- ❄ [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- 📦 [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "albertobastos (via GitHub)" <gi...@apache.org>.
albertobastos commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2005308767
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/MultiStageQueryStats.java:
##########
@@ -95,32 +90,25 @@ private MultiStageQueryStats(int stageId) {
_closedStats = new ArrayList<>();
}
- private static MultiStageQueryStats create(int stageId, MultiStageOperator.Type type, @Nullable StatMap<?> opStats) {
- MultiStageQueryStats multiStageQueryStats = new MultiStageQueryStats(stageId);
- multiStageQueryStats.getCurrentStats().addLastOperator(type, opStats);
- return multiStageQueryStats;
+ private MultiStageQueryStats(MultiStageQueryStats other) {
+ _currentStageId = other._currentStageId;
+ _currentStats = StageStats.Open.copy(other._currentStats);
+ _closedStats = new ArrayList<>(other._closedStats.size());
+ for (StageStats.Closed closed : other._closedStats) {
+ if (closed == null) {
Review Comment:
That's a good point.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can relay on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative of this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
+
+ /// A visitor for [Data] blocks.
+ /// @param <R> The return type of the visitor. Use [Void] if the visitor does not return anything.
+ /// @param <A> The argument type of the visitor. Use [Void] if the visitor does not take any arguments.
+ interface Visitor<R, A> {
+ R visit(RowHeapDataBlock block, A arg);
+ R visit(SerializedDataBlock block, A arg);
+ }
+ }
+
+ /// A block that signals the end of a stream.
+ /// These blocks can be conceptually divided into successful and error blocks.
+ /// Both types of blocks may carry execution statistics and error blocks always carry error messages.
+ interface Eos extends MseBlock {
+ @Override
+ default boolean isData() {
Review Comment:
Not that it will be super useful, but `isSuccess()` and `isError()` have some method-level comment so I assumed `isData()` should have it too.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/pipeline/PipelineBreakerOperator.java:
##########
@@ -42,15 +42,13 @@ public class PipelineBreakerOperator extends MultiStageOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(PipelineBreakerOperator.class);
private static final String EXPLAIN_NAME = "PIPELINE_BREAKER";
- private final Map<Integer, Operator<TransferableBlock>> _workerMap;
+ private final Map<Integer, MultiStageOperator> _workerMap;
- private Map<Integer, List<TransferableBlock>> _resultMap;
- private TransferableBlock _errorBlock;
- @Nullable
- private MultiStageQueryStats _queryStats = null;
+ private Map<Integer, List<MseBlock>> _resultMap;
+ private ErrorMseBlock _errorBlock;
private final StatMap<StatKey> _statMap = new StatMap<>(StatKey.class);
- public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, Operator<TransferableBlock>> workerMap) {
+ public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, MultiStageOperator> workerMap) {
Review Comment:
Understood, will take a look at that. Would be nice to add some inline explanation at some point, anyway.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032846222
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/SerializedDataBlock.java:
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.util.DataBlockExtractUtils;
+
+/// A block that contains data in serialized format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in serialized format.
+/// This is the most efficient way to store data, but it is also the hardest to work with.
+/// As the day this comment was written, this class is only used when we need to shuffle data through the network.
+/// In all other cases, we use [RowHeapDataBlock].
+public class SerializedDataBlock implements MseBlock.Data {
+ private final DataBlock _dataBlock;
+
+ /// Creates a new block with the given data block.
+ /// @param dataBlock The data block to store in this block. It cannot be a metadata block.
+ /// @throws IllegalArgumentException If the data block is a metadata block.
+ public SerializedDataBlock(DataBlock dataBlock) {
+ Preconditions.checkArgument(dataBlock.getDataBlockType() != DataBlock.Type.METADATA,
+ "SerializedDataBlock cannot be used to decorate metadata block");
+ _dataBlock = dataBlock;
+ }
+
+ /// Returns the data block stored in this block.
+ /// It is guaranteed that the returned data block is not a metadata block.
+ public DataBlock getDataBlock() {
+ return _dataBlock;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _dataBlock.getNumberOfRows();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataBlock.getDataSchema();
+ }
+
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ List<Object[]> rows = DataBlockExtractUtils.extractRows(_dataBlock);
+ return new RowHeapDataBlock(rows, _dataBlock.getDataSchema(), null);
Review Comment:
Aggregation functions are used to decide how to apply a HashExchange. They should not be in the block, because it is something statically calculated and defined in the operator. But I assume @Jackie-Jiang didn't find a way to send this information from the aggregate/leaf operator to the exchange without adding it to the block.
Given it is only set in Aggregate and Leaf operators and it is consumed in the hash block, it is never used in offheap blocks (because offheap blocks are only created when data is serialized once the grpc mailbox send data).
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2040698744
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/SerializedDataBlock.java:
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.util.DataBlockExtractUtils;
+
+/// A block that contains data in serialized format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in serialized format.
+/// This is the most efficient way to store data, but it is also the hardest to work with.
+/// As the day this comment was written, this class is only used when we need to shuffle data through the network.
+/// In all other cases, we use [RowHeapDataBlock].
+public class SerializedDataBlock implements MseBlock.Data {
+ private final DataBlock _dataBlock;
+
+ /// Creates a new block with the given data block.
+ /// @param dataBlock The data block to store in this block. It cannot be a metadata block.
+ /// @throws IllegalArgumentException If the data block is a metadata block.
+ public SerializedDataBlock(DataBlock dataBlock) {
+ Preconditions.checkArgument(dataBlock.getDataBlockType() != DataBlock.Type.METADATA,
+ "SerializedDataBlock cannot be used to decorate metadata block");
+ _dataBlock = dataBlock;
+ }
+
+ /// Returns the data block stored in this block.
+ /// It is guaranteed that the returned data block is not a metadata block.
+ public DataBlock getDataBlock() {
+ return _dataBlock;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _dataBlock.getNumberOfRows();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataBlock.getDataSchema();
+ }
+
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ List<Object[]> rows = DataBlockExtractUtils.extractRows(_dataBlock);
+ return new RowHeapDataBlock(rows, _dataBlock.getDataSchema(), null);
Review Comment:
I don't think it's being used in `HashExchange` either right? The only place it seems to be used is in `DataBlockBuilder` to serialize intermediate result values when converting a row heap data block to a serialized data block.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can rely on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative to this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
Review Comment:
Ah, I see. I don't love it because I feel like it introduces a fair bit of cognitive overhead but I like your proposed future alternative of using sealed classes and pattern matching based switch statements.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2005253188
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/MultiStageQueryStats.java:
##########
@@ -95,32 +90,25 @@ private MultiStageQueryStats(int stageId) {
_closedStats = new ArrayList<>();
}
- private static MultiStageQueryStats create(int stageId, MultiStageOperator.Type type, @Nullable StatMap<?> opStats) {
- MultiStageQueryStats multiStageQueryStats = new MultiStageQueryStats(stageId);
- multiStageQueryStats.getCurrentStats().addLastOperator(type, opStats);
- return multiStageQueryStats;
+ private MultiStageQueryStats(MultiStageQueryStats other) {
+ _currentStageId = other._currentStageId;
+ _currentStats = StageStats.Open.copy(other._currentStats);
+ _closedStats = new ArrayList<>(other._closedStats.size());
+ for (StageStats.Closed closed : other._closedStats) {
+ if (closed == null) {
Review Comment:
But then `StageStats.Closed.copy` would be nullable, which means it should be annotated with `@Nullable`. Therefore, all usages of that method should either assume null will not be returned or have to check for null values.
By the way, the first goes against something that would be cool to add in the future: [NullAway](https://github.com/apache/pinot/pull/13741).
In general, when some types are usually not nullable, it is better to add explicit null checks outside utility methods than pollute all calls to that method with nullability
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991812499
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
Review Comment:
everytime -> `every time` . `As the day this comment was written` -> `At the time of writing (the comment)`
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991904724
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/FilterOperator.java:
##########
@@ -94,31 +94,33 @@ public String toExplainString() {
}
@Override
- protected TransferableBlock getNextBlock() {
+ protected MseBlock getNextBlock() {
// Keep reading the input blocks until we find a match row or all blocks are processed.
// TODO: Consider batching the rows to improve performance.
while (true) {
- TransferableBlock block = _input.nextBlock();
- if (block.isErrorBlock()) {
+ MseBlock block = _input.nextBlock();
Review Comment:
Is this correct ?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2024217488
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/BlockSplitter.java:
##########
@@ -18,20 +18,80 @@
*/
package org.apache.pinot.query.runtime.blocks;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
/**
- * Interface for splitting transferable blocks. This is used for ensuring
+ * Interface for splitting MSE blocks. This is used for ensuring
* that the blocks that are sent along the wire play nicely with the
* underlying transport.
*/
public interface BlockSplitter {
BlockSplitter NO_OP = (block, maxBlockSize) -> Iterators.singletonIterator(block);
+ BlockSplitter DEFAULT = new Default();
/**
* @return a list of blocks that was split from the original {@code block}
*/
- Iterator<TransferableBlock> split(TransferableBlock block, int maxBlockSize);
+ Iterator<? extends MseBlock.Data> split(MseBlock.Data block, int maxBlockSize);
+
+ /**
+ * Split a block into multiple block so that each block size is within maxBlockSize. Currently,
+ * <ul>
+ * <li>For row data block, we split for row type dataBlock.</li>
+ * <li>For columnar data block, exceptions are thrown.</li>
+ * <li>For metadata block, split is not supported.</li>
+ * </ul>
+ *
+ * @return a list of data block chunks
+ */
+ class Default implements BlockSplitter, MseBlock.Data.Visitor<Iterator<MseBlock.Data>, Integer> {
+ private static final int MEDIAN_COLUMN_SIZE_BYTES = 8;
+
+ private Default() {
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> split(MseBlock.Data block, int maxBlockSize) {
+ return block.accept(this, maxBlockSize);
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(RowHeapDataBlock block, Integer maxBlockSize) {
+ // Use estimated row size, this estimate is not accurate and is used to estimate numRowsPerChunk only.
+ DataSchema dataSchema = block.getDataSchema();
+ assert dataSchema != null;
+ int estimatedRowSizeInBytes = dataSchema.getColumnNames().length * MEDIAN_COLUMN_SIZE_BYTES;
+ int numRowsPerChunk = maxBlockSize / estimatedRowSizeInBytes;
+ Preconditions.checkState(numRowsPerChunk > 0, "row size too large for query engine to handle, abort!");
+
+ List<Object[]> rows = block.getRows();
+ int numRows = rows.size();
+ int numChunks = (numRows + numRowsPerChunk - 1) / numRowsPerChunk;
+ if (numChunks == 1) {
+ return Iterators.singletonIterator(block);
+ }
+ List<MseBlock.Data> blockChunks = new ArrayList<>(numChunks);
+ for (int fromIndex = 0; fromIndex < numRows; fromIndex += numRowsPerChunk) {
+ int toIndex = Math.min(fromIndex + numRowsPerChunk, numRows);
+ blockChunks.add(new RowHeapDataBlock(rows.subList(fromIndex, toIndex), dataSchema, block.getAggFunctions()));
+ }
+ return blockChunks.iterator();
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(SerializedDataBlock block, Integer maxBlockSize
+ ) {
+ if (block.getDataBlock().getDataBlockType() == DataBlock.Type.ROW) {
Review Comment:
Yes, I didn't find any usage of columnar mode in the current MSE code. If we end up using it in the future we can add them as a new MseBlock.Data implementation
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2052037174
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/MailboxServiceTest.java:
##########
@@ -610,18 +604,32 @@ public void testRemoteEarlyTerminated()
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// receiving-side early terminates after pulling the first block
TestUtils.waitForCondition(aVoid -> {
- TransferableBlock block = receivingMailbox.poll();
- return block != null && block.getNumRows() == 1;
+ MseBlock block = readBlock(receivingMailbox);
+ return block != null && block.isData() && ((MseBlock.Data) block).getNumRows() == 1;
Review Comment:
Nice catch
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/MailboxServiceTest.java:
##########
@@ -610,18 +604,32 @@ public void testRemoteEarlyTerminated()
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// receiving-side early terminates after pulling the first block
TestUtils.waitForCondition(aVoid -> {
- TransferableBlock block = receivingMailbox.poll();
- return block != null && block.getNumRows() == 1;
+ MseBlock block = readBlock(receivingMailbox);
+ return block != null && block.isData() && ((MseBlock.Data) block).getNumRows() == 1;
}, 1000L, "Failed to deliver mails");
receivingMailbox.earlyTerminate();
// send another block b/c it doesn't guarantee the next block must be EOS
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// send a metadata block
- sendingMailbox.send(TransferableBlockTestUtils.getEndOfStreamTransferableBlock(SENDER_STAGE_ID));
+ sendingMailbox.send(SuccessMseBlock.INSTANCE, MultiStageQueryStats.emptyStats(SENDER_STAGE_ID).serialize());
sendingMailbox.complete();
// sending side should early terminate
TestUtils.waitForCondition(aVoid -> sendingMailbox.isEarlyTerminated(), 1000L, "Failed to early-terminate sender");
}
+
+ private static List<Object[]> getRows(ReceivingMailbox receivingMailbox) {
+ ReceivingMailbox.MseBlockWithStats block = receivingMailbox.poll();
+ assertNotNull(block);
+ assertTrue(block.getBlock().isData());
+ List<Object[]> rows = ((MseBlock.Data) block).asRowHeap().getRows();
+ return rows;
+ }
+
+ public static MseBlock readBlock(ReceivingMailbox receivingMailbox) {
+ ReceivingMailbox.MseBlockWithStats block = receivingMailbox.poll();
+ assertNotNull(block);
+ return block.getBlock();
Review Comment:
Nice catch
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1989329010
##########
pinot-common/src/main/java/org/apache/pinot/common/datatable/StatMap.java:
##########
@@ -61,6 +61,13 @@ public StatMap(Class<K> keyClass) {
_map = Collections.synchronizedMap(new EnumMap<>(keyClass));
}
+ /// A copy constructor for the class.
Review Comment:
By the way, I'm using https://openjdk.org/jeps/467 here. Intellij already supports it even when compiling with Java 11, and it is shorter and easier to read in general.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LeafStageTransferableBlockOperator.java:
##########
@@ -481,47 +483,32 @@ void addResultsBlock(BaseResultsBlock resultsBlock)
}
}
- // TODO: Revisit the stats aggregation logic
- private void aggregateExecutionStats(Map<String, String> stats1, Map<String, String> stats2) {
- for (Map.Entry<String, String> entry : stats2.entrySet()) {
- String k2 = entry.getKey();
- String v2 = entry.getValue();
- stats1.merge(k2, v2, (val1, val2) -> {
- try {
- return Long.toString(Long.parseLong(val1) + Long.parseLong(val2));
- } catch (Exception e) {
- return val1 + "\n" + val2;
- }
- });
- }
- }
-
Review Comment:
this method wasn't called at all
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can relay on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
Review Comment:
Done
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/FilterOperator.java:
##########
@@ -94,31 +94,33 @@ public String toExplainString() {
}
@Override
- protected TransferableBlock getNextBlock() {
+ protected MseBlock getNextBlock() {
// Keep reading the input blocks until we find a match row or all blocks are processed.
// TODO: Consider batching the rows to improve performance.
while (true) {
- TransferableBlock block = _input.nextBlock();
- if (block.isErrorBlock()) {
+ MseBlock block = _input.nextBlock();
Review Comment:
What do you mean by _this_?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/QueryRunner.java:
##########
@@ -244,10 +245,10 @@ public void processQuery(WorkerMetadata workerMetadata, StagePlan stagePlan, Map
// Send error block to all the receivers if pipeline breaker fails
if (pipelineBreakerResult != null && pipelineBreakerResult.getErrorBlock() != null) {
- TransferableBlock errorBlock = pipelineBreakerResult.getErrorBlock();
+ ErrorMseBlock errorBlock = pipelineBreakerResult.getErrorBlock();
int stageId = stageMetadata.getStageId();
LOGGER.error("Error executing pipeline breaker for request: {}, stage: {}, sending error block: {}", requestId,
Review Comment:
Yes and no. The older TransferableBlocks overrides toString. I've modifies MseBlocks to do the same.
Anyway, the error is pretty much the same, given the default toString includes the class name and that is mostly what we want to log.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LeafStageTransferableBlockOperator.java:
##########
@@ -176,16 +174,25 @@ protected TransferableBlock getNextBlock()
// Terminate when receiving exception block
Map<Integer, String> exceptions = _exceptions;
if (exceptions != null) {
Review Comment:
I've done a different thing. I've created that static method in QueryErrorCode.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// As the day this comment was written, this class is used almost everytime we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
+ private final DataSchema _dataSchema;
+ private final List<Object[]> _rows;
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ private final AggregationFunction[] _aggFunctions;
+
Review Comment:
TBH I don't know what they are. To me they look like a break in abstraction. Maybe @Jackie-Jiang knows more about them
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
Review Comment:
Done
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
Review Comment:
Done
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/server/ServerPlanRequestVisitor.java:
##########
@@ -156,15 +156,15 @@ public Void visitJoin(JoinNode node, ServerPlanRequestContext context) {
if (visit(left, context)) {
PipelineBreakerResult pipelineBreakerResult = context.getPipelineBreakerResult();
int resultMapId = pipelineBreakerResult.getNodeIdMap().get(right);
- List<TransferableBlock> transferableBlocks =
- pipelineBreakerResult.getResultMap().getOrDefault(resultMapId, Collections.emptyList());
+ List<MseBlock> blocks = pipelineBreakerResult.getResultMap().getOrDefault(resultMapId, Collections.emptyList());
List<Object[]> resultDataContainer = new ArrayList<>();
DataSchema dataSchema = right.getDataSchema();
Review Comment:
I think this comment should be a bit below, right? I think you meant:
```java
for (TransferableBlock block : transferableBlocks) {
if (block.getType() == DataBlock.Type.ROW) {
resultDataContainer.addAll(block.getContainer());
}
}
```
Which is now:
```java
for (MseBlock block : blocks) {
if (block.isData()) {
resultDataContainer.addAll(((MseBlock.Data) block).asRowHeap().getRows());
}
}
```
I don't think we could receive column base blocks there. In fact I didn't see a single place where column blocks were used. Specifically in this case, I hope we weren't receiving any columnar block, otherwise we would just skip it and return an incorrect value
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032716826
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
Review Comment:
I don't think we need to specify the format here (given that readers don't care and could change it), but I will add some extra context.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991924294
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/LeafStageTransferableBlockOperator.java:
##########
@@ -176,16 +174,25 @@ protected TransferableBlock getNextBlock()
// Terminate when receiving exception block
Map<Integer, String> exceptions = _exceptions;
if (exceptions != null) {
Review Comment:
This block is used twice so it could be made into a regular or static constructor in ErrorMseBlock.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2005261336
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/pipeline/PipelineBreakerOperator.java:
##########
@@ -42,15 +42,13 @@ public class PipelineBreakerOperator extends MultiStageOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(PipelineBreakerOperator.class);
private static final String EXPLAIN_NAME = "PIPELINE_BREAKER";
- private final Map<Integer, Operator<TransferableBlock>> _workerMap;
+ private final Map<Integer, MultiStageOperator> _workerMap;
- private Map<Integer, List<TransferableBlock>> _resultMap;
- private TransferableBlock _errorBlock;
- @Nullable
- private MultiStageQueryStats _queryStats = null;
+ private Map<Integer, List<MseBlock>> _resultMap;
+ private ErrorMseBlock _errorBlock;
private final StatMap<StatKey> _statMap = new StatMap<>(StatKey.class);
- public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, Operator<TransferableBlock>> workerMap) {
+ public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, MultiStageOperator> workerMap) {
Review Comment:
Pipeline breakers are not very well explained. They are our way of implementing dynamic filters (see [our docs](https://docs.pinot.apache.org/users/user-guide-query/multi-stage-query/optimizing-joins#optimizing-semi-join-to-use-indexes) or [Trino docs](https://trino.io/episodes/11.html) or [our SQL or death talk last month](https://www.youtube.com/watch?v=yRMhAL_6f4o))
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2005330530
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/InMemorySendingMailbox.java:
##########
@@ -54,17 +58,28 @@ public boolean isLocal() {
}
@Override
- public void send(TransferableBlock block)
+ public void send(MseBlock.Data data)
+ throws IOException, TimeoutException {
+ sendPrivate(data, Collections.emptyList());
Review Comment:
`List.of()` was introduced in Java 9. Some parts of the code need to be compiled with Java 8 (basically to generate the driver). Does that mean I'm using `Collections.emptyList()` when needed? No, honestly. I usually use whatever copilot/Intellij autocomplete recommends, although I'm more used to using `Collections.emptyList`.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2024217488
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/BlockSplitter.java:
##########
@@ -18,20 +18,80 @@
*/
package org.apache.pinot.query.runtime.blocks;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
/**
- * Interface for splitting transferable blocks. This is used for ensuring
+ * Interface for splitting MSE blocks. This is used for ensuring
* that the blocks that are sent along the wire play nicely with the
* underlying transport.
*/
public interface BlockSplitter {
BlockSplitter NO_OP = (block, maxBlockSize) -> Iterators.singletonIterator(block);
+ BlockSplitter DEFAULT = new Default();
/**
* @return a list of blocks that was split from the original {@code block}
*/
- Iterator<TransferableBlock> split(TransferableBlock block, int maxBlockSize);
+ Iterator<? extends MseBlock.Data> split(MseBlock.Data block, int maxBlockSize);
+
+ /**
+ * Split a block into multiple block so that each block size is within maxBlockSize. Currently,
+ * <ul>
+ * <li>For row data block, we split for row type dataBlock.</li>
+ * <li>For columnar data block, exceptions are thrown.</li>
+ * <li>For metadata block, split is not supported.</li>
+ * </ul>
+ *
+ * @return a list of data block chunks
+ */
+ class Default implements BlockSplitter, MseBlock.Data.Visitor<Iterator<MseBlock.Data>, Integer> {
+ private static final int MEDIAN_COLUMN_SIZE_BYTES = 8;
+
+ private Default() {
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> split(MseBlock.Data block, int maxBlockSize) {
+ return block.accept(this, maxBlockSize);
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(RowHeapDataBlock block, Integer maxBlockSize) {
+ // Use estimated row size, this estimate is not accurate and is used to estimate numRowsPerChunk only.
+ DataSchema dataSchema = block.getDataSchema();
+ assert dataSchema != null;
+ int estimatedRowSizeInBytes = dataSchema.getColumnNames().length * MEDIAN_COLUMN_SIZE_BYTES;
+ int numRowsPerChunk = maxBlockSize / estimatedRowSizeInBytes;
+ Preconditions.checkState(numRowsPerChunk > 0, "row size too large for query engine to handle, abort!");
+
+ List<Object[]> rows = block.getRows();
+ int numRows = rows.size();
+ int numChunks = (numRows + numRowsPerChunk - 1) / numRowsPerChunk;
+ if (numChunks == 1) {
+ return Iterators.singletonIterator(block);
+ }
+ List<MseBlock.Data> blockChunks = new ArrayList<>(numChunks);
+ for (int fromIndex = 0; fromIndex < numRows; fromIndex += numRowsPerChunk) {
+ int toIndex = Math.min(fromIndex + numRowsPerChunk, numRows);
+ blockChunks.add(new RowHeapDataBlock(rows.subList(fromIndex, toIndex), dataSchema, block.getAggFunctions()));
+ }
+ return blockChunks.iterator();
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(SerializedDataBlock block, Integer maxBlockSize
+ ) {
+ if (block.getDataBlock().getDataBlockType() == DataBlock.Type.ROW) {
Review Comment:
Yes, I didn't find any usage of columnar mode in the current MSE code
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1991820057
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// As the day this comment was written, this class is used almost everytime we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
+ private final DataSchema _dataSchema;
+ private final List<Object[]> _rows;
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ private final AggregationFunction[] _aggFunctions;
+
Review Comment:
It'd be good to document _aggFunctions .
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "bziobrowski (via GitHub)" <gi...@apache.org>.
bziobrowski commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r1992028253
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/server/ServerPlanRequestVisitor.java:
##########
@@ -156,15 +156,15 @@ public Void visitJoin(JoinNode node, ServerPlanRequestContext context) {
if (visit(left, context)) {
PipelineBreakerResult pipelineBreakerResult = context.getPipelineBreakerResult();
int resultMapId = pipelineBreakerResult.getNodeIdMap().get(right);
- List<TransferableBlock> transferableBlocks =
- pipelineBreakerResult.getResultMap().getOrDefault(resultMapId, Collections.emptyList());
+ List<MseBlock> blocks = pipelineBreakerResult.getResultMap().getOrDefault(resultMapId, Collections.emptyList());
List<Object[]> resultDataContainer = new ArrayList<>();
DataSchema dataSchema = right.getDataSchema();
Review Comment:
Could this loop receive column-based block ?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "yashmayya (via GitHub)" <gi...@apache.org>.
yashmayya commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2016415044
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// At the time of writing, this class is used almost every time we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
Review Comment:
Doesn't `MseBlock.Data` itself extend `MseBlock`?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
Review Comment:
I think it might be useful to add a sentence or two on what "row heap" means here for more context.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can rely on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative to this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
Review Comment:
I'm not sure I follow the pattern of the two separate visitor types being used here and the interchange between them?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/SerializedDataBlock.java:
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.util.DataBlockExtractUtils;
+
+/// A block that contains data in serialized format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in serialized format.
+/// This is the most efficient way to store data, but it is also the hardest to work with.
+/// As the day this comment was written, this class is only used when we need to shuffle data through the network.
+/// In all other cases, we use [RowHeapDataBlock].
+public class SerializedDataBlock implements MseBlock.Data {
+ private final DataBlock _dataBlock;
+
+ /// Creates a new block with the given data block.
+ /// @param dataBlock The data block to store in this block. It cannot be a metadata block.
+ /// @throws IllegalArgumentException If the data block is a metadata block.
+ public SerializedDataBlock(DataBlock dataBlock) {
+ Preconditions.checkArgument(dataBlock.getDataBlockType() != DataBlock.Type.METADATA,
+ "SerializedDataBlock cannot be used to decorate metadata block");
+ _dataBlock = dataBlock;
+ }
+
+ /// Returns the data block stored in this block.
+ /// It is guaranteed that the returned data block is not a metadata block.
+ public DataBlock getDataBlock() {
+ return _dataBlock;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _dataBlock.getNumberOfRows();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataBlock.getDataSchema();
+ }
+
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ List<Object[]> rows = DataBlockExtractUtils.extractRows(_dataBlock);
+ return new RowHeapDataBlock(rows, _dataBlock.getDataSchema(), null);
Review Comment:
So the aggregation functions are only used for serializing from row heap format to serialized format and we don't need to worry about them here because we won't convert from serialized -> row heap -> serialized?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// At the time of writing, this class is used almost every time we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
+ private final DataSchema _dataSchema;
+ private final List<Object[]> _rows;
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ private final AggregationFunction[] _aggFunctions;
+
+ /// Creates a new block with the given rows and schema.
+ /// @param rows The rows in the block. Once received, the list should not be mutated from outside this class.
+ /// @param dataSchema The schema of the data in the block.
+ public RowHeapDataBlock(List<Object[]> rows, DataSchema dataSchema) {
+ this(rows, dataSchema, null);
+ }
+
+ /// Creates a new block with the given rows, schema and aggregation functions.
+ /// @param rows The rows in the block. Once received, the list should not be mutated from outside this class.
+ /// @param dataSchema The schema of the data in the block.
+ @SuppressWarnings("rawtypes")
+ public RowHeapDataBlock(List<Object[]> rows, DataSchema dataSchema,
+ @Nullable AggregationFunction[] aggFunctions) {
+ _dataSchema = dataSchema;
+ _rows = rows;
+ _aggFunctions = aggFunctions;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _rows.size();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataSchema;
+ }
+
+ /// Returns the rows in the block.
+ /// The returned list should be considered immutable.
+ public List<Object[]> getRows() {
+ return _rows;
+ }
+
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ public AggregationFunction[] getAggFunctions() {
+ return _aggFunctions;
+ }
+
+ /// Returns this same object.
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ return this;
+ }
+
+ @Override
+ public SerializedDataBlock asSerialized() {
+ try {
+ return new SerializedDataBlock(DataBlockBuilder.buildFromRows(_rows, _dataSchema, _aggFunctions));
+ } catch (IOException ex) {
+ throw new UncheckedIOException(ex);
+ }
+ }
+
+ @Override
+ public boolean isRowHeap() {
+ return true;
+ }
+
+ @Override
+ public <R, A> R accept(Data.Visitor<R, A> visitor, A arg) {
+ return visitor.visit(this, arg);
+ }
+
+ @Override
+ public String toString() {
+ return "{\"type\": \"rowHeap\", \"numRows\": " + getNumRows() + "}";
Review Comment:
Why does this need to be JSON?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can rely on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative to this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
Review Comment:
We're separating stats from `MseBlock` mainly because data blocks should not have stats?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/SendingMailbox.java:
##########
@@ -36,11 +38,19 @@ public interface SendingMailbox {
boolean isLocal();
/**
- * Sends a block to the receiver. Note that SendingMailbox are required to acquire resources lazily in this call, and
- * they should <b>not</b> acquire any resources when they are created. This method should throw if there was an error
- * sending the data, since that would allow {@link BlockExchange} to exit early.
+ * Sends a data block to the receiver. Note that SendingMailbox are required to acquire resources lazily in this call,
+ * and they should <b>not</b> acquire any resources when they are created. This method should throw if there was a
Review Comment:
nit: `an error` is the correct usage, not sure why this was changed to `a error`?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/QueryRunner.java:
##########
@@ -275,8 +276,12 @@ public void processQuery(WorkerMetadata workerMetadata, StagePlan stagePlan, Map
for (RoutingInfo routingInfo : routingInfos) {
try {
StatMap<MailboxSendOperator.StatKey> statMap = new StatMap<>(MailboxSendOperator.StatKey.class);
- _mailboxService.getSendingMailbox(routingInfo.getHostname(), routingInfo.getPort(),
- routingInfo.getMailboxId(), deadlineMs, statMap).send(errorBlock);
+ SendingMailbox sendingMailbox = _mailboxService.getSendingMailbox(routingInfo.getHostname(),
+ routingInfo.getPort(), routingInfo.getMailboxId(), deadlineMs, statMap);
+ // TODO: Here we are breaking the stats invariants, sending errors without including the stats of the
Review Comment:
Could we include here _why_ we are doing this and how the stats system handles pipeline breakers?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/GrpcSendingMailbox.java:
##########
@@ -68,9 +78,20 @@ public boolean isLocal() {
}
@Override
- public void send(TransferableBlock block)
+ public void send(MseBlock.Data data)
+ throws IOException, TimeoutException {
+ sendPrivate(data, List.of());
+ }
+
+ @Override
+ public void send(MseBlock.Eos block, List<DataBuffer> serializedStats)
+ throws IOException, TimeoutException {
+ sendPrivate(block, serializedStats);
+ }
+
+ private void sendPrivate(MseBlock block, List<DataBuffer> serializedStats)
Review Comment:
nit: I think we usually use `Internal` suffix instead of `Private` for such methods?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/BlockSplitter.java:
##########
@@ -18,20 +18,80 @@
*/
package org.apache.pinot.query.runtime.blocks;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import org.apache.pinot.common.datablock.DataBlock;
+import org.apache.pinot.common.utils.DataSchema;
/**
- * Interface for splitting transferable blocks. This is used for ensuring
+ * Interface for splitting MSE blocks. This is used for ensuring
* that the blocks that are sent along the wire play nicely with the
* underlying transport.
*/
public interface BlockSplitter {
BlockSplitter NO_OP = (block, maxBlockSize) -> Iterators.singletonIterator(block);
+ BlockSplitter DEFAULT = new Default();
/**
* @return a list of blocks that was split from the original {@code block}
*/
- Iterator<TransferableBlock> split(TransferableBlock block, int maxBlockSize);
+ Iterator<? extends MseBlock.Data> split(MseBlock.Data block, int maxBlockSize);
+
+ /**
+ * Split a block into multiple block so that each block size is within maxBlockSize. Currently,
+ * <ul>
+ * <li>For row data block, we split for row type dataBlock.</li>
+ * <li>For columnar data block, exceptions are thrown.</li>
+ * <li>For metadata block, split is not supported.</li>
+ * </ul>
+ *
+ * @return a list of data block chunks
+ */
+ class Default implements BlockSplitter, MseBlock.Data.Visitor<Iterator<MseBlock.Data>, Integer> {
+ private static final int MEDIAN_COLUMN_SIZE_BYTES = 8;
+
+ private Default() {
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> split(MseBlock.Data block, int maxBlockSize) {
+ return block.accept(this, maxBlockSize);
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(RowHeapDataBlock block, Integer maxBlockSize) {
+ // Use estimated row size, this estimate is not accurate and is used to estimate numRowsPerChunk only.
+ DataSchema dataSchema = block.getDataSchema();
+ assert dataSchema != null;
+ int estimatedRowSizeInBytes = dataSchema.getColumnNames().length * MEDIAN_COLUMN_SIZE_BYTES;
+ int numRowsPerChunk = maxBlockSize / estimatedRowSizeInBytes;
+ Preconditions.checkState(numRowsPerChunk > 0, "row size too large for query engine to handle, abort!");
+
+ List<Object[]> rows = block.getRows();
+ int numRows = rows.size();
+ int numChunks = (numRows + numRowsPerChunk - 1) / numRowsPerChunk;
+ if (numChunks == 1) {
+ return Iterators.singletonIterator(block);
+ }
+ List<MseBlock.Data> blockChunks = new ArrayList<>(numChunks);
+ for (int fromIndex = 0; fromIndex < numRows; fromIndex += numRowsPerChunk) {
+ int toIndex = Math.min(fromIndex + numRowsPerChunk, numRows);
+ blockChunks.add(new RowHeapDataBlock(rows.subList(fromIndex, toIndex), dataSchema, block.getAggFunctions()));
+ }
+ return blockChunks.iterator();
+ }
+
+ @Override
+ public Iterator<MseBlock.Data> visit(SerializedDataBlock block, Integer maxBlockSize
+ ) {
+ if (block.getDataBlock().getDataBlockType() == DataBlock.Type.ROW) {
Review Comment:
Are columnar blocks essentially irrelevant?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/MultiStageOperator.java:
##########
@@ -122,24 +123,37 @@ protected void earlyTerminate() {
}
}
+ @Override
+ public abstract List<MultiStageOperator> getChildOperators();
+
/**
- * Adds the current operator stats as the last operator in the open stats of the given holder.
+ * Calculates and returns the stats for the operator.
*
- * It is assumed that:
- * <ol>
- * <li>The current stage of the holder is equal to the stage id of this operator.</li>
- * <li>The holder already contains the stats of the previous operators of the same stage in inorder</li>
- * </ol>
+ * Each time this method is called, a new instance of the stats is created. This is because the stats are mutable and
+ * can be updated by the operator or the caller after the stats are returned.
*/
- protected void addStats(MultiStageQueryStats holder, StatMap<?> statMap) {
- Preconditions.checkArgument(holder.getCurrentStageId() == _context.getStageId(),
+ public final MultiStageQueryStats calculateStats() {
+ MultiStageQueryStats upstreamStats = calculateUpstreamStats();
+
+ Preconditions.checkArgument(upstreamStats.getCurrentStageId() == _context.getStageId(),
"The holder's stage id should be the same as the current operator's stage id. Expected %s, got %s",
- _context.getStageId(), holder.getCurrentStageId());
- holder.getCurrentStats().addLastOperator(getOperatorType(), statMap);
+ _context.getStageId(), upstreamStats.getCurrentStageId());
+ upstreamStats.getCurrentStats().addLastOperator(getOperatorType(), copyStatMaps());
+ return upstreamStats;
}
- @Override
- public abstract List<MultiStageOperator> getChildOperators();
+ protected MultiStageQueryStats calculateUpstreamStats() {
Review Comment:
I think a comment explaining the merging logic here might be useful
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// As the day this comment was written, this class is used almost everytime we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
+ private final DataSchema _dataSchema;
+ private final List<Object[]> _rows;
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ private final AggregationFunction[] _aggFunctions;
+
Review Comment:
Yeah +1, the presence of these aggregation functions here is pretty confusing.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz merged PR #15245:
URL: https://github.com/apache/pinot/pull/15245
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2024212697
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can rely on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative to this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
Review Comment:
A MseBlock.Data.Visitor can only visit blocks that implement MseBlock.Data. A MseBlock.Visitor can visit both.
I decided to implement that by making MseBlock.Visitor _a_ MseBlock.Data.Visitor. This means we need to have both accept(MseBlock.Visitor) and accept(MseBlock.Data.Visitor). But the first can be defined by default as calling the second, given a MseBlock.Visitor is always a MseBlock.Data.Visitor. This cast is always safe but is required to tell the compiler to call the method that accepts MseBlock.Data.Visitor, Otherwise, it would create an infinite recursion
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2024203526
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/RowHeapDataBlock.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.datablock.DataBlockBuilder;
+import org.apache.pinot.core.query.aggregation.function.AggregationFunction;
+
+/// A block that contains data in row heap format.
+///
+/// This class is a subclass of [MseBlock.Data] and is used to store data in row heap format.
+/// This is probably the less efficient way to store data, but it is also the easiest to work with.
+/// At the time of writing, this class is used almost every time we need to read or create data blocks.
+/// The only place where this class is not used is when we need to shuffle data through the network, in which case
+/// we use [SerializedDataBlock].
+public class RowHeapDataBlock implements MseBlock, MseBlock.Data {
+ private final DataSchema _dataSchema;
+ private final List<Object[]> _rows;
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ private final AggregationFunction[] _aggFunctions;
+
+ /// Creates a new block with the given rows and schema.
+ /// @param rows The rows in the block. Once received, the list should not be mutated from outside this class.
+ /// @param dataSchema The schema of the data in the block.
+ public RowHeapDataBlock(List<Object[]> rows, DataSchema dataSchema) {
+ this(rows, dataSchema, null);
+ }
+
+ /// Creates a new block with the given rows, schema and aggregation functions.
+ /// @param rows The rows in the block. Once received, the list should not be mutated from outside this class.
+ /// @param dataSchema The schema of the data in the block.
+ @SuppressWarnings("rawtypes")
+ public RowHeapDataBlock(List<Object[]> rows, DataSchema dataSchema,
+ @Nullable AggregationFunction[] aggFunctions) {
+ _dataSchema = dataSchema;
+ _rows = rows;
+ _aggFunctions = aggFunctions;
+ }
+
+ @Override
+ public int getNumRows() {
+ return _rows.size();
+ }
+
+ @Override
+ public DataSchema getDataSchema() {
+ return _dataSchema;
+ }
+
+ /// Returns the rows in the block.
+ /// The returned list should be considered immutable.
+ public List<Object[]> getRows() {
+ return _rows;
+ }
+
+ @Nullable
+ @SuppressWarnings("rawtypes")
+ public AggregationFunction[] getAggFunctions() {
+ return _aggFunctions;
+ }
+
+ /// Returns this same object.
+ @Override
+ public RowHeapDataBlock asRowHeap() {
+ return this;
+ }
+
+ @Override
+ public SerializedDataBlock asSerialized() {
+ try {
+ return new SerializedDataBlock(DataBlockBuilder.buildFromRows(_rows, _dataSchema, _aggFunctions));
+ } catch (IOException ex) {
+ throw new UncheckedIOException(ex);
+ }
+ }
+
+ @Override
+ public boolean isRowHeap() {
+ return true;
+ }
+
+ @Override
+ public <R, A> R accept(Data.Visitor<R, A> visitor, A arg) {
+ return visitor.visit(this, arg);
+ }
+
+ @Override
+ public String toString() {
+ return "{\"type\": \"rowHeap\", \"numRows\": " + getNumRows() + "}";
Review Comment:
This doesn't have to be JSON. It is just convenient to be a JSON. But contrary to the default toString generated by Intellij, JSONs are easier to parse in case we need to do so. And in the case of blocks, it is very easy to return a JSON (in cases where they contain strings, it is more expensive, given we need to escape strings).
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2005240477
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can relay on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative of this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
+
+ /// A visitor for [Data] blocks.
+ /// @param <R> The return type of the visitor. Use [Void] if the visitor does not return anything.
+ /// @param <A> The argument type of the visitor. Use [Void] if the visitor does not take any arguments.
+ interface Visitor<R, A> {
+ R visit(RowHeapDataBlock block, A arg);
+ R visit(SerializedDataBlock block, A arg);
+ }
+ }
+
+ /// A block that signals the end of a stream.
+ /// These blocks can be conceptually divided into successful and error blocks.
+ /// Both types of blocks may carry execution statistics and error blocks always carry error messages.
+ interface Eos extends MseBlock {
+ @Override
+ default boolean isData() {
Review Comment:
What do you mean?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "albertobastos (via GitHub)" <gi...@apache.org>.
albertobastos commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2003024664
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/MultiStageQueryStats.java:
##########
@@ -95,32 +90,25 @@ private MultiStageQueryStats(int stageId) {
_closedStats = new ArrayList<>();
}
- private static MultiStageQueryStats create(int stageId, MultiStageOperator.Type type, @Nullable StatMap<?> opStats) {
- MultiStageQueryStats multiStageQueryStats = new MultiStageQueryStats(stageId);
- multiStageQueryStats.getCurrentStats().addLastOperator(type, opStats);
- return multiStageQueryStats;
+ private MultiStageQueryStats(MultiStageQueryStats other) {
+ _currentStageId = other._currentStageId;
+ _currentStats = StageStats.Open.copy(other._currentStats);
+ _closedStats = new ArrayList<>(other._closedStats.size());
+ for (StageStats.Closed closed : other._closedStats) {
+ if (closed == null) {
Review Comment:
Very opinionated.
If you change `StageStats.Closed.copy` method so `copy(null) == null`, you can get rid of this _if-else_ statement. Personally I'd find it more readable.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/mailbox/InMemorySendingMailbox.java:
##########
@@ -54,17 +58,28 @@ public boolean isLocal() {
}
@Override
- public void send(TransferableBlock block)
+ public void send(MseBlock.Data data)
+ throws IOException, TimeoutException {
+ sendPrivate(data, Collections.emptyList());
Review Comment:
Just curious, in some places you rely on `Collections.emptyList()` but in others you opt for `List.of()`. Any particular reason for that?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/pipeline/PipelineBreakerOperator.java:
##########
@@ -42,15 +42,13 @@ public class PipelineBreakerOperator extends MultiStageOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(PipelineBreakerOperator.class);
private static final String EXPLAIN_NAME = "PIPELINE_BREAKER";
- private final Map<Integer, Operator<TransferableBlock>> _workerMap;
+ private final Map<Integer, MultiStageOperator> _workerMap;
- private Map<Integer, List<TransferableBlock>> _resultMap;
- private TransferableBlock _errorBlock;
- @Nullable
- private MultiStageQueryStats _queryStats = null;
+ private Map<Integer, List<MseBlock>> _resultMap;
+ private ErrorMseBlock _errorBlock;
private final StatMap<StatKey> _statMap = new StatMap<>(StatKey.class);
- public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, Operator<TransferableBlock>> workerMap) {
+ public PipelineBreakerOperator(OpChainExecutionContext context, Map<Integer, MultiStageOperator> workerMap) {
Review Comment:
Unrelated to this PR, but I miss some Javadoc explaining what this is. From the `getNextBlock()` method I'm assuming it is _just_ a sync merger for all worker blocks, right?
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/blocks/MseBlock.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.blocks;
+
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.core.common.Block;
+
+
+/// Blocks used by [MultiStageOperator][org.apache.pinot.query.runtime.operator.MultiStageOperator] to share
+/// information.
+///
+/// Blocks always go from upstream (the children of the operator) to downstream (the parent of the operator) and can be
+/// classified in the following categories:
+/// - [Data] blocks: contain data that can be processed by the operator.
+/// - [Eos] blocks: signal the end of a stream. These blocks can be either [successful][SuccessMseBlock] or
+/// [error][ErrorMseBlock].
+///
+/// ## The MseBlock API
+/// A MseBlock itself is not very useful, as they have almost no methods.
+/// Instead, they are used as a common sub-interface for [data][Data] and [end-of-stream][Eos] blocks,
+/// which are then subclassed to provide the actual functionality.
+/// This pattern follows the principles of Java 17 sealed interfaces and the intention is implement them as such once
+/// Pinot source code is migrated to Java 17 or newer, specially in Java 21 where pattern matching can also be used,
+/// removing the need for the [Visitor] pattern.
+///
+/// Meanwhile, the API force callers to do some castings, but it is a trade-off to have a more robust and maintainable
+/// codebase given that we can relay on Java typesystem to verify some important properties at compile time instead of
+/// adding runtime checks.
+///
+/// The alternative of this pattern would be to have a single class with all methods, adding runtime checks to verify
+/// whether it is acceptable to call a method or not. This is the approach that was used in the removed
+/// TransferableBlock class, which was used for all possible block type combinations. As a result each method
+/// had to include a runtime check to verify if it was legal to call it given some conditions imposed by its attributes.
+/// This approach was error-prone and hard to maintain, as it was easy to forget to add a check in a new method or to
+/// know which methods could be called at a given point in time.
+///
+/// ## MseBlock vs DataBlock
+/// MseBlock are conceptually close to [DataBlocks][org.apache.pinot.common.datablock.DataBlock].
+/// MseBlocks are sent from one operator to another while DataBlocks are a way to codify data. It is important to notice
+/// that MseBlocks don't store stats, while DataBlocks do.
+///
+/// When a MseBlock needs to be sent to another server, it will serialize it into a DataBlock. Then, when a DataBlock
+/// is received by another server, it will deserialize it into a MseBlock (plus stats if needed). This is done by
+/// [GrpcSendingMailbox][org.apache.pinot.query.mailbox.GrpcSendingMailbox] and
+/// [ReceivingMailbox][org.apache.pinot.query.mailbox.ReceivingMailbox].
+public interface MseBlock extends Block {
+ /// Whether the block is a [Data] block or otherwise an [Eos] block.
+ boolean isData();
+
+ /// Whether the block is an [Eos] block or otherwise a [Data] block.
+ default boolean isEos() {
+ return !isData();
+ }
+
+ /// Whether the block is an [Eos] that signals the end of a stream with no errors.
+ boolean isSuccess();
+
+ /// Whether the block is an [Eos] that signals the end of a stream with one or more errors.
+ boolean isError();
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ /// A block that contains data.
+ /// These blocks can store data as [rows on heap][RowHeapDataBlock] or as
+ /// [DataBlocks][SerializedDataBlock].
+ interface Data extends MseBlock {
+ /// Returns the number of rows in the block.
+ int getNumRows();
+
+ /// Returns the schema of the data in the block.
+ DataSchema getDataSchema();
+
+ /// Returns the data in the block as a [RowHeapDataBlock].
+ /// This is a no-op if the block is already a [RowHeapDataBlock]} but is an CPU and memory intensive operation
+ /// if the block is a [SerializedDataBlock].
+ RowHeapDataBlock asRowHeap();
+ /// Returns the data in the block as a [SerializedDataBlock].
+ /// This is a no-op if the block is already a [SerializedDataBlock] but is a CPU and memory intensive operation
+ /// if the block is a [RowHeapDataBlock].
+ /// @throws java.io.UncheckedIOException if the block cannot be serialized.
+ SerializedDataBlock asSerialized();
+
+ /// Returns whether the block is a [RowHeapDataBlock].
+ boolean isRowHeap();
+ /// Returns whether the block is a [SerializedDataBlock].
+ default boolean isSerialized() {
+ return !isRowHeap();
+ }
+
+ @Override
+ default boolean isData() {
+ return true;
+ }
+
+ @Override
+ default boolean isSuccess() {
+ return false;
+ }
+
+ @Override
+ default boolean isError() {
+ return false;
+ }
+
+ <R, A> R accept(Visitor<R, A> visitor, A arg);
+
+ @Override
+ default <R, A> R accept(MseBlock.Visitor<R, A> visitor, A arg) {
+ return accept((MseBlock.Data.Visitor<R, A>) visitor, arg);
+ }
+
+ /// A visitor for [Data] blocks.
+ /// @param <R> The return type of the visitor. Use [Void] if the visitor does not return anything.
+ /// @param <A> The argument type of the visitor. Use [Void] if the visitor does not take any arguments.
+ interface Visitor<R, A> {
+ R visit(RowHeapDataBlock block, A arg);
+ R visit(SerializedDataBlock block, A arg);
+ }
+ }
+
+ /// A block that signals the end of a stream.
+ /// These blocks can be conceptually divided into successful and error blocks.
+ /// Both types of blocks may carry execution statistics and error blocks always carry error messages.
+ interface Eos extends MseBlock {
+ @Override
+ default boolean isData() {
Review Comment:
Missing comment header?
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/MailboxServiceTest.java:
##########
@@ -610,18 +604,32 @@ public void testRemoteEarlyTerminated()
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// receiving-side early terminates after pulling the first block
TestUtils.waitForCondition(aVoid -> {
- TransferableBlock block = receivingMailbox.poll();
- return block != null && block.getNumRows() == 1;
+ MseBlock block = readBlock(receivingMailbox);
+ return block != null && block.isData() && ((MseBlock.Data) block).getNumRows() == 1;
}, 1000L, "Failed to deliver mails");
receivingMailbox.earlyTerminate();
// send another block b/c it doesn't guarantee the next block must be EOS
sendingMailbox.send(OperatorTestUtil.block(DATA_SCHEMA, new Object[]{0}));
// send a metadata block
- sendingMailbox.send(TransferableBlockTestUtils.getEndOfStreamTransferableBlock(SENDER_STAGE_ID));
+ sendingMailbox.send(SuccessMseBlock.INSTANCE, MultiStageQueryStats.emptyStats(SENDER_STAGE_ID).serialize());
sendingMailbox.complete();
// sending side should early terminate
TestUtils.waitForCondition(aVoid -> sendingMailbox.isEarlyTerminated(), 1000L, "Failed to early-terminate sender");
}
+
+ private static List<Object[]> getRows(ReceivingMailbox receivingMailbox) {
+ ReceivingMailbox.MseBlockWithStats block = receivingMailbox.poll();
+ assertNotNull(block);
+ assertTrue(block.getBlock().isData());
+ List<Object[]> rows = ((MseBlock.Data) block).asRowHeap().getRows();
+ return rows;
+ }
+
+ public static MseBlock readBlock(ReceivingMailbox receivingMailbox) {
+ ReceivingMailbox.MseBlockWithStats block = receivingMailbox.poll();
+ assertNotNull(block);
+ return block.getBlock();
Review Comment:
All usages of this method except the one at `testRemoteEarlyTerminated` immediately asserts that `block.getBlock()` is not null. I would move that assertion here and maybe stop using this method from that single test.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Substitute TransferableBlock with MseBlock [pinot]
Posted by "gortiz (via GitHub)" <gi...@apache.org>.
gortiz commented on code in PR #15245:
URL: https://github.com/apache/pinot/pull/15245#discussion_r2032829964
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/QueryRunner.java:
##########
@@ -275,8 +276,12 @@ public void processQuery(WorkerMetadata workerMetadata, StagePlan stagePlan, Map
for (RoutingInfo routingInfo : routingInfos) {
try {
StatMap<MailboxSendOperator.StatKey> statMap = new StatMap<>(MailboxSendOperator.StatKey.class);
- _mailboxService.getSendingMailbox(routingInfo.getHostname(), routingInfo.getPort(),
- routingInfo.getMailboxId(), deadlineMs, statMap).send(errorBlock);
+ SendingMailbox sendingMailbox = _mailboxService.getSendingMailbox(routingInfo.getHostname(),
+ routingInfo.getPort(), routingInfo.getMailboxId(), deadlineMs, statMap);
+ // TODO: Here we are breaking the stats invariants, sending errors without including the stats of the
Review Comment:
Precisely the reason to add this TODO is because it is not clear how to handle this case :laughing:
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org