You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gr...@apache.org on 2014/05/22 09:26:26 UTC

[1/2] git commit: PHOENIX-979 Delete on key and non-key field

Repository: incubator-phoenix
Updated Branches:
  refs/heads/master 5db15f09f -> 6c3b6524e


PHOENIX-979 Delete on key and non-key field

Correct behavior of a delete that is filtered by a combination
of the full row key and a single non-key field.


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

Branch: refs/heads/master
Commit: 4954c7371cf88dc19d314bb81b178100fae315f8
Parents: 5db15f0
Author: Gabriel Reid <gr...@apache.org>
Authored: Tue May 20 20:06:33 2014 +0200
Committer: Gabriel Reid <ga...@ngdata.com>
Committed: Thu May 22 07:05:03 2014 +0200

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/DeleteIT.java    | 66 ++++++++++++++++----
 .../apache/phoenix/compile/DeleteCompiler.java  |  9 ++-
 2 files changed, 61 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/4954c737/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
index 03d5ccc..4d41141 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java
@@ -70,24 +70,68 @@ public class DeleteIT extends BaseHBaseManagedTimeIT {
     private void testDeleteFilter(boolean autoCommit) throws Exception {
         Connection conn = DriverManager.getConnection(getUrl());
         initTableValues(conn);
-        
-        ResultSet rs;
-        rs = conn.createStatement().executeQuery("SELECT count(*) FROM IntIntKeyTest");
-        assertTrue(rs.next());
-        assertEquals(NUMBER_OF_ROWS, rs.getInt(1));
 
-        String deleteStmt ;
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS);
+        
         conn.setAutoCommit(autoCommit);
-        deleteStmt = "DELETE FROM IntIntKeyTest WHERE 20 = j";
+        String deleteStmt = "DELETE FROM IntIntKeyTest WHERE 20 = j";
         assertEquals(1,conn.createStatement().executeUpdate(deleteStmt));
         if (!autoCommit) {
             conn.commit();
         }
-        
-        String query = "SELECT count(*) FROM IntIntKeyTest";
-        rs = conn.createStatement().executeQuery(query);
+
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS - 1);
+    }
+
+    @Test
+    public void testDeleteByRowAndFilterAutoCommit() throws SQLException {
+        testDeleteByFilterAndRow(true);
+    }
+
+
+    @Test
+    public void testDeleteByRowAndFilterNoAutoCommit() throws SQLException {
+        testDeleteByFilterAndRow(false);
+    }
+
+    private void testDeleteByFilterAndRow(boolean autoCommit) throws SQLException {
+        Connection conn = DriverManager.getConnection(getUrl());
+        initTableValues(conn);
+
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS);
+
+        conn.setAutoCommit(autoCommit);
+
+        Statement stmt = conn.createStatement();
+
+        // This shouldn't delete anything, because the key matches but the filter doesn't
+        assertEquals(0, stmt.executeUpdate("DELETE FROM IntIntKeyTest WHERE i = 1 AND j = 1"));
+        if (!autoCommit) {
+            conn.commit();
+        }
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS);
+
+        // This shouldn't delete anything, because the filter matches but the key doesn't
+        assertEquals(0, stmt.executeUpdate("DELETE FROM IntIntKeyTest WHERE i = -1 AND j = 20"));
+        if (!autoCommit) {
+            conn.commit();
+        }
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS);
+
+        // This should do a delete, because both the filter and key match
+        assertEquals(1, stmt.executeUpdate("DELETE FROM IntIntKeyTest WHERE i = 1 AND j = 10"));
+        if (!autoCommit) {
+            conn.commit();
+        }
+        assertTableCount(conn, "IntIntKeyTest", NUMBER_OF_ROWS - 1);
+
+    }
+
+    private void assertTableCount(Connection conn, String tableName, int expectedNumberOfRows) throws SQLException {
+        ResultSet rs = conn.createStatement().executeQuery("SELECT count(*) FROM " + tableName);
         assertTrue(rs.next());
-        assertEquals(NUMBER_OF_ROWS - 1, rs.getInt(1));
+        assertEquals(expectedNumberOfRows, rs.getInt(1));
+        rs.close();
     }
     
     private static void assertIndexUsed (Connection conn, String query, String indexName, boolean expectedToBeUsed) throws SQLException {

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/4954c737/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index e338280..59a7ce7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -38,6 +38,7 @@ import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.execute.AggregatePlan;
 import org.apache.phoenix.execute.MutationState;
+import org.apache.phoenix.filter.SkipScanFilter;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.index.IndexMetaDataCacheClient;
 import org.apache.phoenix.index.PhoenixIndexCodec;
@@ -227,9 +228,11 @@ public class DeleteCompiler {
         final StatementContext context = plan.getContext();
         // If we're doing a query for a set of rows with no where clause, then we don't need to contact the server at all.
         // A simple check of the none existence of a where clause in the parse node is not sufficient, as the where clause
-        // may have been optimized out. Instead, we check that there's a single filter which must be the SkipScanFilter
-        // in this case.
-        if (noQueryReqd && ! (context.getScan().getFilter() instanceof FilterList) && context.getScanRanges().isPointLookup()) {
+        // may have been optimized out. Instead, we check that there's a single SkipScanFilter
+        if (noQueryReqd
+                && (!context.getScan().hasFilter()
+                    || context.getScan().getFilter() instanceof SkipScanFilter)
+                && context.getScanRanges().isPointLookup()) {
             return new MutationPlan() {
 
                 @Override


[2/2] git commit: PHOENIX-993 Exclude JRuby dependency

Posted by gr...@apache.org.
PHOENIX-993 Exclude JRuby dependency

Exclude JRuby transitive dependency (via HBase) to avoid pulling
in all extra deps that are included in the JRuby uber jar.


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

Branch: refs/heads/master
Commit: 6c3b6524ec98d8299d771d914b12f58529b805d3
Parents: 4954c73
Author: Gabriel Reid <ga...@ngdata.com>
Authored: Wed May 21 09:26:54 2014 +0200
Committer: Gabriel Reid <ga...@ngdata.com>
Committed: Thu May 22 07:05:15 2014 +0200

----------------------------------------------------------------------
 phoenix-core/pom.xml  | 17 ++++++++++++-----
 phoenix-flume/pom.xml | 24 ++++++++++++++++++++++++
 phoenix-pig/pom.xml   | 28 ++++++++++++++++++++++++++++
 pom.xml               | 24 ++++++++++++++++++------
 4 files changed, 82 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/6c3b6524/phoenix-core/pom.xml
----------------------------------------------------------------------
diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index 9ea82a5..074c000 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -252,11 +252,6 @@
       <version>4.0.1</version>
     </dependency>
     <dependency>
-      <groupId>org.jruby</groupId>
-      <artifactId>jruby-complete</artifactId>
-      <version>${jruby.version}</version>
-    </dependency>
-    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
       <version>${log4j.version}</version>
@@ -323,6 +318,12 @@
             <groupId>org.apache.hbase</groupId>
             <artifactId>hbase-testing-util</artifactId>
             <version>${hbase-hadoop1.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>org.jruby</groupId>
+                <artifactId>jruby-complete</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hbase</groupId>
@@ -330,6 +331,12 @@
             <version>${hbase-hadoop1.version}</version>
             <type>test-jar</type>
             <scope>test</scope>
+            <exclusions>
+              <exclusion>
+                <groupId>org.jruby</groupId>
+                <artifactId>jruby-complete</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hbase</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/6c3b6524/phoenix-flume/pom.xml
----------------------------------------------------------------------
diff --git a/phoenix-flume/pom.xml b/phoenix-flume/pom.xml
index 353430b..7677b9e 100644
--- a/phoenix-flume/pom.xml
+++ b/phoenix-flume/pom.xml
@@ -111,6 +111,12 @@
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-testing-util</artifactId>
           <version>${hbase-hadoop1.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -118,6 +124,12 @@
           <version>${hbase-hadoop1.version}</version>
           <type>test-jar</type>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -185,6 +197,12 @@
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-testing-util</artifactId>
           <version>${hbase-hadoop2.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -192,6 +210,12 @@
           <version>${hbase-hadoop2.version}</version>
           <type>test-jar</type>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>        
         <dependency>
           <groupId>org.apache.hbase</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/6c3b6524/phoenix-pig/pom.xml
----------------------------------------------------------------------
diff --git a/phoenix-pig/pom.xml b/phoenix-pig/pom.xml
index 94522d6..ce39a60 100644
--- a/phoenix-pig/pom.xml
+++ b/phoenix-pig/pom.xml
@@ -47,6 +47,10 @@
       <artifactId>pig</artifactId>
     </dependency>
     <dependency>
+      <groupId>joda-time</groupId>
+      <artifactId>joda-time</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
     </dependency>
@@ -85,6 +89,12 @@
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-testing-util</artifactId>
           <version>${hbase-hadoop1.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -92,6 +102,12 @@
           <version>${hbase-hadoop1.version}</version>
           <type>test-jar</type>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -159,6 +175,12 @@
           <groupId>org.apache.hbase</groupId>
           <artifactId>hbase-testing-util</artifactId>
           <version>${hbase-hadoop2.version}</version>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>
@@ -166,6 +188,12 @@
           <version>${hbase-hadoop2.version}</version>
           <type>test-jar</type>
           <scope>test</scope>
+          <exclusions>
+            <exclusion>
+              <groupId>org.jruby</groupId>
+              <artifactId>jruby-complete</artifactId>
+            </exclusion>
+          </exclusions>
         </dependency>
         <dependency>
           <groupId>org.apache.hbase</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/6c3b6524/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 98cb0c5..24fbd1d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,11 +93,11 @@
     <findbugs.version>1.3.2</findbugs.version>
     <jline.version>2.11</jline.version>
     <snappy.version>1.1.0.1</snappy.version>
-    <jruby.version>1.6.8</jruby.version>
     <netty.version>3.6.6.Final</netty.version>
     <commons-codec.version>1.7</commons-codec.version>
     <htrace.version>2.04</htrace.version>
     <collections.version>3.2.1</collections.version>
+    <jodatime.version>2.3</jodatime.version>
 
     <!-- Test Dependencies -->
     <mockito-all.version>1.8.5</mockito-all.version>
@@ -514,11 +514,6 @@
         <version>4.0.1</version>
       </dependency>
       <dependency>
-        <groupId>org.jruby</groupId>
-        <artifactId>jruby-complete</artifactId>
-        <version>${jruby.version}</version>
-      </dependency>
-      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>${log4j.version}</version>
@@ -548,6 +543,11 @@
         <artifactId>commons-collections</artifactId>
         <version>${collections.version}</version>
       </dependency>
+      <dependency>
+        <groupId>joda-time</groupId>
+        <artifactId>joda-time</artifactId>
+        <version>${jodatime.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -584,6 +584,12 @@
             <groupId>org.apache.hbase</groupId>
             <artifactId>hbase-testing-util</artifactId>
             <version>${hbase-hadoop1.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>org.jruby</groupId>
+                <artifactId>jruby-complete</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hbase</groupId>
@@ -669,6 +675,12 @@
             <groupId>org.apache.hbase</groupId>
             <artifactId>hbase-testing-util</artifactId>
             <version>${hbase-hadoop2.version}</version>
+            <exclusions>
+              <exclusion>
+                <groupId>org.jruby</groupId>
+                <artifactId>jruby-complete</artifactId>
+              </exclusion>
+            </exclusions>
           </dependency>
           <dependency>
             <groupId>org.apache.hbase</groupId>