-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BugFix] Fix Java UDAF OOM when spill
In past implementations, Function States would not be released. For sorted streaming agg or spill aggregates, they will not be released even if destroy is called. This PR adds a remove state interface to Function States. After calling destroy, it will call function states-> remove. Signed-off-by: stdpain <[email protected]>
- Loading branch information
Showing
10 changed files
with
270 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
java-extensions/udf-extensions/src/test/java/com/starrocks/udf/FunctionStatesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// Licensed 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 | ||
// | ||
// https://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 com.starrocks.udf; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class FunctionStatesTest { | ||
private static class State { | ||
|
||
} | ||
// Test Agg batch Call Single | ||
@Test | ||
public void testAddFunctionStates() throws Exception { | ||
FunctionStates<State> states = new FunctionStates<>(); | ||
List<Integer> lst = new ArrayList<>(); | ||
for (int i = 0; i < 4096; i++) { | ||
lst.add(states.add(new State())); | ||
} | ||
for (int j = 0; j < 100; j++) { | ||
for (int i = 0; i < 4095; i++) { | ||
states.remove(lst.get(i)); | ||
} | ||
lst.clear(); | ||
for (int i = 0; i < 4095; i++) { | ||
lst.add(states.add(new State())); | ||
} | ||
} | ||
|
||
Assert.assertEquals(states.size(), 8191); | ||
} | ||
} |
Oops, something went wrong.