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 2015/04/20 09:54:11 UTC

phoenix git commit: Work around bug in TableRef comparison

Repository: phoenix
Updated Branches:
  refs/heads/txn 714284d32 -> 9270db150


Work around bug in TableRef comparison


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

Branch: refs/heads/txn
Commit: 9270db150d107c67dbd2e09fedc362862da518a9
Parents: 714284d
Author: James Taylor <jt...@salesforce.com>
Authored: Mon Apr 20 00:54:07 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Mon Apr 20 00:54:07 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/phoenix/execute/MutationState.java |  8 +++++++-
 .../main/java/org/apache/phoenix/schema/TableRef.java  | 13 ++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9270db15/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index e2b6968..7acc7b5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -638,8 +638,14 @@ public class MutationState implements SQLCloseable {
             }
         });
         if (filteredTableRefs.hasNext()) {
+            // FIXME: strip table alias to prevent equality check from failing due to alias mismatch on null alias.
+            // We really should be keying the tables based on the physical table name.
+            List<TableRef> strippedAliases = Lists.newArrayListWithExpectedSize(mutations.keySet().size());
+            while (filteredTableRefs.hasNext()) {
+                strippedAliases.add(new TableRef(filteredTableRefs.next(), null));
+            }
             startTransaction();
-            send(filteredTableRefs);
+            send(strippedAliases.iterator());
             return true;
         }
         return false;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9270db15/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java
index b5351bf..ec3e64b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableRef.java
@@ -36,6 +36,10 @@ public class TableRef {
         this(tableRef.alias, tableRef.table, timeStamp, tableRef.hasDynamicCols);
     }
     
+    public TableRef(TableRef tableRef, String alias) {
+        this(alias, tableRef.table, tableRef.upperBoundTimeStamp, tableRef.hasDynamicCols);
+    }
+    
     public TableRef(PTable table) {
         this(null, table, HConstants.LATEST_TIMESTAMP, false);
     }
@@ -97,7 +101,10 @@ public class TableRef {
     
     @Override
     public int hashCode() {
-        return this.table.getName().getString().hashCode();
+        final int prime = 31;
+        int result = alias == null ? 0 : alias.hashCode();
+        result = prime * result + this.table.getName().getString().hashCode();
+        return result;
     }
 
     @Override
@@ -106,8 +113,8 @@ public class TableRef {
         if (obj == null) return false;
         if (getClass() != obj.getClass()) return false;
         TableRef other = (TableRef)obj;
-        // If alias is null, it matches any other alias
-        if (alias != null && other.alias != null && !alias.equals(other.alias)) return false;
+        // FIXME: a null alias on either side should mean a wildcard and should not fail the equals check
+        if ((alias == null && other.alias != null) || (alias != null && !alias.equals(other.alias))) return false;
         if (!table.getName().getString().equals(other.table.getName().getString())) return false;
         return true;
     }