Apache-Phoenix | Master | Build Successful

2014-11-24 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master/lastCompletedBuild/testReport/

Changes
[jtaylor] Upgrade to 4.12 Junit and update tests by removing @Category (Samarth Jain)



Apache-Phoenix | 4.0 | Build Successful

2014-11-24 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1346 the choice of index by phoneix is not correct where do querying



Jenkins build is back to normal : Phoenix | 4.2 #19

2014-11-24 Thread Apache Jenkins Server
See 



[2/3] phoenix git commit: Upgrade to 4.12 Junit and update tests by removing @Category (Samarth Jain)

2014-11-24 Thread jamestaylor
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java
index c35ecab..bb09793 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledOrderByIT.java
@@ -22,9 +22,8 @@ import java.util.Map;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
 
-@Category(ClientManagedTimeTest.class)
+
 public class SpooledOrderByIT extends OrderByIT {
 
 @BeforeClass

http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java
index d602423..c646622 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledSortMergeJoinIT.java
@@ -22,11 +22,10 @@ import java.util.Map;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.junit.BeforeClass;
-import org.junit.experimental.categories.Category;
 
 import com.google.common.collect.Maps;
 
-@Category(HBaseManagedTimeTest.class)
+
 public class SpooledSortMergeJoinIT extends SortMergeJoinIT {
 
 public SpooledSortMergeJoinIT(String[] indexDDL, String[] plans) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java
new file mode 100644
index 000..4e3f54f
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+package org.apache.phoenix.end2end;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.phoenix.query.QueryServices;
+import org.junit.Before;
+import org.junit.Test;
+
+
+
+public class SpooledTmpFileDeleteIT extends BaseClientManagedTimeIT {
+   private Connection conn = null;
+   private Properties props = null;
+
+   @Before 
+   public void setup() throws SQLException {
+   props = new Properties();
+   props.put(QueryServices.SPOOL_DIRECTORY, "/tmp"); 
+   props.setProperty(QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, 
Integer.toString(1));
+   conn = DriverManager.getConnection(getUrl(), props);
+   Statement stmt = conn.createStatement();
+   stmt.execute("CREATE TABLE test (ID varchar NOT NULL PRIMARY 
KEY) SPLIT ON ('EA','EZ')");
+   stmt.execute("UPSERT INTO test VALUES ('AA')");
+   stmt.execute("UPSERT INTO test VALUES ('EB')");
+   stmt.execute("UPSERT INTO test VALUES ('FA')");
+   stmt.close();
+   conn.commit();
+   }
+
+   @Test
+   public void testDeleteAllSpooledTmpFiles() throws SQLException, 
Throwable {
+   File dir = new File("/tmp");
+   File[] files = null; 
+
+   class FilenameFilter impleme

[1/3] phoenix git commit: Upgrade to 4.12 Junit and update tests by removing @Category (Samarth Jain)

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master bff5ddae1 -> 039817861


http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java
index be85635..a4901cf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/DelegateColumn.java
@@ -17,10 +17,6 @@
  */
 package org.apache.phoenix.schema;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.phoenix.util.SizedUtil;
 
 public class DelegateColumn extends DelegateDatum implements PColumn {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
index 265fc78..159e0c9 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/PhoenixMetricsSink.java
@@ -17,12 +17,23 @@
  */
 package org.apache.phoenix.trace;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterators;
-import org.apache.commons.configuration.Configuration;
+import static org.apache.phoenix.metrics.MetricInfo.ANNOTATION;
+import static org.apache.phoenix.metrics.MetricInfo.DESCRIPTION;
+import static org.apache.phoenix.metrics.MetricInfo.END;
+import static org.apache.phoenix.metrics.MetricInfo.HOSTNAME;
+import static org.apache.phoenix.metrics.MetricInfo.PARENT;
+import static org.apache.phoenix.metrics.MetricInfo.SPAN;
+import static org.apache.phoenix.metrics.MetricInfo.START;
+import static org.apache.phoenix.metrics.MetricInfo.TAG;
+import static org.apache.phoenix.metrics.MetricInfo.TRACE;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
 import org.apache.commons.configuration.SubsetConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -31,20 +42,15 @@ import org.apache.hadoop.metrics2.AbstractMetric;
 import org.apache.hadoop.metrics2.MetricsRecord;
 import org.apache.hadoop.metrics2.MetricsSink;
 import org.apache.hadoop.metrics2.MetricsTag;
-import org.apache.phoenix.metrics.*;
+import org.apache.phoenix.metrics.MetricInfo;
+import org.apache.phoenix.metrics.Metrics;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.trace.util.Tracing;
 import org.apache.phoenix.util.QueryUtil;
 
-import javax.annotation.Nullable;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.*;
-
-import static org.apache.phoenix.metrics.MetricInfo.*;
-import static org.apache.phoenix.metrics.MetricInfo.HOSTNAME;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
 
 /**
  * Write the metrics to a phoenix table.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/03981786/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java
index 3c8a6df..375b754 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/write/TestWALRecoveryCaching.java
@@ -56,7 +56,6 @@ import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
 import org.apache.phoenix.hbase.index.IndexTestingUtils;
 import org.apache.phoenix.hbase.index.Indexer;
 import org.apache.phoenix.hbase.index.TableName;
@@ -72,7 +71,6 @@ import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 import com.google.common.collect.Multimap;
 

[3/3] phoenix git commit: Upgrade to 4.12 Junit and update tests by removing @Category (Samarth Jain)

2014-11-24 Thread jamestaylor
Upgrade to 4.12 Junit and update tests by removing @Category (Samarth Jain)


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

Branch: refs/heads/master
Commit: 0398178617cb2aeac3661510395635b9d00f814d
Parents: bff5dda
Author: James Taylor 
Authored: Mon Nov 24 22:41:49 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 22:41:49 2014 -0800

--
 ...ReplayWithIndexWritesAndCompressedWALIT.java |   3 +
 .../apache/phoenix/end2end/AlterTableIT.java|   3 +-
 .../phoenix/end2end/ArithmeticQueryIT.java  |   3 +-
 .../org/apache/phoenix/end2end/ArrayIT.java |   2 -
 .../apache/phoenix/end2end/AutoCommitIT.java|   3 +-
 .../BaseOwnClusterClientManagedTimeIT.java  |   3 +-
 .../BaseOwnClusterHBaseManagedTimeIT.java   |   3 +-
 .../org/apache/phoenix/end2end/BaseQueryIT.java |   2 -
 .../end2end/BaseTenantSpecificTablesIT.java |   3 +-
 .../end2end/BaseTenantSpecificViewIndexIT.java  |   1 +
 .../org/apache/phoenix/end2end/BaseViewIT.java  |   3 +-
 .../apache/phoenix/end2end/BinaryRowKeyIT.java  |   3 +-
 .../phoenix/end2end/CSVCommonsLoaderIT.java |   3 +-
 .../apache/phoenix/end2end/CaseStatementIT.java |   2 -
 .../apache/phoenix/end2end/CastAndCoerceIT.java |   2 -
 .../end2end/ClientTimeArithmeticQueryIT.java|   3 +-
 .../phoenix/end2end/CoalesceFunctionIT.java |   3 +-
 .../end2end/ColumnProjectionOptimizationIT.java |   4 +-
 .../phoenix/end2end/CompareDecimalToLongIT.java |   3 +-
 .../end2end/ConvertTimezoneFunctionIT.java  |   3 +-
 .../end2end/CountDistinctCompressionIT.java |   3 +-
 .../apache/phoenix/end2end/CreateTableIT.java   |   3 +-
 .../phoenix/end2end/CustomEntityDataIT.java |   3 +-
 .../phoenix/end2end/DecodeFunctionIT.java   |   3 +-
 .../org/apache/phoenix/end2end/DeleteIT.java|   3 +-
 .../apache/phoenix/end2end/DerivedTableIT.java  |   3 +-
 .../apache/phoenix/end2end/DistinctCountIT.java |   3 +-
 .../apache/phoenix/end2end/DynamicColumnIT.java |   4 +-
 .../apache/phoenix/end2end/DynamicFamilyIT.java |   4 +-
 .../apache/phoenix/end2end/DynamicUpsertIT.java |   3 +-
 .../phoenix/end2end/EvaluationOfORIT.java   |   3 +-
 .../phoenix/end2end/ExecuteStatementsIT.java|   3 +-
 .../phoenix/end2end/ExtendedQueryExecIT.java|   3 +-
 .../phoenix/end2end/FirstValueFunctionIT.java   |  11 +-
 .../apache/phoenix/end2end/FunkyNamesIT.java|   3 +-
 .../apache/phoenix/end2end/GroupByCaseIT.java   |   3 +-
 .../org/apache/phoenix/end2end/GroupByIT.java   |   3 +-
 .../org/apache/phoenix/end2end/HashJoinIT.java  |   3 +-
 .../org/apache/phoenix/end2end/InListIT.java|   4 +-
 .../phoenix/end2end/InMemoryOrderByIT.java  |   3 +-
 .../org/apache/phoenix/end2end/IsNullIT.java|   3 +-
 .../org/apache/phoenix/end2end/KeyOnlyIT.java   |   3 +-
 .../phoenix/end2end/LastValueFunctionIT.java|   3 +-
 .../apache/phoenix/end2end/LpadFunctionIT.java  |   3 +-
 .../apache/phoenix/end2end/MD5FunctionIT.java   |   3 +-
 .../phoenix/end2end/MappingTableDataTypeIT.java |   3 +-
 .../phoenix/end2end/ModulusExpressionIT.java|   5 +-
 .../phoenix/end2end/MultiCfQueryExecIT.java |   3 +-
 .../phoenix/end2end/NativeHBaseTypesIT.java |   3 +-
 .../org/apache/phoenix/end2end/NotQueryIT.java  |   3 +-
 .../phoenix/end2end/NthValueFunctionIT.java |   3 +-
 .../org/apache/phoenix/end2end/OrderByIT.java   |   3 +-
 .../phoenix/end2end/ParallelIteratorsIT.java|   3 +-
 .../apache/phoenix/end2end/PercentileIT.java|   3 +-
 .../phoenix/end2end/ProductMetricsIT.java   |   3 +-
 .../end2end/QueryDatabaseMetaDataIT.java|   3 +-
 .../phoenix/end2end/QueryExecWithoutSCNIT.java  |   3 +-
 .../org/apache/phoenix/end2end/QueryIT.java |   3 +-
 .../org/apache/phoenix/end2end/QueryMoreIT.java |   3 +-
 .../phoenix/end2end/QueryWithLimitIT.java   |   3 +-
 .../phoenix/end2end/ReadIsolationLevelIT.java   |   3 +-
 .../org/apache/phoenix/end2end/ReadOnlyIT.java  |   3 +-
 .../phoenix/end2end/RegexpSplitFunctionIT.java  |   3 +-
 .../phoenix/end2end/RegexpSubstrFunctionIT.java |   3 +-
 .../phoenix/end2end/ReverseFunctionIT.java  |   3 +-
 .../apache/phoenix/end2end/ReverseScanIT.java   |   3 +-
 .../RoundFloorCeilFunctionsEnd2EndIT.java   |   3 +-
 .../phoenix/end2end/RowValueConstructorIT.java  |   3 +-
 .../apache/phoenix/end2end/SaltedViewIT.java|   3 +-
 .../org/apache/phoenix/end2end/ScanQueryIT.java |   3 +-
 .../org/apache/phoenix/end2end/SequenceIT.java  |   3 +-
 .../phoenix/end2end/ServerExceptionIT.java  |   3 +-
 .../end2end/SkipScanAfterManualSplitIT.java |   3 +-
 .../apache/phoenix/end2end/SkipScanQueryIT.java |   3 +-
 .../apache/phoenix/end2end/SortMergeJoinIT.java |   3 +-
 .../apache/phoe

Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2014-11-24 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1346 the choice of index by phoneix is not correct where do querying



Jenkins build is back to normal : Phoenix | Master #497

2014-11-24 Thread Apache Jenkins Server
See 



phoenix git commit: PHOENIX-1346 the choice of index by phoneix is not correct where do querying

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.2 0669b66e4 -> a94e4a07b


PHOENIX-1346 the choice of index by phoneix is not correct where do querying

Conflicts:

phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java


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

Branch: refs/heads/3.2
Commit: a94e4a07bde80857e54c967b1196a652b8ecbb5d
Parents: 0669b66
Author: James Taylor 
Authored: Mon Nov 24 21:26:28 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 21:36:19 2014 -0800

--
 .../org/apache/phoenix/optimize/QueryOptimizer.java   | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a94e4a07/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index e809dff..409a8d5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -311,13 +311,12 @@ public class QueryOptimizer {
 public int compare(QueryPlan plan1, QueryPlan plan2) {
 PTable table1 = plan1.getTableRef().getTable();
 PTable table2 = plan2.getTableRef().getTable();
-int c = plan2.getContext().getScanRanges().getRanges().size() 
- plan1.getContext().getScanRanges().getRanges().size();
-// Account for potential view constants which are always bound
-if (plan1 == dataPlan) { // plan2 is index plan. Ignore the 
viewIndexId if present
-c += boundRanges - (table2.getViewIndexId() == null ? 0 : 
1);
-} else { // plan1 is index plan. Ignore the viewIndexId if 
present
-c -= boundRanges - (table1.getViewIndexId() == null ? 0 : 
1);
-}
+
+// For shared indexes (i.e. indexes on views and local 
indexes),
+// a) add back any view constants as these won't be in the 
index, and
+// b) ignore the viewIndexId which will be part of the row key 
columns.
+int c = (plan2.getContext().getScanRanges().getRanges().size() 
+ (table2.getViewIndexId() == null ? 0 : (boundRanges - 1))) - 
+(plan1.getContext().getScanRanges().getRanges().size() 
+ (table1.getViewIndexId() == null ? 0 : (boundRanges - 1)));
 if (c != 0) return c;
 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {
 if (plan1.getGroupBy().isOrderPreserving() != 
plan2.getGroupBy().isOrderPreserving()) {
@@ -328,6 +327,7 @@ public class QueryOptimizer {
 c = (table1.getColumns().size() - 
table1.getPKColumns().size()) - (table2.getColumns().size() - 
table2.getPKColumns().size());
 if (c != 0) return c;
 
+
 // All things being equal, just use the table based on the 
Hint.USE_DATA_OVER_INDEX_TABLE
 if (plan1.getTableRef().getTable().getType() == 
PTableType.INDEX) {
 return comparisonOfDataVersusIndexTable;



phoenix git commit: PHOENIX-1346 the choice of index by phoneix is not correct where do querying

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.0 1ec6498ca -> c8b86f325


PHOENIX-1346 the choice of index by phoneix is not correct where do querying

Conflicts:

phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java


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

Branch: refs/heads/3.0
Commit: c8b86f3255842542627b0d71f2073ae795ee9b42
Parents: 1ec6498
Author: James Taylor 
Authored: Mon Nov 24 21:26:28 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 21:35:37 2014 -0800

--
 .../org/apache/phoenix/optimize/QueryOptimizer.java   | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c8b86f32/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index 81d32f9..d821e2a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -311,13 +311,12 @@ public class QueryOptimizer {
 public int compare(QueryPlan plan1, QueryPlan plan2) {
 PTable table1 = plan1.getTableRef().getTable();
 PTable table2 = plan2.getTableRef().getTable();
-int c = plan2.getContext().getScanRanges().getRanges().size() 
- plan1.getContext().getScanRanges().getRanges().size();
-// Account for potential view constants which are always bound
-if (plan1 == dataPlan) { // plan2 is index plan. Ignore the 
viewIndexId if present
-c += boundRanges - (table2.getViewIndexId() == null ? 0 : 
1);
-} else { // plan1 is index plan. Ignore the viewIndexId if 
present
-c -= boundRanges - (table1.getViewIndexId() == null ? 0 : 
1);
-}
+
+// For shared indexes (i.e. indexes on views and local 
indexes),
+// a) add back any view constants as these won't be in the 
index, and
+// b) ignore the viewIndexId which will be part of the row key 
columns.
+int c = (plan2.getContext().getScanRanges().getRanges().size() 
+ (table2.getViewIndexId() == null ? 0 : (boundRanges - 1))) - 
+(plan1.getContext().getScanRanges().getRanges().size() 
+ (table1.getViewIndexId() == null ? 0 : (boundRanges - 1)));
 if (c != 0) return c;
 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {
 if (plan1.getGroupBy().isOrderPreserving() != 
plan2.getGroupBy().isOrderPreserving()) {
@@ -328,6 +327,7 @@ public class QueryOptimizer {
 c = (table1.getColumns().size() - 
table1.getPKColumns().size()) - (table2.getColumns().size() - 
table2.getPKColumns().size());
 if (c != 0) return c;
 
+
 // All things being equal, just use the table based on the 
Hint.USE_DATA_OVER_INDEX_TABLE
 if (plan1.getTableRef().getTable().getType() == 
PTableType.INDEX) {
 return comparisonOfDataVersusIndexTable;



phoenix git commit: PHOENIX-1346 the choice of index by phoneix is not correct where do querying

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.2 91210733a -> 2d7ea61d4


PHOENIX-1346 the choice of index by phoneix is not correct where do querying


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2d7ea61d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2d7ea61d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2d7ea61d

Branch: refs/heads/4.2
Commit: 2d7ea61d4f6d6697c5f21a30e366cc85595c473f
Parents: 9121073
Author: James Taylor 
Authored: Mon Nov 24 21:26:28 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 21:31:21 2014 -0800

--
 .../apache/phoenix/optimize/QueryOptimizer.java | 26 ++--
 1 file changed, 8 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d7ea61d/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index c5bf741..ca89dc2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -316,21 +316,11 @@ public class QueryOptimizer {
 public int compare(QueryPlan plan1, QueryPlan plan2) {
 PTable table1 = plan1.getTableRef().getTable();
 PTable table2 = plan2.getTableRef().getTable();
-int c = plan2.getContext().getScanRanges().getRanges().size() 
- plan1.getContext().getScanRanges().getRanges().size();
-boolean bothLocalIndexes = table1.getIndexType() == 
IndexType.LOCAL && table2.getIndexType() == IndexType.LOCAL;
-// Account for potential view constants which are always bound
-if (plan1 == dataPlan) { // plan2 is index plan. Ignore the 
viewIndexId if present
-c += boundRanges - (table2.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table2 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if(table2.getIndexType()==IndexType.LOCAL && 
plan2.getContext().getScanRanges().getRanges().size()==0) c++;
-} else { // plan1 is index plan. Ignore the viewIndexId if 
present
-c -= boundRanges - (table1.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table1 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if (!bothLocalIndexes && table1.getIndexType() == 
IndexType.LOCAL
-&& 
plan1.getContext().getScanRanges().getRanges().isEmpty()) c--;
-}
+// For shared indexes (i.e. indexes on views and local 
indexes),
+// a) add back any view constants as these won't be in the 
index, and
+// b) ignore the viewIndexId which will be part of the row key 
columns.
+int c = (plan2.getContext().getScanRanges().getRanges().size() 
+ (table2.getViewIndexId() == null ? 0 : (boundRanges - 1))) - 
+(plan1.getContext().getScanRanges().getRanges().size() 
+ (table1.getViewIndexId() == null ? 0 : (boundRanges - 1)));
 if (c != 0) return c;
 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {
 if (plan1.getGroupBy().isOrderPreserving() != 
plan2.getGroupBy().isOrderPreserving()) {
@@ -342,12 +332,12 @@ public class QueryOptimizer {
 if (c != 0) return c;
 
 // If all things are equal, don't choose local index as it 
forces scan
-// on every region.
+// on every region (unless there's no start/stop key)
 if (table1.getIndexType() == IndexType.LOCAL) {
-return 1;
+return 
plan1.getContext().getScanRanges().getRanges().isEmpty() ? -1 : 1;
 }
 if (table2.getIndexType() == IndexType.LOCAL) {
-return -1;
+return 
plan2.getContext().getScanRanges().getRanges().isEmpty() ? 1 : -1;
 }
 
 // All things being equal, just use the table based on the 
Hint.USE_DATA_OVER_INDEX_TABLE



phoenix git commit: PHOENIX-1346 the choice of index by phoneix is not correct where do querying

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 b8e7da27f -> 0fdf78e7c


PHOENIX-1346 the choice of index by phoneix is not correct where do querying


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0fdf78e7
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0fdf78e7
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0fdf78e7

Branch: refs/heads/4.0
Commit: 0fdf78e7c4ea8ba6fdb29670dfddb287eea8b8cf
Parents: b8e7da2
Author: James Taylor 
Authored: Mon Nov 24 21:26:28 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 21:30:12 2014 -0800

--
 .../apache/phoenix/optimize/QueryOptimizer.java | 26 ++--
 1 file changed, 8 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0fdf78e7/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index 333b102..a478656 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -317,21 +317,11 @@ public class QueryOptimizer {
 public int compare(QueryPlan plan1, QueryPlan plan2) {
 PTable table1 = plan1.getTableRef().getTable();
 PTable table2 = plan2.getTableRef().getTable();
-int c = plan2.getContext().getScanRanges().getRanges().size() 
- plan1.getContext().getScanRanges().getRanges().size();
-boolean bothLocalIndexes = table1.getIndexType() == 
IndexType.LOCAL && table2.getIndexType() == IndexType.LOCAL;
-// Account for potential view constants which are always bound
-if (plan1 == dataPlan) { // plan2 is index plan. Ignore the 
viewIndexId if present
-c += boundRanges - (table2.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table2 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if(table2.getIndexType()==IndexType.LOCAL && 
plan2.getContext().getScanRanges().getRanges().size()==0) c++;
-} else { // plan1 is index plan. Ignore the viewIndexId if 
present
-c -= boundRanges - (table1.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table1 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if (!bothLocalIndexes && table1.getIndexType() == 
IndexType.LOCAL
-&& 
plan1.getContext().getScanRanges().getRanges().isEmpty()) c--;
-}
+// For shared indexes (i.e. indexes on views and local 
indexes),
+// a) add back any view constants as these won't be in the 
index, and
+// b) ignore the viewIndexId which will be part of the row key 
columns.
+int c = (plan2.getContext().getScanRanges().getRanges().size() 
+ (table2.getViewIndexId() == null ? 0 : (boundRanges - 1))) - 
+(plan1.getContext().getScanRanges().getRanges().size() 
+ (table1.getViewIndexId() == null ? 0 : (boundRanges - 1)));
 if (c != 0) return c;
 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {
 if (plan1.getGroupBy().isOrderPreserving() != 
plan2.getGroupBy().isOrderPreserving()) {
@@ -343,12 +333,12 @@ public class QueryOptimizer {
 if (c != 0) return c;
 
 // If all things are equal, don't choose local index as it 
forces scan
-// on every region.
+// on every region (unless there's no start/stop key)
 if (table1.getIndexType() == IndexType.LOCAL) {
-return 1;
+return 
plan1.getContext().getScanRanges().getRanges().isEmpty() ? -1 : 1;
 }
 if (table2.getIndexType() == IndexType.LOCAL) {
-return -1;
+return 
plan2.getContext().getScanRanges().getRanges().isEmpty() ? 1 : -1;
 }
 
 // All things being equal, just use the table based on the 
Hint.USE_DATA_OVER_INDEX_TABLE



phoenix git commit: PHOENIX-1346 the choice of index by phoneix is not correct where do querying

2014-11-24 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 3f4579038 -> bff5ddae1


PHOENIX-1346 the choice of index by phoneix is not correct where do querying


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

Branch: refs/heads/master
Commit: bff5ddae11ba2ac47804bc6db6afecd5f1bbe76a
Parents: 3f45790
Author: James Taylor 
Authored: Mon Nov 24 21:26:28 2014 -0800
Committer: James Taylor 
Committed: Mon Nov 24 21:26:28 2014 -0800

--
 .../apache/phoenix/optimize/QueryOptimizer.java | 26 ++--
 1 file changed, 8 insertions(+), 18 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bff5ddae/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index 333b102..a478656 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -317,21 +317,11 @@ public class QueryOptimizer {
 public int compare(QueryPlan plan1, QueryPlan plan2) {
 PTable table1 = plan1.getTableRef().getTable();
 PTable table2 = plan2.getTableRef().getTable();
-int c = plan2.getContext().getScanRanges().getRanges().size() 
- plan1.getContext().getScanRanges().getRanges().size();
-boolean bothLocalIndexes = table1.getIndexType() == 
IndexType.LOCAL && table2.getIndexType() == IndexType.LOCAL;
-// Account for potential view constants which are always bound
-if (plan1 == dataPlan) { // plan2 is index plan. Ignore the 
viewIndexId if present
-c += boundRanges - (table2.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table2 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if(table2.getIndexType()==IndexType.LOCAL && 
plan2.getContext().getScanRanges().getRanges().size()==0) c++;
-} else { // plan1 is index plan. Ignore the viewIndexId if 
present
-c -= boundRanges - (table1.getViewIndexId() == null || 
bothLocalIndexes ? 0 : 1);
-// if table1 is local index table and query doesn't have 
any condition on the
-// indexed columns then give first priority to the local 
index.
-if (!bothLocalIndexes && table1.getIndexType() == 
IndexType.LOCAL
-&& 
plan1.getContext().getScanRanges().getRanges().isEmpty()) c--;
-}
+// For shared indexes (i.e. indexes on views and local 
indexes),
+// a) add back any view constants as these won't be in the 
index, and
+// b) ignore the viewIndexId which will be part of the row key 
columns.
+int c = (plan2.getContext().getScanRanges().getRanges().size() 
+ (table2.getViewIndexId() == null ? 0 : (boundRanges - 1))) - 
+(plan1.getContext().getScanRanges().getRanges().size() 
+ (table1.getViewIndexId() == null ? 0 : (boundRanges - 1)));
 if (c != 0) return c;
 if (plan1.getGroupBy()!=null && plan2.getGroupBy()!=null) {
 if (plan1.getGroupBy().isOrderPreserving() != 
plan2.getGroupBy().isOrderPreserving()) {
@@ -343,12 +333,12 @@ public class QueryOptimizer {
 if (c != 0) return c;
 
 // If all things are equal, don't choose local index as it 
forces scan
-// on every region.
+// on every region (unless there's no start/stop key)
 if (table1.getIndexType() == IndexType.LOCAL) {
-return 1;
+return 
plan1.getContext().getScanRanges().getRanges().isEmpty() ? -1 : 1;
 }
 if (table2.getIndexType() == IndexType.LOCAL) {
-return -1;
+return 
plan2.getContext().getScanRanges().getRanges().isEmpty() ? 1 : -1;
 }
 
 // All things being equal, just use the table based on the 
Hint.USE_DATA_OVER_INDEX_TABLE