This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new 62b47ae  [CALCITE-2635] getMonotonocity is slow on wide tables (Gian 
Merlino)
62b47ae is described below

commit 62b47aeeb7eeb59beaf5b8f3b54a5c58ba4ca76d
Author: Gian Merlino <gianmerl...@gmail.com>
AuthorDate: Sat Oct 20 15:57:43 2018 -0700

    [CALCITE-2635] getMonotonocity is slow on wide tables (Gian Merlino)
    
    Instead of getting the index of the column from rowType and then comparing
    it to the collation field index, gets the collation field index and checks
    if the corresponding rowType index matches.
    
    fixes #891
---
 .../java/org/apache/calcite/prepare/RelOptTableImpl.java  | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/prepare/RelOptTableImpl.java 
b/core/src/main/java/org/apache/calcite/prepare/RelOptTableImpl.java
index aeeca3d..aac238a 100644
--- a/core/src/main/java/org/apache/calcite/prepare/RelOptTableImpl.java
+++ b/core/src/main/java/org/apache/calcite/prepare/RelOptTableImpl.java
@@ -332,14 +332,13 @@ public class RelOptTableImpl extends 
Prepare.AbstractPreparingTable {
   }
 
   public SqlMonotonicity getMonotonicity(String columnName) {
-    final int i = rowType.getFieldNames().indexOf(columnName);
-    if (i >= 0) {
-      for (RelCollation collation : table.getStatistic().getCollations()) {
-        final RelFieldCollation fieldCollation =
-            collation.getFieldCollations().get(0);
-        if (fieldCollation.getFieldIndex() == i) {
-          return fieldCollation.direction.monotonicity();
-        }
+    for (RelCollation collation : table.getStatistic().getCollations()) {
+      final RelFieldCollation fieldCollation =
+          collation.getFieldCollations().get(0);
+      final int fieldIndex = fieldCollation.getFieldIndex();
+      if (fieldIndex < rowType.getFieldCount()
+          && rowType.getFieldNames().get(fieldIndex).equals(columnName)) {
+        return fieldCollation.direction.monotonicity();
       }
     }
     return SqlMonotonicity.NOT_MONOTONIC;

Reply via email to