Skip to content

Commit

Permalink
refactor Qualifier builders
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Oct 16, 2023
1 parent 92b1d48 commit 7932785
Show file tree
Hide file tree
Showing 23 changed files with 862 additions and 862 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ExpiryQualifier extends Qualifier {
private static final long serialVersionUID = 13172814137477042L;

public ExpiryQualifier(FilterOperation op, Value value) {
super(new QualifierBuilder()
super(Qualifier.builder()
.setField(QueryEngine.Meta.EXPIRATION.toString())
.setFilterOperation(op)
.setValue1(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ public Exp filterExp(Map<String, Object> qualifierMap) {
Value value1 = getValue1AsCollectionOrFail(qualifierMap);
Collection<?> collection = (Collection<?>) value1.getObject();
Exp[] arrElementsExp = collection.stream().map(item ->
new Qualifier(
new QualifierBuilder()
.setField(getField(qualifierMap))
.setFilterOperation(FilterOperation.EQ)
.setValue1(Value.get(item))
).toFilterExp()
Qualifier.builder()
.setField(getField(qualifierMap))
.setFilterOperation(FilterOperation.EQ)
.setValue1(Value.get(item))
.build()
.toFilterExp()
).toArray(Exp[]::new);

return Exp.or(arrElementsExp);
Expand All @@ -100,12 +100,12 @@ public Exp filterExp(Map<String, Object> qualifierMap) {
Value value1 = getValue1AsCollectionOrFail(qualifierMap);
Collection<?> collection = (Collection<?>) value1.getObject();
Exp[] arrElementsExp = collection.stream().map(item ->
new Qualifier(
new QualifierBuilder()
.setField(getField(qualifierMap))
.setFilterOperation(FilterOperation.NOTEQ)
.setValue1(Value.get(item))
).toFilterExp()
Qualifier.builder()
.setField(getField(qualifierMap))
.setFilterOperation(FilterOperation.NOTEQ)
.setValue1(Value.get(item))
.build()
.toFilterExp()
).toArray(Exp[]::new);

return Exp.and(arrElementsExp);
Expand Down Expand Up @@ -587,7 +587,8 @@ public Exp filterExp(Map<String, Object> qualifierMap) {
validateEquality(getValue1(qualifierMap).getType(), getValue3(qualifierMap).getType(), qualifierMap,
"MAP_VAL_BETWEEN_BY_KEY");

Exp value1, value2;
Exp value1;
Exp value2;
Exp.Type type;
switch (getValue1(qualifierMap).getType()) {
case INTEGER -> {
Expand Down Expand Up @@ -1212,11 +1213,12 @@ public Filter sIndexFilter(Map<String, Object> qualifierMap) {
/**
* FilterOperations that require both sIndexFilter and FilterExpression
*/
public static final List<FilterOperation> dualFilterOperations = Arrays.asList(
protected static final List<FilterOperation> dualFilterOperations = Arrays.asList(
MAP_VAL_EQ_BY_KEY, MAP_VAL_GT_BY_KEY, MAP_VAL_GTEQ_BY_KEY, MAP_VAL_LT_BY_KEY, MAP_VAL_LTEQ_BY_KEY,
MAP_VAL_BETWEEN_BY_KEY
);

@SuppressWarnings("unchecked")
private static Exp processMetadataFieldInOrNot(Map<String, Object> qualifierMap, boolean notIn) {
FilterOperation filterOperation = notIn ? NOTEQ : EQ;
Object value1 = getValue1Object(qualifierMap);
Expand All @@ -1230,12 +1232,12 @@ private static Exp processMetadataFieldInOrNot(Map<String, Object> qualifierMap,
"type List<Long>");
}
Exp[] listElementsExp = listOfLongs.stream().map(item ->
new Qualifier(
new MetadataQualifierBuilder()
.setMetadataField(getMetadataField(qualifierMap))
.setFilterOperation(filterOperation)
.setValue1AsObj(item)
).toFilterExp()
Qualifier.metadataBuilder()
.setMetadataField(getMetadataField(qualifierMap))
.setFilterOperation(filterOperation)
.setValue1AsObj(item)
.build()
.toFilterExp()
).toArray(Exp[]::new);

return notIn ? Exp.and(listElementsExp) : Exp.or(listElementsExp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public class KeyQualifier extends Qualifier {
boolean hasDigest = false;

public KeyQualifier(Value value) {
super(new QualifierBuilder()
super(Qualifier.builder()
.setField(QueryEngine.Meta.KEY.toString())
.setFilterOperation(FilterOperation.EQ)
.setValue1(value)
);
}

public KeyQualifier(byte[] digest) {
super(new QualifierBuilder()
super(Qualifier.builder()
.setField(QueryEngine.Meta.KEY.toString())
.setFilterOperation(FilterOperation.EQ)
.setValue1(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class LatestUpdateQualifier extends Qualifier {
private static final long serialVersionUID = -8767573059309320133L;

public LatestUpdateQualifier(FilterOperation op, Value value) {
super(new QualifierBuilder()
super(Qualifier.builder()
.setField("latest_update_time")
.setFilterOperation(op)
.setValue1(value)
Expand Down

This file was deleted.

Loading

0 comments on commit 7932785

Please sign in to comment.