Skip to content

Commit

Permalink
changed method names
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Sep 30, 2024
1 parent c445c02 commit d140d4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
public interface ConstraintOperator {
<T, V> BiPredicate<T, V> asPredicate();

default boolean containsConstraintType() {
default boolean hasIndex() {
return false;
}

default Index.ConstraintType getConstraintType() {
default Index.ConstraintType getIndexType() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public <T, V> BiPredicate<T, V> asPredicate() {
}

@Override
public boolean containsConstraintType() {
public boolean hasIndex() {
return true;
}

@Override
public Index.ConstraintType getConstraintType() {
public Index.ConstraintType getIndexType() {
return Index.ConstraintType.EQUAL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,21 @@ public PrototypePatternDef expr(PrototypeExpression left, ConstraintOperator ope
reactOnFields.addAll(right.getImpactedFields());

// If operator is not Index.ConstraintType, it may contain Index.ConstraintType internally for indexing purposes
ConstraintOperator operatorAsConstraintType = operator;
if (operator.containsConstraintType()) {
operatorAsConstraintType = operator.getConstraintType();
ConstraintOperator operatorAsIndexType = operator;
if (operator.hasIndex()) {
operatorAsIndexType = operator.getIndexType();
}

expr(createExprId(left, operator, right),
asPredicate1(leftExtractor, operator, right.asFunction(prototype)),
createAlphaIndex(left, operatorAsConstraintType, right, prototype, leftExtractor),
createAlphaIndex(left, operatorAsIndexType, right, prototype, leftExtractor),
reactOn( reactOnFields.toArray(new String[reactOnFields.size()])) );

return this;
}

private static AlphaIndex createAlphaIndex(PrototypeExpression left, ConstraintOperator operatorAsConstraintType, PrototypeExpression right, Prototype prototype, Function1<PrototypeFactInstance, Object> leftExtractor) {
if (left.getIndexingKey().isPresent() && right instanceof PrototypeExpression.FixedValue && operatorAsConstraintType instanceof Index.ConstraintType constraintType) {
private static AlphaIndex createAlphaIndex(PrototypeExpression left, ConstraintOperator operatorAsIndexType, PrototypeExpression right, Prototype prototype, Function1<PrototypeFactInstance, Object> leftExtractor) {
if (left.getIndexingKey().isPresent() && right instanceof PrototypeExpression.FixedValue && operatorAsIndexType instanceof Index.ConstraintType constraintType) {
String fieldName = left.getIndexingKey().get();
Prototype.Field field = prototype.getField(fieldName);
Object value = ((PrototypeExpression.FixedValue) right).getValue();
Expand Down Expand Up @@ -174,14 +174,14 @@ public PrototypePatternDef expr(PrototypeExpression left, ConstraintOperator ope
reactOnFields.addAll(right.getImpactedFields());

// If operator is not Index.ConstraintType, it may contain Index.ConstraintType internally for indexing purposes
ConstraintOperator operatorAsConstraintType = operator;
if (operator.containsConstraintType()) {
operatorAsConstraintType = operator.getConstraintType();
ConstraintOperator operatorAsIndexType = operator;
if (operator.hasIndex()) {
operatorAsIndexType = operator.getIndexType();
}

expr(createExprId(left, operator, right),
other, asPredicate2(left.asFunction(prototype), operator, right.asFunction(otherPrototype)),
createBetaIndex(left, operatorAsConstraintType, right, prototype, otherPrototype),
createBetaIndex(left, operatorAsIndexType, right, prototype, otherPrototype),
reactOn( reactOnFields.toArray(new String[reactOnFields.size()])) );

return this;
Expand All @@ -193,8 +193,8 @@ private static String createExprId(PrototypeExpression left, ConstraintOperator
return "expr:" + leftId + ":" + operator + ":" + rightId;
}

private BetaIndex createBetaIndex(PrototypeExpression left, ConstraintOperator operator, PrototypeExpression right, Prototype prototype, Prototype otherPrototype) {
if (left.getIndexingKey().isPresent() && operator instanceof Index.ConstraintType constraintType && right.getIndexingKey().isPresent()) {
private BetaIndex createBetaIndex(PrototypeExpression left, ConstraintOperator operatorAsIndexType, PrototypeExpression right, Prototype prototype, Prototype otherPrototype) {
if (left.getIndexingKey().isPresent() && operatorAsIndexType instanceof Index.ConstraintType constraintType && right.getIndexingKey().isPresent()) {
String fieldName = left.getIndexingKey().get();
Prototype.Field field = prototype.getField(fieldName);
Function1<PrototypeFactInstance, Object> extractor = left.asFunction(prototype);
Expand Down

0 comments on commit d140d4a

Please sign in to comment.