Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix HashBucketAssigner load index too large error with refactor exception #3796

Merged
merged 8 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ public void put(int key, short value) {
}

public Int2ShortHashMap build() {
Int2ShortHashMap map = new Int2ShortHashMap(keyList.size());
for (int i = 0; i < keyList.size(); i++) {
map.put(keyList.getInt(i), valueList.getShort(i));
Int2ShortHashMap map;
try {
map = new Int2ShortHashMap(keyList.size());
for (int i = 0; i < keyList.size(); i++) {
map.put(keyList.getInt(i), valueList.getShort(i));
}
} catch (IllegalArgumentException e) {
throw new RuntimeException(
"capacity of Int2ShortOpenHashMap is too large, advise raise your parallelism in your Flink/Spark job",
e);
}
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Random;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

/** Test for {@link Int2ShortHashMap}. */
public class Int2ShortHashMapTest {
Expand Down Expand Up @@ -53,4 +54,9 @@ public void testRandom() {
assertThat(map.get(k)).isEqualTo(v);
});
}

@Test
public void testCapacity() {
assertThrows(RuntimeException.class, () -> new Int2ShortHashMap(1073741824));
}
}
Loading