[11/35] phoenix git commit: PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang)
PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/45fbc417 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/45fbc417 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/45fbc417 Branch: refs/heads/calcite Commit: 45fbc4177bddacd0e62bbb38258cc94be94a4fe5 Parents: 04f5370 Author: James TaylorAuthored: Sat Oct 15 15:19:47 2016 -0700 Committer: James Taylor Committed: Sat Oct 15 15:19:47 2016 -0700 -- .../apache/phoenix/compile/WhereOptimizer.java | 23 - .../phoenix/compile/WhereOptimizerTest.java | 53 .../java/org/apache/phoenix/util/TestUtil.java | 7 +++ 3 files changed, 81 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/45fbc417/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index f49aa52..f15a251 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -750,12 +750,31 @@ public class WhereOptimizer { } } } else { +boolean hasFirstSlot = true; +boolean prevIsNull = false; // TODO: Do the same optimization that we do for IN if the childSlots specify a fully qualified row key for (KeySlot slot : childSlot) { -// We have a nested OR with nothing for this slot, so continue +if (hasFirstSlot) { +// if the first slot is null, return null immediately +if (slot == null) { +return null; +} +// mark that we've handled the first slot +hasFirstSlot = false; +} + +// now if current slot is the first one, it must not be null +// if not the first, then it might be null, so check if all the rest are null if (slot == null) { -return null; //If one childSlot does not have the PK columns, let Phoenix scan all the key ranges of the table. +prevIsNull = true; +continue; +} else { +// current slot is not null but prev one is null, cannot OR these together (PHOENIX-3328) +if (prevIsNull) { +return null; +} } + /* * If we see a different PK column than before, we can't * optimize it because our SkipScanFilter only handles http://git-wip-us.apache.org/repos/asf/phoenix/blob/45fbc417/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java -- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java index a116a2c..e056c47 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java @@ -19,6 +19,7 @@ package org.apache.phoenix.compile; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; import static org.apache.phoenix.util.TestUtil.BINARY_NAME; +import static org.apache.phoenix.util.TestUtil.BTABLE_NAME; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.assertDegenerate; import static org.apache.phoenix.util.TestUtil.assertEmptyScanKey; @@ -28,6 +29,7 @@ import static org.apache.phoenix.util.TestUtil.rowKeyFilter; import static org.apache.phoenix.util.TestUtil.substr; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -38,6 +40,7 @@ import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager;
[3/4] phoenix git commit: PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang)
PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/96b14f5d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/96b14f5d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/96b14f5d Branch: refs/heads/4.x-HBase-1.1 Commit: 96b14f5decb759ff6869a6e9934a72a03d136137 Parents: 1d4a88d Author: James TaylorAuthored: Sat Oct 15 15:19:47 2016 -0700 Committer: James Taylor Committed: Tue Oct 25 17:05:33 2016 -0700 -- .../apache/phoenix/compile/WhereOptimizer.java | 23 - .../phoenix/compile/WhereOptimizerTest.java | 53 .../java/org/apache/phoenix/util/TestUtil.java | 7 +++ 3 files changed, 81 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/96b14f5d/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index f49aa52..f15a251 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -750,12 +750,31 @@ public class WhereOptimizer { } } } else { +boolean hasFirstSlot = true; +boolean prevIsNull = false; // TODO: Do the same optimization that we do for IN if the childSlots specify a fully qualified row key for (KeySlot slot : childSlot) { -// We have a nested OR with nothing for this slot, so continue +if (hasFirstSlot) { +// if the first slot is null, return null immediately +if (slot == null) { +return null; +} +// mark that we've handled the first slot +hasFirstSlot = false; +} + +// now if current slot is the first one, it must not be null +// if not the first, then it might be null, so check if all the rest are null if (slot == null) { -return null; //If one childSlot does not have the PK columns, let Phoenix scan all the key ranges of the table. +prevIsNull = true; +continue; +} else { +// current slot is not null but prev one is null, cannot OR these together (PHOENIX-3328) +if (prevIsNull) { +return null; +} } + /* * If we see a different PK column than before, we can't * optimize it because our SkipScanFilter only handles http://git-wip-us.apache.org/repos/asf/phoenix/blob/96b14f5d/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java -- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java index a116a2c..e056c47 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java @@ -19,6 +19,7 @@ package org.apache.phoenix.compile; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; import static org.apache.phoenix.util.TestUtil.BINARY_NAME; +import static org.apache.phoenix.util.TestUtil.BTABLE_NAME; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.assertDegenerate; import static org.apache.phoenix.util.TestUtil.assertEmptyScanKey; @@ -28,6 +29,7 @@ import static org.apache.phoenix.util.TestUtil.rowKeyFilter; import static org.apache.phoenix.util.TestUtil.substr; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -38,6 +40,7 @@ import java.sql.Connection; import java.sql.Date; import
[3/4] phoenix git commit: PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang)
PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/6027ee8e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6027ee8e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6027ee8e Branch: refs/heads/4.x-HBase-0.98 Commit: 6027ee8efe53658ba3fd3e234876e2e6f89b8468 Parents: c40fa01 Author: James TaylorAuthored: Sat Oct 15 15:19:47 2016 -0700 Committer: James Taylor Committed: Tue Oct 25 16:41:01 2016 -0700 -- .../apache/phoenix/compile/WhereOptimizer.java | 23 - .../phoenix/compile/WhereOptimizerTest.java | 53 .../java/org/apache/phoenix/util/TestUtil.java | 7 +++ 3 files changed, 81 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/6027ee8e/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index f49aa52..f15a251 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -750,12 +750,31 @@ public class WhereOptimizer { } } } else { +boolean hasFirstSlot = true; +boolean prevIsNull = false; // TODO: Do the same optimization that we do for IN if the childSlots specify a fully qualified row key for (KeySlot slot : childSlot) { -// We have a nested OR with nothing for this slot, so continue +if (hasFirstSlot) { +// if the first slot is null, return null immediately +if (slot == null) { +return null; +} +// mark that we've handled the first slot +hasFirstSlot = false; +} + +// now if current slot is the first one, it must not be null +// if not the first, then it might be null, so check if all the rest are null if (slot == null) { -return null; //If one childSlot does not have the PK columns, let Phoenix scan all the key ranges of the table. +prevIsNull = true; +continue; +} else { +// current slot is not null but prev one is null, cannot OR these together (PHOENIX-3328) +if (prevIsNull) { +return null; +} } + /* * If we see a different PK column than before, we can't * optimize it because our SkipScanFilter only handles http://git-wip-us.apache.org/repos/asf/phoenix/blob/6027ee8e/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java -- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java index 8b668a1..34beb59 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java @@ -19,6 +19,7 @@ package org.apache.phoenix.compile; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; import static org.apache.phoenix.util.TestUtil.BINARY_NAME; +import static org.apache.phoenix.util.TestUtil.BTABLE_NAME; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.assertDegenerate; import static org.apache.phoenix.util.TestUtil.assertEmptyScanKey; @@ -28,6 +29,7 @@ import static org.apache.phoenix.util.TestUtil.rowKeyFilter; import static org.apache.phoenix.util.TestUtil.substr; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -38,6 +40,7 @@ import java.sql.Connection; import java.sql.Date; import
phoenix git commit: PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang)
Repository: phoenix Updated Branches: refs/heads/master 04f5370d7 -> 45fbc4177 PHOENIX-3328 Optimize ORed leading pk column range comparisions to SkipScan (William Yang) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/45fbc417 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/45fbc417 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/45fbc417 Branch: refs/heads/master Commit: 45fbc4177bddacd0e62bbb38258cc94be94a4fe5 Parents: 04f5370 Author: James TaylorAuthored: Sat Oct 15 15:19:47 2016 -0700 Committer: James Taylor Committed: Sat Oct 15 15:19:47 2016 -0700 -- .../apache/phoenix/compile/WhereOptimizer.java | 23 - .../phoenix/compile/WhereOptimizerTest.java | 53 .../java/org/apache/phoenix/util/TestUtil.java | 7 +++ 3 files changed, 81 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/45fbc417/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index f49aa52..f15a251 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -750,12 +750,31 @@ public class WhereOptimizer { } } } else { +boolean hasFirstSlot = true; +boolean prevIsNull = false; // TODO: Do the same optimization that we do for IN if the childSlots specify a fully qualified row key for (KeySlot slot : childSlot) { -// We have a nested OR with nothing for this slot, so continue +if (hasFirstSlot) { +// if the first slot is null, return null immediately +if (slot == null) { +return null; +} +// mark that we've handled the first slot +hasFirstSlot = false; +} + +// now if current slot is the first one, it must not be null +// if not the first, then it might be null, so check if all the rest are null if (slot == null) { -return null; //If one childSlot does not have the PK columns, let Phoenix scan all the key ranges of the table. +prevIsNull = true; +continue; +} else { +// current slot is not null but prev one is null, cannot OR these together (PHOENIX-3328) +if (prevIsNull) { +return null; +} } + /* * If we see a different PK column than before, we can't * optimize it because our SkipScanFilter only handles http://git-wip-us.apache.org/repos/asf/phoenix/blob/45fbc417/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java -- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java index a116a2c..e056c47 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java @@ -19,6 +19,7 @@ package org.apache.phoenix.compile; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; import static org.apache.phoenix.util.TestUtil.BINARY_NAME; +import static org.apache.phoenix.util.TestUtil.BTABLE_NAME; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.assertDegenerate; import static org.apache.phoenix.util.TestUtil.assertEmptyScanKey; @@ -28,6 +29,7 @@ import static org.apache.phoenix.util.TestUtil.rowKeyFilter; import static org.apache.phoenix.util.TestUtil.substr; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -38,6 +40,7 @@