Skip to content

Commit

Permalink
Key Value processor value grouping optimization (opensearch-project#4704
Browse files Browse the repository at this point in the history
)

* dplive1.yaml

Signed-off-by: Kondaka <[email protected]>

* Optimize findInStartGroup in KV processor

Signed-off-by: Kondaka <[email protected]>

* Rebased to latest

Signed-off-by: Kondaka <[email protected]>

* Cleanup

Signed-off-by: Kondaka <[email protected]>

* Minor improvements to code

Signed-off-by: Kondaka <[email protected]>

* Addressed review comments

Signed-off-by: Kondaka <[email protected]>

---------

Signed-off-by: Kondaka <[email protected]>
  • Loading branch information
kkondaka authored Jul 3, 2024
1 parent 39c74db commit 3d2265f
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,22 @@ private void addPart(List<String> parts, final String str, final int start, fina
}
}

public int findInStartGroup(final String str, int idx) {
private int findInStartGroup(final String str, final int idx) {
if (idx < 0 || idx >= str.length()) {
return -1; // Invalid starting index
}

for (int j = 0; j < startGroupStrings.length; j++) {
try {
if (startGroupStrings[j].equals(str.substring(idx, idx+startGroupStrings[j].length()))) {
// For " and ', make sure, it's not escaped
if (j <= 1 && (idx == 0 || str.charAt(idx-1) != '\\')) {
return j;
} else if (j > 1) {
return j;
}
String startGroup = startGroupStrings[j];
int startGroupLen = startGroup.length();

if (idx + startGroupLen <= str.length() && str.startsWith(startGroup, idx)) {
// For the first two elements, check for escape characters
if (j <= 1 && (idx == 0 || str.charAt(idx - 1) != '\\')) {
return j;
} else if (j > 1) {
return j;
}
} catch (Exception e) {
return -1;
}
}
return -1;
Expand Down

0 comments on commit 3d2265f

Please sign in to comment.