You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/06/09 18:21:38 UTC

[1/4] phoenix git commit: PHOENIX-2942 Order by incorrect for RVC

Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 9c1b85aeb -> ef7ce7c8b


PHOENIX-2942 Order by incorrect for RVC


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

Branch: refs/heads/4.x-HBase-1.1
Commit: ef7ce7c8bcdaea2b36defd65a6e8339385d7a9c1
Parents: f6edc9c
Author: James Taylor <ja...@apache.org>
Authored: Thu Jun 9 11:18:48 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu Jun 9 11:22:51 2016 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/OrderByIT.java   | 29 +++++++++++++++++++
 .../RowValueConstructorExpression.java          | 30 +++++++++++---------
 2 files changed, 45 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ef7ce7c8/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
index 1d31eee..2c880e7 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java
@@ -507,4 +507,33 @@ public class OrderByIT extends BaseHBaseManagedTimeIT {
             conn.close();
         }
     }
+    
+    @Test
+    public void testOrderByRVC() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        String ddl = "create table test1 (testpk varchar not null primary key, l_quantity decimal(15,2), l_discount decimal(15,2))";
+        conn.createStatement().execute(ddl);
+
+        PreparedStatement stmt = conn.prepareStatement("upsert into test1 values ('a',0.1,0.9)");
+        stmt.execute();
+        stmt = conn.prepareStatement(" upsert into test1 values ('b',0.5,0.5)");
+        stmt.execute();
+        stmt = conn.prepareStatement(" upsert into test1 values ('c',0.9,0.1)");
+        stmt.execute();
+        conn.commit();
+
+        ResultSet rs;
+        stmt = conn.prepareStatement("select l_discount,testpk from test1 order by (l_discount,l_quantity)");
+        rs = stmt.executeQuery();
+        assertTrue(rs.next());
+        assertEquals(0.1, rs.getDouble(1), 0.01);
+        assertEquals("c", rs.getString(2));
+        assertTrue(rs.next());
+        assertEquals(0.5, rs.getDouble(1), 0.01);
+        assertEquals("b", rs.getString(2));
+        assertTrue(rs.next());
+        assertEquals(0.9, rs.getDouble(1), 0.01);
+        assertEquals("a", rs.getString(2));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ef7ce7c8/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
index 481368c..15f6e3e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/RowValueConstructorExpression.java
@@ -44,7 +44,7 @@ public class RowValueConstructorExpression extends BaseCompoundExpression {
     
     private ImmutableBytesWritable ptrs[];
     private ImmutableBytesWritable literalExprPtr;
-    private int counter;
+    private int partialEvalIndex = -1;
     private int estimatedByteSize;
 
     public RowValueConstructorExpression() {
@@ -52,7 +52,6 @@ public class RowValueConstructorExpression extends BaseCompoundExpression {
     
     public RowValueConstructorExpression(List<Expression> children, boolean isConstant) {
         super(children);
-        counter = 0;
         estimatedByteSize = 0;
         init(isConstant);
     }
@@ -108,9 +107,10 @@ public class RowValueConstructorExpression extends BaseCompoundExpression {
     
     @Override
     public void reset() {
-        counter = 0;
+        partialEvalIndex = 0;
         estimatedByteSize = 0;
         Arrays.fill(ptrs, null);
+        super.reset();
     }
     
     private static int getExpressionByteCount(Expression e) {
@@ -132,30 +132,32 @@ public class RowValueConstructorExpression extends BaseCompoundExpression {
             return true;
         }
         try {
-            int j;
-            int expressionCount = counter;
-            for(j = counter; j < ptrs.length; j++) {
-                final Expression expression = children.get(j);
+            boolean isPartialEval = this.partialEvalIndex >= 0;
+            int evalIndex = isPartialEval ? this.partialEvalIndex : 0;
+            int expressionCount = evalIndex;
+            for(; evalIndex < ptrs.length; evalIndex++) {
+                final Expression expression = children.get(evalIndex);
                 // TODO: handle overflow and underflow
                 if (expression.evaluate(tuple, ptr)) {
                     if (ptr.getLength() == 0) {
                         estimatedByteSize += getExpressionByteCount(expression);
                     } else {
-                        expressionCount = j+1;
-                        ptrs[j] = new ImmutableBytesWritable();
-                        ptrs[j].set(ptr.get(), ptr.getOffset(), ptr.getLength());
+                        expressionCount = evalIndex+1;
+                        ptrs[evalIndex] = new ImmutableBytesWritable();
+                        ptrs[evalIndex].set(ptr.get(), ptr.getOffset(), ptr.getLength());
                         estimatedByteSize += ptr.getLength() + (expression.getDataType().isFixedWidth() ? 0 : 1); // 1 extra for the separator byte.
                     }
-                    counter++;
                 } else if (tuple == null || tuple.isImmutable()) {
                     estimatedByteSize += getExpressionByteCount(expression);
-                    counter++;
-                } else {
+                } else { // Cannot yet be evaluated
                     return false;
                 }
             }
+            if (isPartialEval) {
+                this.partialEvalIndex = evalIndex; // Move counter forward
+            }
             
-            if (j == ptrs.length) {
+            if (evalIndex == ptrs.length) {
                 if (expressionCount == 0) {
                     ptr.set(ByteUtil.EMPTY_BYTE_ARRAY);
                     return true;


[2/4] phoenix git commit: PHOENIX-2924 Remove staging repository once Apache Tephra 0.8.0 is released

Posted by ja...@apache.org.
PHOENIX-2924 Remove staging repository once Apache Tephra 0.8.0 is released


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

Branch: refs/heads/4.x-HBase-1.1
Commit: c87c7c400cfade25c72ecea13b16d0f367194111
Parents: dfb67c8
Author: James Taylor <ja...@apache.org>
Authored: Thu May 26 13:33:08 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu Jun 9 11:22:51 2016 -0700

----------------------------------------------------------------------
 pom.xml | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c87c7c40/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 598c1b4..71c7623 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,10 +37,6 @@
 
   <repositories>
     <repository>
-      <id>apache tephra staging</id>
-      <url>https://repository.apache.org/content/repositories/orgapachetephra-1001</url>
-    </repository>
-    <repository>
       <id>apache release</id>
       <url>https://repository.apache.org/content/repositories/releases/</url>
     </repository>


[4/4] phoenix git commit: PHOENIX-2899 Add test for inflight transactions over partially evaluating filters

Posted by ja...@apache.org.
PHOENIX-2899 Add test for inflight transactions over partially evaluating filters


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

Branch: refs/heads/4.x-HBase-1.1
Commit: dfb67c894579f5d80ea78a84ec0151825a13eae4
Parents: 9c1b85a
Author: James Taylor <ja...@apache.org>
Authored: Sat May 21 10:22:34 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu Jun 9 11:22:51 2016 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/tx/TransactionIT.java    | 48 +++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/dfb67c89/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
index 6628d14..d3f54fe 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
@@ -26,13 +26,13 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.sql.Connection;
+import java.sql.DatabaseMetaData;
 import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import java.sql.DatabaseMetaData;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -894,4 +894,50 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
                 "false", rs2.getString(PhoenixDatabaseMetaData.TRANSACTIONAL));
         }
     }
+
+    @Test
+    public void testInflightPartialEval() throws SQLException {
+
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            String transactTableName = "TR";
+            Statement stmt = conn.createStatement();
+            stmt.execute("CREATE TABLE " + transactTableName + " (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) " +
+                "TRANSACTIONAL=true");
+            
+            try (Connection conn1 = DriverManager.getConnection(getUrl()); Connection conn2 = DriverManager.getConnection(getUrl())) {
+                conn1.createStatement().execute("UPSERT INTO tr VALUES ('a','b','x')");
+                // Select to force uncommitted data to be written
+                ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM tr");
+                assertTrue(rs.next());
+                assertEquals("a", rs.getString(1));
+                assertEquals("b", rs.getString(2));
+                assertFalse(rs.next());
+                
+                conn2.createStatement().execute("UPSERT INTO tr VALUES ('a','c','x')");
+                // Select to force uncommitted data to be written
+                rs = conn2.createStatement().executeQuery("SELECT * FROM tr");
+                assertTrue(rs.next());
+                assertEquals("a", rs.getString(1));
+                assertEquals("c", rs.getString(2));
+                assertFalse(rs.next());
+                
+                // If the AndExpression were to see the uncommitted row from conn2, the filter would
+                // filter the row out early and no longer continue to evaluate other cells due to
+                // the way partial evaluation holds state.
+                rs = conn1.createStatement().executeQuery("SELECT * FROM tr WHERE v1 != 'c' AND v2 = 'x'");
+                assertTrue(rs.next());
+                assertEquals("a", rs.getString(1));
+                assertEquals("b", rs.getString(2));
+                assertFalse(rs.next());
+                
+                // Same as above for conn1 data
+                rs = conn2.createStatement().executeQuery("SELECT * FROM tr WHERE v1 != 'b' AND v2 = 'x'");
+                assertTrue(rs.next());
+                assertEquals("a", rs.getString(1));
+                assertEquals("c", rs.getString(2));
+                assertFalse(rs.next());
+            }
+
+        }
+    }
 }


[3/4] phoenix git commit: PHOENIX-2898 HTable not closed in ConnectionQueryServicesImpl (Alex Araujo)

Posted by ja...@apache.org.
PHOENIX-2898 HTable not closed in ConnectionQueryServicesImpl (Alex Araujo)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: f6edc9c1292c406fa8c6a89f23e4fc5dac7c38fd
Parents: c87c7c4
Author: James Taylor <ja...@apache.org>
Authored: Thu May 26 14:41:23 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu Jun 9 11:22:51 2016 -0700

----------------------------------------------------------------------
 .../phoenix/query/ConnectionQueryServicesImpl.java      | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6edc9c1/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index f593dd0..888c481 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1150,6 +1150,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
         boolean isIncompatible = false;
         int minHBaseVersion = Integer.MAX_VALUE;
         boolean isTableNamespaceMappingEnabled = false;
+        HTableInterface ht = null;
         try {
             List<HRegionLocation> locations = this
                     .getAllTableRegions(metaTable);
@@ -1164,8 +1165,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                 }
             }
 
-            HTableInterface ht = this
-                    .getTable(metaTable);
+            ht = this.getTable(metaTable);
             final Map<byte[], Long> results =
                     ht.coprocessorService(MetaDataService.class, null, null, new Batch.Call<MetaDataService,Long>() {
                         @Override
@@ -1213,6 +1213,14 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
             throw new SQLExceptionInfo.Builder(SQLExceptionCode.INCOMPATIBLE_CLIENT_SERVER_JAR).setRootCause(t)
                 .setMessage("Ensure that " + QueryConstants.DEFAULT_COPROCESS_PATH + " is put on the classpath of HBase in every region server: " + t.getMessage())
                 .build().buildException();
+        } finally {
+            if (ht != null) {
+                try {
+                    ht.close();
+                } catch (IOException e) {
+                    logger.warn("Could not close HTable", e);
+                }
+            }
         }
         if (isIncompatible) {
             buf.setLength(buf.length()-1);