Skip to content

Commit b93b544

Browse files
committed
remove over optimization
1 parent 1daf249 commit b93b544

File tree

5 files changed

+364
-48
lines changed

5 files changed

+364
-48
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/expressions/Comparisons.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,8 @@ public enum Type {
638638
SORT(false),
639639
@API(API.Status.EXPERIMENTAL)
640640
LIKE,
641-
IS_DISTINCT_FROM(true),
642-
NOT_DISTINCT_FROM(false);
641+
IS_DISTINCT_FROM(false),
642+
NOT_DISTINCT_FROM(true);
643643

644644
@Nonnull
645645
private static final Supplier<BiMap<Type, PComparisonType>> protoEnumBiMapSupplier =
@@ -1337,9 +1337,7 @@ public BooleanWithConstraint semanticEqualsTyped(@Nonnull final Comparison other
13371337
public Boolean eval(@Nullable FDBRecordStoreBase<?> store, @Nonnull EvaluationContext context, @Nullable Object value) {
13381338
// this is at evaluation time --> always use the context binding
13391339
final Object comparand = getComparand(store, context);
1340-
if (comparand == null) {
1341-
return null;
1342-
} else if (comparand == COMPARISON_SKIPPED_BINDING) {
1340+
if (comparand == COMPARISON_SKIPPED_BINDING) {
13431341
return Boolean.TRUE;
13441342
} else {
13451343
return evalComparison(type, value, comparand);
@@ -1660,9 +1658,7 @@ public BooleanWithConstraint semanticEqualsTyped(@Nonnull final Comparison other
16601658
public Boolean eval(@Nullable FDBRecordStoreBase<?> store, @Nonnull EvaluationContext context, @Nullable Object v) {
16611659
// this is at evaluation time --> always use the context binding
16621660
final Object comparand = getComparand(store, context);
1663-
if (comparand == null) {
1664-
return null;
1665-
} else if (comparand == COMPARISON_SKIPPED_BINDING) {
1661+
if (comparand == COMPARISON_SKIPPED_BINDING) {
16661662
return Boolean.TRUE;
16671663
} else {
16681664
return evalComparison(type, v, comparand);

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ private static Optional<QueryPredicate> promoteOperandsAndCreatePredicate(@Nulla
184184
@Nonnull Value leftChild,
185185
@Nonnull Value rightChild,
186186
@Nonnull final Comparisons.Type comparisonType) {
187-
/*
188187
if (leftChild.getResultType().getTypeCode() == Type.TypeCode.NULL && rightChild.getResultType().getTypeCode() == Type.TypeCode.NULL) {
189188
if (comparisonType == Comparisons.Type.NOT_DISTINCT_FROM) {
190189
return Optional.of(ConstantPredicate.TRUE);
@@ -193,10 +192,6 @@ private static Optional<QueryPredicate> promoteOperandsAndCreatePredicate(@Nulla
193192
}
194193
}
195194

196-
*/
197-
198-
199-
200195
// maximumType may return null, but only for non-primitive types which is not possible here
201196
final var maxtype = Verify.verifyNotNull(Type.maximumType(leftChild.getResultType(), rightChild.getResultType()));
202197

@@ -306,30 +301,11 @@ private static Value encapsulate(@Nonnull final String functionName,
306301
final Typed arg1 = arguments.get(1);
307302
final Type res1 = arg1.getResultType();
308303

309-
/*
310-
if ("isDistinctFrom".equals(functionName)) {
311-
if (res0.getTypeCode() == Type.TypeCode.NULL && res1.getTypeCode() != Type.TypeCode.NULL) {
312-
return encapsulate("notNull", Comparisons.Type.NOT_NULL, List.of(arg1));
313-
} else if (res1.getTypeCode() == Type.TypeCode.NULL && res0.getTypeCode() != Type.TypeCode.NULL) {
314-
return encapsulate("notNull", Comparisons.Type.NOT_NULL, List.of(arg0));
315-
}
316-
}
317-
if ("notDistinctFrom".equals(functionName)) {
318-
if (res0.getTypeCode() == Type.TypeCode.NULL && res1.getTypeCode() != Type.TypeCode.NULL) {
319-
return encapsulate("isNull", Comparisons.Type.IS_NULL, List.of(arg1));
320-
} else if (res1.getTypeCode() == Type.TypeCode.NULL && res0.getTypeCode() != Type.TypeCode.NULL) {
321-
return encapsulate("isNull", Comparisons.Type.IS_NULL, List.of(arg0));
322-
}
323-
}
324-
325-
*/
326-
327304
SemanticException.check(res1.isPrimitive() || res1.isEnum() || res1.isUuid(), SemanticException.ErrorCode.COMPARAND_TO_COMPARISON_IS_OF_COMPLEX_TYPE);
328305

329306
final BinaryPhysicalOperator physicalOperator =
330307
getBinaryOperatorMap().get(new BinaryComparisonSignature(comparisonType, res0.getTypeCode(), res1.getTypeCode()));
331308

332-
System.out.println("comparisonType:" + comparisonType + " res0:" + res0.getTypeCode() + " res1:" + res1.getTypeCode());
333309
Verify.verifyNotNull(physicalOperator, "unable to encapsulate comparison operation due to type mismatch(es)");
334310

335311
return new BinaryRelOpValue(functionName,

0 commit comments

Comments
 (0)