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-252 Refactor query creator #647

Merged
merged 6 commits into from
Oct 31, 2023
Merged

FMWK-252 Refactor query creator #647

merged 6 commits into from
Oct 31, 2023

Conversation

agrgr
Copy link

@agrgr agrgr commented Oct 29, 2023

No description provided.

@agrgr agrgr requested review from roimenashe and reugn October 29, 2023 13:21
@agrgr agrgr marked this pull request as ready for review October 29, 2023 14:17
private Qualifier processId(Object value1) {
Qualifier qualifier;
if (value1 instanceof Collection<?>) {
qualifier = forIds(((Collection<?>) value1).toArray(String[]::new));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe transition from a collection of Object to an array of String.


private Qualifier processCollection(Part part, Object value1, Object value2, Iterator<?> parameters,
FilterOperation op, String fieldName) {
String dotPath = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotPath is always null. Consider passing an explicit null as an argument.

qualifiers[j++] = setQualifierBuilderValues(qb, fieldName, op, part, params.get(i),
null, null, dotPath).build();
qualifiers[j++] = setQualifier(qb, fieldName, op, part, params.get(i),
null, null, dotPath);
}

return new AerospikeCriteria(Qualifier.and(qualifiers));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wrapping with AerospikeCriteria?

Qualifier[] qualifiers;
if (containingMapKeyValuePairs) {
qualifiers = new Qualifier[params.size() / 2]; // keys/values qty must be even
for (int i = 0, j = 0; i < params.size(); i += 2) {
setQbValuesForMapByKey(qb, params.get(i), params.get(i + 1));
qualifiers[j++] = setQualifierBuilderValues(qb, fieldName, op, part, params.get(i),
null, null, dotPath).build();
qualifiers[j++] = setQualifier(qb, fieldName, op, part, params.get(i),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increment j in the increment section of the for statement.

return setQualifier(qb, fieldName, op, part, value1, value2, null, dotPath);
}

private Qualifier processMapMultipleParams(Part part, Object value1, Object value2, List<Object> params,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if this method can be refactored/simplified further.

@roimenashe
Copy link
Member

Nothing to add other than @reugn's comments

@agrgr agrgr merged commit b507fb8 into main Oct 31, 2023
5 checks passed
@agrgr agrgr deleted the FMWK-252-refactor-quey-creator branch October 31, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants