Copilot commented on code in PR #719:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/719#discussion_r2969318701


##########
hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/FileUploadController.java:
##########
@@ -277,12 +277,12 @@ private void checkFileValid(int connId, int jobId, 
JobManager jobEntity,
 
         long totalFileSizeLimit = this.config.get(
                 HubbleOptions.UPLOAD_TOTAL_FILE_SIZE_LIMIT);
-        List<FileMapping> fileMappings = this.service.listAll();
+        List<FileMapping> fileMappings = this.service.listByConnId(connId);
         long currentTotalSize = fileMappings.stream()
                                             .map(FileMapping::getTotalSize)
                                             .reduce(0L, (Long::sum));

Review Comment:
   `currentTotalSize` is calculated by loading every `FileMapping` for the 
connection into memory and then reducing with boxed `Long`s. For large numbers 
of mappings this is unnecessarily expensive on every upload request. Consider 
using a DB-side `SUM(total_size)` aggregate (or at least 
`mapToLong(...).sum()`) to avoid allocating and iterating over full entities.
   ```suggestion
                                               
.mapToLong(FileMapping::getTotalSize)
                                               .sum();
   ```



##########
hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/controller/load/FileUploadController.java:
##########
@@ -277,12 +277,12 @@ private void checkFileValid(int connId, int jobId, 
JobManager jobEntity,
 
         long totalFileSizeLimit = this.config.get(
                 HubbleOptions.UPLOAD_TOTAL_FILE_SIZE_LIMIT);
-        List<FileMapping> fileMappings = this.service.listAll();
+        List<FileMapping> fileMappings = this.service.listByConnId(connId);
         long currentTotalSize = fileMappings.stream()
                                             .map(FileMapping::getTotalSize)
                                             .reduce(0L, (Long::sum));
         Ex.check(fileSize + currentTotalSize <= totalFileSizeLimit,
-                 "load.upload.file.exceed-single-size",
+                 "load.upload.file.exceed-total-size",
                  FileUtils.byteCountToDisplaySize(totalFileSizeLimit));

Review Comment:
   The total upload limit is now computed by summing `total_size` across *all* 
`FileMapping` records for the connection. Since completed mappings are 
persisted (and `totalSize` is set on completion), this quota becomes cumulative 
across jobs and won’t “reset” when a new job is created, which seems to be the 
core problem described in #496. Consider scoping the sum to the current job 
(`conn_id` + `job_id`), or using `jobEntity.getJobSize()` (which is already 
maintained on upload/delete) so the limit is enforced per job and naturally 
resets between jobs.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to