llama90 commented on code in PR #42029:
URL: https://github.com/apache/arrow/pull/42029#discussion_r1633208511


##########
java/algorithm/src/test/java/org/apache/arrow/algorithm/search/TestParallelSearcher.java:
##########
@@ -48,45 +46,39 @@ private enum ComparatorType {
 
   private static final int VECTOR_LENGTH = 10000;
 
-  private final int threadCount;
-
   private BufferAllocator allocator;
 
   private ExecutorService threadPool;
 
-  private final ComparatorType comparatorType;
-
-  public TestParallelSearcher(ComparatorType comparatorType, int threadCount) {
-    this.comparatorType = comparatorType;
-    this.threadCount = threadCount;
-  }
-
-  @Parameterized.Parameters(name = "comparator type = {0}, thread count = {1}")
-  public static Collection<Object[]> getComparatorName() {
-    List<Object[]> params = new ArrayList<>();
+  public static Stream<Arguments> getComparatorName() {
+    List<Arguments> params = new ArrayList<>();
     int[] threadCounts = {1, 2, 5, 10, 20, 50};
     for (ComparatorType type : ComparatorType.values()) {
       for (int count : threadCounts) {
-        params.add(new Object[] {type, count});
+        params.add(Arguments.of(type, count));
       }
     }
-    return params;
+    return params.stream();
   }
 
-  @Before
+  @BeforeEach
   public void prepare() {
     allocator = new RootAllocator(1024 * 1024);
-    threadPool = Executors.newFixedThreadPool(threadCount);
   }
 
-  @After
+  @AfterEach
   public void shutdown() {
     allocator.close();
-    threadPool.shutdown();
+    if (threadPool != null) {
+      threadPool.shutdown();
+    }
   }
 
-  @Test
-  public void testParallelIntSearch() throws ExecutionException, 
InterruptedException {
+  @ParameterizedTest
+  @MethodSource("getComparatorName")
+  public void testParallelIntSearch(ComparatorType comparatorType, int 
threadCount)
+      throws ExecutionException, InterruptedException {
+    threadPool = Executors.newFixedThreadPool(threadCount);

Review Comment:
   @vibhatha I think it is similar to `initializeDatabase` in 
[PR](https://github.com/apache/arrow/pull/42038).
   
   ### JUnit 4 Case
   
   `constructor(int threadCount)` -> `@Before` -> `@Test`
   
   - The `threadCount` is changed in the constructor.
   
   ### JUnit 5 Case
   
   `@BeforeEach` -> `@ParameterizedTest`
   
   - The `threadCount` changed when calling the test.
   
   That's why I initialized `threadPool` like `initializeDatabase`.
   
   We need to consider the sequence of function calls to ensure that the 
`threadCount` is correctly set before initializing the `threadPool`.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to