thomasmueller commented on code in PR #1123:
URL: https://github.com/apache/jackrabbit-oak/pull/1123#discussion_r1328464274


##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriter.java:
##########
@@ -118,14 +122,53 @@ public static String getPath(String entryLine) {
         return entryLine.substring(0, getDelimiterPosition(entryLine));
     }
 
+    /*
+        Currently we only have 2 types of store:
+        1. FlatFileStore
+        2. IncrementalFlatFileStore
+     */
     public static String[] getParts(String line) {
-        int pos = getDelimiterPosition(line);
-        return new String[]{line.substring(0, pos), line.substring(pos + 1)};
+        // file is FlatFileStore
+        if (line.endsWith("}")) {
+            int pos = getDelimiterPosition(line);
+            return new String[]{line.substring(0, pos), line.substring(pos + 
1)};
+        } else {
+            // file is IncrementalFlatFileStore
+            List<Integer> positions = getDelimiterPositions(line);
+            checkState(positions.size() >= 2, "Invalid path entry [%s]", line);
+            // there are 4 parts in incrementalFFS and default delimiter is |
+            // path|nodeData|checkpoint|operand
+            // Node's data can itself have many | so we split based on first 
and last 2 |
+            String[] parts = new String[4];
+            parts[0] = line.substring(0, positions.get(0));
+            parts[1] = line.substring(positions.get(0) + 1, 
positions.get(positions.size() - 2));

Review Comment:
   Why not use the simpler
   
       line.substring(positions.get(0) + 1, positions.get(1));
   
   ? I think it should be equivalent.



##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/index/indexer/document/flatfile/NodeStateEntryWriter.java:
##########
@@ -118,14 +122,53 @@ public static String getPath(String entryLine) {
         return entryLine.substring(0, getDelimiterPosition(entryLine));
     }
 
+    /*
+        Currently we only have 2 types of store:
+        1. FlatFileStore
+        2. IncrementalFlatFileStore
+     */
     public static String[] getParts(String line) {
-        int pos = getDelimiterPosition(line);
-        return new String[]{line.substring(0, pos), line.substring(pos + 1)};
+        // file is FlatFileStore
+        if (line.endsWith("}")) {
+            int pos = getDelimiterPosition(line);
+            return new String[]{line.substring(0, pos), line.substring(pos + 
1)};
+        } else {
+            // file is IncrementalFlatFileStore
+            List<Integer> positions = getDelimiterPositions(line);
+            checkState(positions.size() >= 2, "Invalid path entry [%s]", line);
+            // there are 4 parts in incrementalFFS and default delimiter is |
+            // path|nodeData|checkpoint|operand
+            // Node's data can itself have many | so we split based on first 
and last 2 |
+            String[] parts = new String[4];
+            parts[0] = line.substring(0, positions.get(0));
+            parts[1] = line.substring(positions.get(0) + 1, 
positions.get(positions.size() - 2));
+            parts[2] = line.substring(positions.get(positions.size() - 2) + 1, 
positions.get(positions.size() - 1));
+            parts[3] = line.substring(positions.get(positions.size() - 1) + 1);

Review Comment:
   same here
   
       parts[3] = line.substring(positions.get(2) + 1);
   
   
   (I think)



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