nfsantos commented on code in PR #1353:
URL: https://github.com/apache/jackrabbit-oak/pull/1353#discussion_r1517380764


##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextDocumentMaker.java:
##########
@@ -336,6 +338,32 @@ private boolean indexProperty(String path,
         return dirty;
     }
 
+    private String getValueAsTruncatedString(Object val) {
+        String value = val.toString();
+        return value.length() <= 128 ? value
+            : value.substring(0, 128) + " ... [" + value.hashCode() + "]";

Review Comment:
   This is going to fail with StringIndexOutOfBoundsException if the value is 
smaller than 128.



##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextDocumentMaker.java:
##########
@@ -336,6 +338,32 @@ private boolean indexProperty(String path,
         return dirty;
     }
 
+    private String getValueAsTruncatedString(Object val) {
+        String value = val.toString();
+        return value.length() <= 128 ? value
+            : value.substring(0, 128) + " ... [" + value.hashCode() + "]";

Review Comment:
   Do not add the three dots if the value is printed in full, add it only if 
the value is truncated.



##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextDocumentMaker.java:
##########
@@ -336,6 +338,32 @@ private boolean indexProperty(String path,
         return dirty;
     }
 
+    private String getValueAsTruncatedString(Object val) {
+        String value = val.toString();
+        return value.length() <= 128 ? value
+            : value.substring(0, 128) + " ... [" + value.hashCode() + "]";

Review Comment:
   Extract the cutoff size for logging into a constant, that avoids hardcoding 
in multiple places the same numeric value and the constant name works as 
documentation.



##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextDocumentMaker.java:
##########
@@ -336,6 +338,32 @@ private boolean indexProperty(String path,
         return dirty;
     }
 
+    private String getValueAsTruncatedString(Object val) {
+        String value = val.toString();
+        return value.length() <= 128 ? value
+            : value.substring(0, 128) + " ... [" + value.hashCode() + "]";

Review Comment:
   What is the use case of printing the hascCode? In what situations will it be 
useful? I can't think of any right now. 



-- 
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: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to