Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/18231#discussion_r120767926
--- Diff:
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockHandler.java
---
@@ -209,4 +190,47 @@ private ShuffleMetrics() {
}
}
+ private class ManagedBufferIterator implements Iterator<ManagedBuffer> {
+
+ private int index = 0;
+ private String appId;
+ private String execId;
+ private String shuffleId;
+ // mapId and reduceId are stored as bytes to save memory.
+ private byte[][] mapIdAndReduceIds;
+
+ ManagedBufferIterator(String appId, String execId, String[] blockIds) {
+ this.appId = appId;
+ this.execId = execId;
+ String blockId = blockIds[0];
+ String[] blockIdParts = blockId.split("_");
+ if (blockIdParts.length < 4) {
+ throw new IllegalArgumentException("Unexpected block id format: "
+ blockId);
+ } else if (!blockIdParts[0].equals("shuffle")) {
+ throw new IllegalArgumentException("Expected shuffle block id,
got: " + blockId);
+ }
+ this.shuffleId = blockIdParts[1];
+ mapIdAndReduceIds = new byte[blockIds.length][];
+ if (blockIds.length > 0) {
+ for (int i = 0; i< blockIds.length; i++) {
+ mapIdAndReduceIds[i] = (blockIdParts[2] + "_" +
blockIdParts[3]).getBytes();
--- End diff --
Instead of storing this as a byte array, how about storing them as ints or
longs (depending on what's the actual data type of the id)?
e.g., instead of:
```
private byte[][] mapIdAndReduceIds;
```
Which results in `blockIds.length + 1` arrays in total, you could have a
single one where for each block id you have two entries, one for map id and one
for reduce id, or something along those lines.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]