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 6 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,10 +67,18 @@ 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 PaimonUtilsException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just throw runtime exception is OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK,had change exception to RumtimeException. @JingsongLi

"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
@@ -0,0 +1,30 @@
/*
* 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.paimon.utils;

/**
* A {@code PaimonUtilsException} is thrown when occur exception during using with paimon utils,
* such as too large initial capacity when build Int2ShortHashMap and so on.
*/
public class PaimonUtilsException extends RuntimeException {

public PaimonUtilsException(String message, Throwable e) {
super(message, e);
}
}
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(IllegalArgumentException.class, () -> new Int2ShortHashMap(1073741824));
}
}