luis4a0 commented on code in PR #12114:
URL: https://github.com/apache/gluten/pull/12114#discussion_r3265097747


##########
gluten-arrow/src/main/java/org/apache/gluten/vectorized/GlutenSplitResult.java:
##########
@@ -122,4 +139,32 @@ public double getAvgDictionaryFields() {
   public long getDictionarySize() {
     return dictionarySize;
   }
+
+  /**
+   * Backend-specific shuffle writer metrics, keyed by 
`<Backend>.<Family>.<Stat>`. The map
+   * preserves the iteration order JNI marshalled, but callers should treat 
the map as unordered.
+   * Returns an empty map if the native side did not populate any custom 
metrics (e.g. older Gluten
+   * libs, or backends that don't yet emit any). The returned map is 
unmodifiable.
+   */
+  public Map<String, Long> getCustomMetrics() {
+    Map<String, Long> cached = customMetricsCache;
+    if (cached != null) {
+      return cached;
+    }
+    synchronized (this) {
+      if (customMetricsCache != null) {
+        return customMetricsCache;
+      }
+      if (customMetricsKeys == null || customMetricsKeys.length == 0) {

Review Comment:
   Excellent point. Fixed in 722fa45. Added an explicit length-match check at 
the top of the synchronized block that throws `IllegalStateException` 
mentioning both lengths (and the case where values is null while keys is 
non-empty), so the producer-side bug is unambiguous and the cache field never 
gets assigned to a partial map. Two new `GlutenSplitResultSuite` cases:
   
   - `fails loudly on mismatched key/value array lengths` — also asserts the 
second call still throws (the cache field stays null on the failure path)
   - `fails loudly when values array is null but keys is non-empty`
   
   Both pass locally; full suite is now 8/8.



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