You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/10/28 08:52:03 UTC
incubator-kylin git commit: KYLIN-747 Optimize for IN clause
containing non-exist value
Repository: incubator-kylin
Updated Branches:
refs/heads/1.x-staging 060e45d31 -> f96600e89
KYLIN-747 Optimize for IN clause containing non-exist value
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/f96600e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/f96600e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/f96600e8
Branch: refs/heads/1.x-staging
Commit: f96600e89a5a2c0e533cea86ad6a73b9451bcddc
Parents: 060e45d
Author: Li, Yang <ya...@ebay.com>
Authored: Wed Oct 28 15:51:52 2015 +0800
Committer: Li, Yang <ya...@ebay.com>
Committed: Wed Oct 28 15:51:52 2015 +0800
----------------------------------------------------------------------
query/src/test/resources/query/sql/query82.sql | 22 ++++++++++++++++++++
query/src/test/resources/query/sql/query83.sql | 22 ++++++++++++++++++++
query/src/test/resources/query/sql/query84.sql | 22 ++++++++++++++++++++
.../kylin/storage/hbase/ColumnValueRange.java | 14 ++++++-------
.../kylin/storage/hbase/HBaseKeyRange.java | 7 +------
5 files changed, 74 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f96600e8/query/src/test/resources/query/sql/query82.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql/query82.sql b/query/src/test/resources/query/sql/query82.sql
new file mode 100644
index 0000000..8e29323
--- /dev/null
+++ b/query/src/test/resources/query/sql/query82.sql
@@ -0,0 +1,22 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+-- equals to non-exist value 'GGGG'
+select test_kylin_fact.lstg_format_name, sum(price) as GMV, count(*) as TRANS_CNT from test_kylin_fact
+where test_kylin_fact.lstg_format_name = 'GGGG'
+ group by test_kylin_fact.lstg_format_name
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f96600e8/query/src/test/resources/query/sql/query83.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql/query83.sql b/query/src/test/resources/query/sql/query83.sql
new file mode 100644
index 0000000..f4f06a1
--- /dev/null
+++ b/query/src/test/resources/query/sql/query83.sql
@@ -0,0 +1,22 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+-- greater tham non-exist value 'GGGG'
+select test_kylin_fact.lstg_format_name, sum(price) as GMV, count(*) as TRANS_CNT from test_kylin_fact
+where test_kylin_fact.lstg_format_name > 'GGGG'
+ group by test_kylin_fact.lstg_format_name
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f96600e8/query/src/test/resources/query/sql/query84.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql/query84.sql b/query/src/test/resources/query/sql/query84.sql
new file mode 100644
index 0000000..d526ba6
--- /dev/null
+++ b/query/src/test/resources/query/sql/query84.sql
@@ -0,0 +1,22 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+-- greater tham non-exist and super big value 'ZZZZ'
+select test_kylin_fact.lstg_format_name, sum(price) as GMV, count(*) as TRANS_CNT from test_kylin_fact
+where test_kylin_fact.lstg_format_name > 'ZZZZ'
+ group by test_kylin_fact.lstg_format_name
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f96600e8/storage/src/main/java/org/apache/kylin/storage/hbase/ColumnValueRange.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/hbase/ColumnValueRange.java b/storage/src/main/java/org/apache/kylin/storage/hbase/ColumnValueRange.java
index a840e51..9ae4a6d 100644
--- a/storage/src/main/java/org/apache/kylin/storage/hbase/ColumnValueRange.java
+++ b/storage/src/main/java/org/apache/kylin/storage/hbase/ColumnValueRange.java
@@ -102,7 +102,7 @@ public class ColumnValueRange {
}
public boolean satisfyAll() {
- return beginValue == null && endValue == null; // the NEQ case
+ return beginValue == null && endValue == null && equalValues == null; // the NEQ case
}
public boolean satisfyNone() {
@@ -184,19 +184,19 @@ public class ColumnValueRange {
if (beginValue != null) {
try {
- beginValue = dict.getValueFromId(dict.getIdFromValue(beginValue, -1));
+ beginValue = dict.getValueFromId(dict.getIdFromValue(beginValue, 1));
} catch (IllegalArgumentException e) {
- // value is less than the smallest in dictionary
- beginValue = null;
+ // beginValue is greater than the biggest in dictionary, mark FALSE
+ equalValues = Sets.newHashSet();
}
}
if (endValue != null) {
try {
- endValue = dict.getValueFromId(dict.getIdFromValue(endValue, 1));
+ endValue = dict.getValueFromId(dict.getIdFromValue(endValue, -1));
} catch (IllegalArgumentException e) {
- // value is greater than the biggest in dictionary
- endValue = null;
+ // endValue is lesser than the smallest in dictionary, mark FALSE
+ equalValues = Sets.newHashSet();
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f96600e8/storage/src/main/java/org/apache/kylin/storage/hbase/HBaseKeyRange.java
----------------------------------------------------------------------
diff --git a/storage/src/main/java/org/apache/kylin/storage/hbase/HBaseKeyRange.java b/storage/src/main/java/org/apache/kylin/storage/hbase/HBaseKeyRange.java
index cdfafaf..7baca90 100644
--- a/storage/src/main/java/org/apache/kylin/storage/hbase/HBaseKeyRange.java
+++ b/storage/src/main/java/org/apache/kylin/storage/hbase/HBaseKeyRange.java
@@ -136,14 +136,9 @@ public class HBaseKeyRange implements Comparable<HBaseKeyRange> {
encoder.setBlankByte(RowConstants.ROWKEY_UPPER_BYTE);
- // In order to make stopRow inclusive add a trailing 0 byte. #See
- // Scan.setStopRow(byte [] stopRow)
+ // In order to make stopRow inclusive add a trailing 0 byte. #See Scan.setStopRow(byte [] stopRow)
this.stopKey = Bytes.add(encoder.encode(stopValues), ZERO_TAIL_BYTES);
- // restore encoder defaults for later reuse (note
- // AbstractRowKeyEncoder.createInstance() caches instances)
- encoder.setBlankByte(AbstractRowKeyEncoder.DEFAULT_BLANK_BYTE);
-
// always fuzzy match cuboid ID to lock on the selected cuboid
this.fuzzyKeys = buildFuzzyKeys(fuzzyValues);
}