phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [4/4] phoenix git commit: PHOENIX-2899 Add test for inflight transactions over partially evaluating filters
Date Thu, 09 Jun 2016 18:25:06 GMT
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/965edb3b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/965edb3b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/965edb3b

Branch: refs/heads/4.x-HBase-1.0
Commit: 965edb3b6770459123193a72ae1ab450fcae89b5
Parents: b1e1118
Author: James Taylor <jamestaylor@apache.org>
Authored: Sat May 21 10:22:34 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Thu Jun 9 11:26:29 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/phoenix/blob/965edb3b/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 aa2088d..2429e7e 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
@@ -893,4 +893,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());
+            }
+
+        }
+    }
 }


Mime
View raw message