leaves12138 commented on code in PR #129:
URL: 
https://github.com/apache/paimon-vector-index/pull/129#discussion_r4584456942


##########
java/src/main/java/org/apache/paimon/index/vector/VectorRangeSearchParams.java:
##########
@@ -79,17 +87,23 @@ public static VectorRangeSearchParams 
diskAnn(VectorDistanceBand band, int start
     }
 
     public final VectorRangeSearchParams withInitialSlack(float value) {
-        return new VectorRangeSearchParams(band, searchWidth, width, value, 
rangeSlack, maxWorkingBytes, exhaustive);
+        return new VectorRangeSearchParams(band, searchWidth, width, value, 
rangeSlack, maxWorkingBytes, exhaustive, maxResultBytes);
     }
     public final VectorRangeSearchParams withRangeSlack(float value) {
-        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, value, maxWorkingBytes, exhaustive);
+        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, value, maxWorkingBytes, exhaustive, maxResultBytes);
     }
     public final VectorRangeSearchParams withMaxWorkingBytes(long value) {
-        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, rangeSlack, value, exhaustive);
+        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, rangeSlack, value, exhaustive, maxResultBytes);
     }
     public final VectorRangeSearchParams withExhaustive(boolean value) {
-        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, rangeSlack, maxWorkingBytes, value);
+        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, rangeSlack, maxWorkingBytes, value, maxResultBytes);
+    }
+
+    /** Bounds live native result buffers per call, including CSR conversion. 
*/
+    public final VectorRangeSearchParams withMaxResultBytes(long value) {
+        return new VectorRangeSearchParams(band, searchWidth, width, 
initialSlack, rangeSlack, maxWorkingBytes, exhaustive, value);

Review Comment:
   [P2] Reject JNI libraries that cannot enforce the result budget
   
   When these Java classes load a pre-PR JNI library through the supported 
native-path override, the existing materialized range entry points never check 
for the new result-budget capability. The older JNI parser ignores the new 
getter, so the budget is silently unenforced: with the previous JNI build, I 
reproduced supportsRangeSearch() == true and rangeSearch(..., 
params.withMaxResultBytes(1)) successfully returning 256 hits (3,072 bytes of 
label/distance payload alone); the same probe against this PR's JNI correctly 
fails with max_result_bytes exceeded. This also defeats the new default 64 MiB 
protection for mixed-version deployments and can leave broad queries unbounded. 
Please add a Java/JNI result-capability handshake before accepting materialized 
range calls, rejecting incompatible native libraries as the C++/Python bindings 
already do, and cover this configuration with a regression test.



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