KAILINYmq commented on code in PR #9733:
URL: https://github.com/apache/seatunnel/pull/9733#discussion_r2297002552


##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/service/JobInfoService.java:
##########
@@ -93,7 +94,7 @@ public JsonArray getJobsByStateJson(String state) {
 
         SeaTunnelServer seaTunnelServer = getSeaTunnelServer(true);
 
-        return finishedJob.values().stream()
+        return finishedJob.values().parallelStream()

Review Comment:
   I simulated a parsing process for 100 tasks, and the query performance will 
be greatly improved. This modification is helpful for our deployment of 
SEATUNEL query performance in Pro.
   
   <img width="428" height="581" alt="image" 
src="https://github.com/user-attachments/assets/c671e6b2-1167-4c4f-973c-e3f3f673fa33";
 />
   
   ```
   class JobInfoServiceTest {
   
       @RepeatedTest(10)
       void getJobInfoJsonStream() {
           JsonArray jsonArray = new JsonArray();
           JsonObject jsonObject1 = new JsonObject();
           jsonObject1.add("name", "1");
           jsonObject1.add("key", "2");
           for (int i = 0; i < 100; i++) {
               jsonArray.add(jsonObject1);
           }
   
           JsonArray collect = jsonArray.values().stream().map(json -> {
               JsonObject jsonNew = new JsonObject();
               try {
                   TimeUnit.MILLISECONDS.sleep(100);
               } catch (InterruptedException e) {
               }
               jsonNew.add("name", ((JsonObject) json).get("name"));
               jsonNew.add("key", ((JsonObject) json).get("key"));
               return jsonNew;
           }).collect(JsonArray::new, JsonArray::add, JsonArray::add);
   
           System.out.println(collect);
       }
   
   
   
       @RepeatedTest(10)
       void getJobInfoJsonParallelStream() {
           JsonArray jsonArray = new JsonArray();
           JsonObject jsonObject1 = new JsonObject();
           jsonObject1.add("name", "1");
           jsonObject1.add("key", "2");
           for (int i = 0; i < 100; i++) {
               jsonArray.add(jsonObject1);
           }
   
           JsonArray collect = jsonArray.values().parallelStream().map(json -> {
               JsonObject jsonNew = new JsonObject();
                       try {
                           TimeUnit.MILLISECONDS.sleep(100);
                       } catch (InterruptedException e) {
                       }
                       jsonNew.add("name", ((JsonObject) json).get("name"));
               return jsonNew;})
                   .collect(Collectors.toList()).stream()
                   .collect(JsonArray::new, JsonArray::add, JsonArray::add);
   
           System.out.println(collect);
       }
   }
   ```



-- 
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