Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMWK-636 Use internal flag in Map keys containing queries #815

Merged
merged 4 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,11 @@ private static Exp mapKeysNotContain(Map<QualifierKey, Object> qualifierMap) {
private static Exp mapKeysContain(Map<QualifierKey, Object> qualifierMap) {
String errMsg = "MAP_KEYS_CONTAIN FilterExpression unsupported type: got " +
getValue(qualifierMap).getClass().getSimpleName();
String[] dotPathArray = getDotPathArray(getDotPath(qualifierMap));
if (hasMapKeyPlaceholder(qualifierMap) && dotPathArray != null && dotPathArray.length > 1) {
List<String> ctxList = convertToStringListExclStart(dotPathArray);
qualifierMap.put(CTX_ARRAY, resolveCtxList(ctxList));
}
return mapKeysCountComparedToZero(qualifierMap, Exp::gt, getValue(qualifierMap), errMsg);
}

Expand Down Expand Up @@ -2007,4 +2012,8 @@ protected Filter collectionRange(IndexCollectionType collectionType, Map<Qualifi
protected Filter geoWithinRadius(IndexCollectionType collectionType, Map<QualifierKey, Object> qualifierMap) {
return Filter.geoContains(getBinName(qualifierMap), getValue(qualifierMap).toString());
}

private static boolean hasMapKeyPlaceholder(Map<QualifierKey, Object> qualifierMap) {
return (Boolean) qualifierMap.getOrDefault(MAP_KEY_PLACEHOLDER, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public abstract class BaseQualifierBuilder<T extends BaseQualifierBuilder<?>> im
protected final Map<QualifierKey, Object> map = new HashMap<>();

public boolean getIgnoreCase() {
Object ignoreCase = map.get(IGNORE_CASE);
return ignoreCase != null && Boolean.parseBoolean(ignoreCase.toString());
return (Boolean) map.getOrDefault(IGNORE_CASE, false);
}

public FilterOperation getFilterOperation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public enum QualifierKey {
FILTER_OPERATION,
DIGEST_KEY,
HAS_SINDEX_FILTER,
SERVER_VERSION_SUPPORT
SERVER_VERSION_SUPPORT,
MAP_KEY_PLACEHOLDER
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,8 @@ private Qualifier processMapContaining(QueryQualifierBuilder qb, Part part, Stri
case KEY -> {
op = keysOp;
setQualifierBuilderValue(qb, queryParameters.get(1));
// the actual value is irrelevant here,
// the last dotPath element is discarded within AerospikeQueryCreatorUtils.getCtxFromDotPathArray(),
// the elements except the first and the last are converted to CTX,
// the key object (can contain '.') is transferred separately via qualifier builder value
dotPath.add("mapKeyPlaceholder");
// Map key placeholder is set for "Map keys containing" queries
qb.setMapKeyPlaceholder();
}
case VALUE -> {
op = valuesOp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ public QueryQualifierBuilder setServerVersionSupport(ServerVersionSupport server
return this;
}

/**
* Set Map key placeholder (for "Map keys containing" queries).
*/
public QueryQualifierBuilder setMapKeyPlaceholder() {
this.map.put(MAP_KEY_PLACEHOLDER, true);
return this;
}

public boolean hasDotPath() {
return map.get(DOT_PATH) != null;
}

}
Loading