Repository: calcite
Updated Branches:
  refs/heads/master e0f29dd79 -> 72b2cfb79


[CALCITE-1083] SqlNode.equalsDeep has O(n ^ 2) performance

Cause of the problem is that Litmus.fail constructs an error message string, 
even if the particular implementation of Litmus does not use the string. 
Solution is to pass a format string and arguments, which are only converted to 
strings if the message is used, the same as SLF4J Logger does.


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/670fa73e
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/670fa73e
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/670fa73e

Branch: refs/heads/master
Commit: 670fa73e24a7b72d6ddafd69793474083bb4b9f0
Parents: e0f29dd
Author: Julian Hyde <[email protected]>
Authored: Tue Feb 9 15:04:03 2016 -0800
Committer: Julian Hyde <[email protected]>
Committed: Tue Feb 9 15:17:40 2016 -0800

----------------------------------------------------------------------
 .../org/apache/calcite/plan/RelOptUtil.java     | 18 ++++++---------
 .../org/apache/calcite/rel/core/Aggregate.java  |  3 ++-
 .../java/org/apache/calcite/rel/core/Join.java  |  4 ++--
 .../org/apache/calcite/rel/core/Project.java    |  8 +++----
 .../java/org/apache/calcite/rex/RexChecker.java |  4 ++--
 .../java/org/apache/calcite/rex/RexLiteral.java |  8 +++----
 .../java/org/apache/calcite/rex/RexProgram.java |  7 +++---
 .../java/org/apache/calcite/rex/RexUtil.java    |  9 ++++----
 .../apache/calcite/sql/SqlBinaryOperator.java   |  2 +-
 .../java/org/apache/calcite/sql/SqlCall.java    |  4 ++--
 .../org/apache/calcite/sql/SqlDataTypeSpec.java | 10 ++++-----
 .../org/apache/calcite/sql/SqlDynamicParam.java |  4 ++--
 .../org/apache/calcite/sql/SqlIdentifier.java   |  6 ++---
 .../calcite/sql/SqlIntervalQualifier.java       |  2 +-
 .../java/org/apache/calcite/sql/SqlLiteral.java |  4 ++--
 .../org/apache/calcite/sql/SqlNodeList.java     |  4 ++--
 .../apache/calcite/sql/SqlPostfixOperator.java  |  2 +-
 .../apache/calcite/sql/SqlPrefixOperator.java   |  2 +-
 .../apache/calcite/sql/fun/SqlInOperator.java   |  2 +-
 .../calcite/sql/fun/SqlStdOperatorTable.java    |  2 +-
 .../apache/calcite/sql2rel/RelDecorrelator.java |  2 +-
 .../java/org/apache/calcite/util/Litmus.java    | 23 ++++++++++++--------
 22 files changed, 66 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index 610867a..a03a0fa 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -227,7 +227,7 @@ public abstract class RelOptUtil {
     if (!set.contains(correlationId)) {
       return litmus.succeed();
     } else {
-      return litmus.fail("contains " + correlationId);
+      return litmus.fail("contains {}", correlationId);
     }
   }
 
@@ -1662,11 +1662,9 @@ public abstract class RelOptUtil {
     }
 
     if (type1 != type2) {
-      return litmus.fail("type mismatch:\n"
-          + desc1 + ":\n"
-          + type1.getFullTypeString() + "\n"
-          + desc2 + ":\n"
-          + type2.getFullTypeString());
+      return litmus.fail("type mismatch:\n{}:\n{}\n{}:\n{}",
+          desc1, type1.getFullTypeString(),
+          desc2, type2.getFullTypeString());
     }
     return litmus.succeed();
   }
@@ -1690,11 +1688,9 @@ public abstract class RelOptUtil {
       RelDataType type2,
       Litmus litmus) {
     if (!areRowTypesEqual(type1, type2, false)) {
-      return litmus.fail("Type mismatch:\n"
-          + desc1 + ":\n"
-          + type1.getFullTypeString() + "\n"
-          + desc2 + ":\n"
-          + type2.getFullTypeString());
+      return litmus.fail("Type mismatch:\n{}:\n{}\n{}:\n{}",
+          desc1, type1.getFullTypeString(),
+          desc2, type2.getFullTypeString());
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java 
b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
index 4eedee7..2408ae5 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
@@ -382,7 +382,8 @@ public abstract class Aggregate extends SingleRel {
 
   public boolean isValid(Litmus litmus) {
     return super.isValid(litmus)
-        && litmus.check(Util.isDistinct(getRowType().getFieldNames()), 
getRowType());
+        && litmus.check(Util.isDistinct(getRowType().getFieldNames()),
+            "distinct field names: {}", getRowType());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rel/core/Join.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Join.java 
b/core/src/main/java/org/apache/calcite/rel/core/Join.java
index 7c20f14..4a99f0d 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Join.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Join.java
@@ -155,8 +155,8 @@ public abstract class Join extends BiRel {
     }
     if (condition != null) {
       if (condition.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
-        return litmus.fail("condition must be boolean: "
-            + condition.getType());
+        return litmus.fail("condition must be boolean: {}",
+            condition.getType());
       }
       // The input to the condition is a row type consisting of system
       // fields, left fields, and right fields. Very similar to the

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rel/core/Project.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Project.java 
b/core/src/main/java/org/apache/calcite/rel/core/Project.java
index e92b04d..8089506 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Project.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Project.java
@@ -184,12 +184,12 @@ public abstract class Project extends SingleRel {
     for (RexNode exp : exps) {
       exp.accept(checker);
       if (checker.getFailureCount() > 0) {
-        return litmus.fail(checker.getFailureCount()
-            + " failures in expression " + exp);
+        return litmus.fail("{} failures in expression {}",
+            checker.getFailureCount(), exp);
       }
     }
     if (!Util.isDistinct(rowType.getFieldNames())) {
-      return litmus.fail("field names not distinct: " + rowType);
+      return litmus.fail("field names not distinct: {}", rowType);
     }
     //CHECKSTYLE: IGNORE 1
     if (false && !Util.isDistinct(
@@ -205,7 +205,7 @@ public abstract class Project extends SingleRel {
       // because we need to allow
       //
       //  SELECT a, b FROM c UNION SELECT x, x FROM z
-      return litmus.fail("duplicate expressions: " + exps);
+      return litmus.fail("duplicate expressions: {}", exps);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rex/RexChecker.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexChecker.java 
b/core/src/main/java/org/apache/calcite/rex/RexChecker.java
index c51d923..d573c51 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexChecker.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexChecker.java
@@ -111,8 +111,8 @@ public class RexChecker extends RexVisitorImpl<Boolean> {
     final int index = ref.getIndex();
     if ((index < 0) || (index >= inputTypeList.size())) {
       ++failCount;
-      return litmus.fail("RexInputRef index " + index
-          + " out of range 0.." + (inputTypeList.size() - 1));
+      return litmus.fail("RexInputRef index {} out of range 0..{}",
+          index, inputTypeList.size() - 1);
     }
     if (!ref.getType().isStruct()
         && !RelOptUtil.eq("ref", ref.getType(), "input",

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java 
b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
index 26f8e4a..e28653f 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
@@ -275,7 +275,7 @@ public class RexLiteral extends RexNode {
       List list = (List) o;
       for (Object o1 : list) {
         if (!validConstant(o1, litmus)) {
-          return litmus.fail("not a constant: " + o1);
+          return litmus.fail("not a constant: {}", o1);
         }
       }
       return litmus.succeed();
@@ -283,15 +283,15 @@ public class RexLiteral extends RexNode {
       @SuppressWarnings("unchecked") final Map<Object, Object> map = (Map) o;
       for (Map.Entry entry : map.entrySet()) {
         if (!validConstant(entry.getKey(), litmus)) {
-          return litmus.fail("not a constant: " + entry.getKey());
+          return litmus.fail("not a constant: {}", entry.getKey());
         }
         if (!validConstant(entry.getValue(), litmus)) {
-          return litmus.fail("not a constant: " + entry.getValue());
+          return litmus.fail("not a constant: {}", entry.getValue());
         }
       }
       return litmus.succeed();
     } else {
-      return litmus.fail("not a constant: " + o);
+      return litmus.fail("not a constant: {}", o);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rex/RexProgram.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexProgram.java 
b/core/src/main/java/org/apache/calcite/rex/RexProgram.java
index 30382c5..2762180 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexProgram.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexProgram.java
@@ -766,9 +766,10 @@ public class RexProgram {
     String normalized = normalizedProgram.toString();
     String string = toString();
     if (!normalized.equals(string)) {
-      return litmus.fail("Program is not normalized:\n"
-          + "program:    " + string + "\n"
-          + "normalized: " + normalized + "\n");
+      final String message = "Program is not normalized:\n"
+          + "program:    {}\n"
+          + "normalized: {}\n";
+      return litmus.fail(message, string, normalized);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/rex/RexUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java 
b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index ce3e936..f26c783 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -521,7 +521,7 @@ public class RexUtil {
         expr.accept(visitor);
       } catch (ForwardRefFinder.IllegalForwardRefException e) {
         Util.swallow(e, null);
-        return litmus.fail("illegal forward reference in " + expr);
+        return litmus.fail("illegal forward reference in {}", expr);
       }
     }
     return litmus.succeed();
@@ -542,7 +542,7 @@ public class RexUtil {
           for (RexNode operand : rexCall.operands) {
             if (!(operand instanceof RexLocalRef)
                 && !(operand instanceof RexLiteral)) {
-              return litmus.fail("contains non trivial agg: " + operand);
+              return litmus.fail("contains non trivial agg: {}", operand);
             }
           }
         }
@@ -680,12 +680,11 @@ public class RexUtil {
     }
     for (int i = 0; i < fields.size(); i++) {
       if (!(exprs.get(i) instanceof RexInputRef)) {
-        return litmus.fail("expr[" + i + "] is not a RexInputRef");
+        return litmus.fail("expr[{}] is not a RexInputRef", i);
       }
       RexInputRef inputRef = (RexInputRef) exprs.get(i);
       if (inputRef.getIndex() != i) {
-        return litmus.fail("expr[" + i + "] has ordinal "
-            + inputRef.getIndex());
+        return litmus.fail("expr[{}] has ordinal {}", i, inputRef.getIndex());
       }
       if (!RelOptUtil.eq("type1",
           exprs.get(i).getType(),

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java 
b/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
index 34943c2..c1dece3 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
@@ -217,7 +217,7 @@ public class SqlBinaryOperator extends SqlOperator {
           && count > 2) {
         return true;
       }
-      return litmus.fail("wrong operand count " + count + " for " + this);
+      return litmus.fail("wrong operand count {} for {}", count, this);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlCall.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlCall.java 
b/core/src/main/java/org/apache/calcite/sql/SqlCall.java
index 59066b3..620f1a8 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlCall.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlCall.java
@@ -140,14 +140,14 @@ public abstract class SqlCall extends SqlNode {
       return true;
     }
     if (!(node instanceof SqlCall)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlCall that = (SqlCall) node;
 
     // Compare operators by name, not identity, because they may not
     // have been resolved yet.
     if (!this.getOperator().getName().equals(that.getOperator().getName())) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     return equalDeep(this.getOperandList(), that.getOperandList(), litmus);
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java 
b/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
index 2cffb82..d4bfc6c 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlDataTypeSpec.java
@@ -236,7 +236,7 @@ public class SqlDataTypeSpec extends SqlNode {
 
   public boolean equalsDeep(SqlNode node, Litmus litmus) {
     if (!(node instanceof SqlDataTypeSpec)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlDataTypeSpec that = (SqlDataTypeSpec) node;
     if (!SqlNode.equalDeep(
@@ -248,16 +248,16 @@ public class SqlDataTypeSpec extends SqlNode {
       return litmus.fail(null);
     }
     if (this.precision != that.precision) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     if (this.scale != that.scale) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     if (!Objects.equals(this.timeZone, that.timeZone)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     if (!Objects.equals(this.charSetName, that.charSetName)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlDynamicParam.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDynamicParam.java 
b/core/src/main/java/org/apache/calcite/sql/SqlDynamicParam.java
index 8fc771c..7db5fd7 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlDynamicParam.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlDynamicParam.java
@@ -79,11 +79,11 @@ public class SqlDynamicParam extends SqlNode {
 
   public boolean equalsDeep(SqlNode node, Litmus litmus) {
     if (!(node instanceof SqlDynamicParam)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlDynamicParam that = (SqlDynamicParam) node;
     if (this.index != that.index) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java 
b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
index bd0c5d5..2a6bca0 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
@@ -289,15 +289,15 @@ public class SqlIdentifier extends SqlNode {
 
   public boolean equalsDeep(SqlNode node, Litmus litmus) {
     if (!(node instanceof SqlIdentifier)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlIdentifier that = (SqlIdentifier) node;
     if (this.names.size() != that.names.size()) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     for (int i = 0; i < names.size(); i++) {
       if (!this.names.get(i).equals(that.names.get(i))) {
-        return litmus.fail(this + "!=" + node);
+        return litmus.fail("{} != {}", this, node);
       }
     }
     return litmus.succeed();

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java 
b/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
index aa9729d..ae36bee 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
@@ -147,7 +147,7 @@ public class SqlIntervalQualifier extends SqlNode {
     final String thisString = this.toString();
     final String thatString = node.toString();
     if (!thisString.equals(thatString)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java 
b/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
index 625e11c..f535c53 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlLiteral.java
@@ -407,11 +407,11 @@ public class SqlLiteral extends SqlNode {
 
   public boolean equalsDeep(SqlNode node, Litmus litmus) {
     if (!(node instanceof SqlLiteral)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlLiteral that = (SqlLiteral) node;
     if (!this.equals(that)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java 
b/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
index 392d967..0925864 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
@@ -155,11 +155,11 @@ public class SqlNodeList extends SqlNode implements 
Iterable<SqlNode> {
 
   public boolean equalsDeep(SqlNode node, Litmus litmus) {
     if (!(node instanceof SqlNodeList)) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     SqlNodeList that = (SqlNodeList) node;
     if (this.size() != that.size()) {
-      return litmus.fail(this + "!=" + node);
+      return litmus.fail("{} != {}", this, node);
     }
     for (int i = 0; i < list.size(); i++) {
       SqlNode thisChild = list.get(i);

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlPostfixOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlPostfixOperator.java 
b/core/src/main/java/org/apache/calcite/sql/SqlPostfixOperator.java
index 5fef8ae..31020d1 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlPostfixOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlPostfixOperator.java
@@ -91,7 +91,7 @@ public class SqlPostfixOperator extends SqlOperator {
 
   @Override public boolean validRexOperands(int count, Litmus litmus) {
     if (count != 1) {
-      return litmus.fail("wrong operand count " + count + " for " + this);
+      return litmus.fail("wrong operand count {} for {}", count, this);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/SqlPrefixOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlPrefixOperator.java 
b/core/src/main/java/org/apache/calcite/sql/SqlPrefixOperator.java
index 8976a56..11eeb26 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlPrefixOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlPrefixOperator.java
@@ -100,7 +100,7 @@ public class SqlPrefixOperator extends SqlOperator {
 
   @Override public boolean validRexOperands(int count, Litmus litmus) {
     if (count != 1) {
-      return litmus.fail("wrong operand count " + count + " for " + this);
+      return litmus.fail("wrong operand count {} for {}", count, this);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
index 9e8105a..a20cea3 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
@@ -87,7 +87,7 @@ public class SqlInOperator extends SqlBinaryOperator {
 
   @Override public boolean validRexOperands(int count, Litmus litmus) {
     if (count == 0) {
-      return litmus.fail("wrong operand count " + count + " for " + this);
+      return litmus.fail("wrong operand count {} for {}", count, this);
     }
     return litmus.succeed();
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index 464945d..db755a2 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -617,7 +617,7 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
 
         @Override public boolean validRexOperands(int count, Litmus litmus) {
           if (count != 0) {
-            return litmus.fail("wrong operand count " + count + " for " + 
this);
+            return litmus.fail("wrong operand count {} for {}", count, this);
           }
           return litmus.succeed();
         }

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java 
b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index ecfd124..024cb5f 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -1323,7 +1323,7 @@ public class RelDecorrelator implements ReflectiveVisitor 
{
       Litmus ret) {
     for (int value : integers) {
       if (value >= limit) {
-        return ret.fail("out of range; value: " + value + ", limit: " + limit);
+        return ret.fail("out of range; value: {}, limit: {}", value, limit);
       }
     }
     return ret.succeed();

http://git-wip-us.apache.org/repos/asf/calcite/blob/670fa73e/core/src/main/java/org/apache/calcite/util/Litmus.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Litmus.java 
b/core/src/main/java/org/apache/calcite/util/Litmus.java
index 1a74e6c..0f0be55 100644
--- a/core/src/main/java/org/apache/calcite/util/Litmus.java
+++ b/core/src/main/java/org/apache/calcite/util/Litmus.java
@@ -23,19 +23,20 @@ public interface Litmus {
   /** Implementation of {@link org.apache.calcite.util.Litmus} that throws
    * an {@link java.lang.AssertionError} on failure. */
   Litmus THROW = new Litmus() {
-    public boolean fail(String message) {
-      throw new AssertionError(message);
+    public boolean fail(String message, Object... args) {
+      final String s = message == null ? null : String.format(message, args);
+      throw new AssertionError(s);
     }
 
     public boolean succeed() {
       return true;
     }
 
-    public boolean check(boolean condition, Object info) {
+    public boolean check(boolean condition, String message, Object... args) {
       if (condition) {
         return succeed();
       } else {
-        return fail(info == null ? null : info.toString());
+        return fail(message, args);
       }
     }
   };
@@ -43,7 +44,7 @@ public interface Litmus {
   /** Implementation of {@link org.apache.calcite.util.Litmus} that returns
    * a status code but does not throw. */
   Litmus IGNORE = new Litmus() {
-    public boolean fail(String message) {
+    public boolean fail(String message, Object... args) {
       return false;
     }
 
@@ -51,13 +52,17 @@ public interface Litmus {
       return true;
     }
 
-    public boolean check(boolean condition, Object info) {
+    public boolean check(boolean condition, String message, Object... args) {
       return condition;
     }
   };
 
-  /** Called when test fails. Returns false or throws. */
-  boolean fail(String message);
+  /** Called when test fails. Returns false or throws.
+   *
+   * @param message Message
+   * @param args Arguments
+   */
+  boolean fail(String message, Object... args);
 
   /** Called when test succeeds. Returns true. */
   boolean succeed();
@@ -68,7 +73,7 @@ public interface Litmus {
    * if the condition is false, calls {@link #fail},
    * converting {@code info} into a string message.
    */
-  boolean check(boolean condition, Object info);
+  boolean check(boolean condition, String message, Object... args);
 }
 
 // End Litmus.java

Reply via email to