Skip to content

Commit c231a9c

Browse files
committed
Handle FT.PROFILE Results for both Redis 7 and 8
1 parent f021c08 commit c231a9c

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4494,8 +4494,10 @@ public void setDefaultSearchDialect(int dialect) {
44944494

44954495
private class SearchProfileResponseBuilder<T> extends Builder<Map.Entry<T, ProfilingInfo>> {
44964496

4497-
private static final String PROFILE_STR = "profile";
4498-
private static final String RESULTS_STR = "results";
4497+
private static final String PROFILE_STR_REDIS7 = "profile";
4498+
private static final String PROFILE_STR_REDIS8 = "Profile";
4499+
private static final String RESULTS_STR_REDIS7 = "results";
4500+
private static final String RESULTS_STR_REDIS8 = "Results";
44994501

45004502
private final Builder<T> resultsBuilder;
45014503

@@ -4512,22 +4514,32 @@ public Map.Entry<T, ProfilingInfo> build(Object data) {
45124514
System.out.println("<<<<<<<<<<<<<<<<<<<<DEBUG");
45134515

45144516
if (list.get(0) instanceof KeyValue) { // RESP3
4515-
Object resultsRaw = data;
4516-
Object profileRaw = null;
4517+
Object resultsData = null, profileData = null;
4518+
45174519
for (KeyValue keyValue : (List<KeyValue>) data) {
45184520
String keyStr = BuilderFactory.STRING.build(keyValue.getKey());
4519-
if (PROFILE_STR.equalsIgnoreCase(keyStr)) {
4520-
profileRaw = keyValue.getValue();
4521-
// } else if (RESULTS_STR.equalsIgnoreCase(keyStr)) { // Redis 8
4522-
// resultsRaw = keyValue.getValue();
4521+
switch (keyStr) {
4522+
case PROFILE_STR_REDIS7:
4523+
case PROFILE_STR_REDIS8:
4524+
profileData = keyValue.getValue();
4525+
break;
4526+
case RESULTS_STR_REDIS7:
4527+
resultsData = data;
4528+
break;
4529+
case RESULTS_STR_REDIS8:
4530+
resultsData = keyValue.getValue();
4531+
break;
45234532
}
45244533
}
4525-
return KeyValue.of(resultsBuilder.build(resultsRaw),
4526-
ProfilingInfo.PROFILING_INFO_BUILDER.build(profileRaw));
4534+
4535+
assert resultsData != null : "Could not detect Results data.";
4536+
assert profileData != null : "Could not detect Profile data.";
4537+
return KeyValue.of(resultsBuilder.build(resultsData),
4538+
ProfilingInfo.PROFILING_INFO_BUILDER.build(profileData));
45274539
}
45284540

45294541
return KeyValue.of(resultsBuilder.build(list.get(0)),
4530-
ProfilingInfo.PROFILING_INFO_BUILDER.build(list.get(1))); // RESP2
4542+
ProfilingInfo.PROFILING_INFO_BUILDER.build(list.get(1)));
45314543
}
45324544
}
45334545

0 commit comments

Comments
 (0)