You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2015/02/12 16:08:41 UTC
drill git commit: DRILL-1872: Assertion failure and empty map on
order by with complex data
Repository: drill
Updated Branches:
refs/heads/master ca28b9cba -> 066b6dbc3
DRILL-1872: Assertion failure and empty map on order by with complex data
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/066b6dbc
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/066b6dbc
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/066b6dbc
Branch: refs/heads/master
Commit: 066b6dbc3a711dac822dd73441b1faedc1bebdfd
Parents: ca28b9c
Author: Parth Chandra <pc...@maprtech.com>
Authored: Mon Feb 2 13:39:39 2015 -0800
Committer: Parth Chandra <pc...@maprtech.com>
Committed: Thu Feb 12 07:08:15 2015 -0800
----------------------------------------------------------------------
.../apache/drill/exec/record/MaterializedField.java | 16 ++++++----------
.../apache/drill/exec/vector/complex/MapVector.java | 9 +++++++++
2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/066b6dbc/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java b/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
index a9f3292..bcc226f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
@@ -181,10 +181,10 @@ public class MaterializedField {
@Override
public int hashCode() {
- final int prime = 31;
int result = 1;
- result = prime * result + ((children == null) ? 0 : children.hashCode());
- result = prime * result + ((key == null) ? 0 : key.hashCode());
+ // DRILL-1872: Compute hashCode only on key. See also the comment
+ // in MapVector$MapTransferPair
+ result = ((key == null) ? 0 : key.hashCode());
return result;
}
@@ -200,13 +200,9 @@ public class MaterializedField {
return false;
}
MaterializedField other = (MaterializedField) obj;
- if (children == null) {
- if (other.children != null) {
- return false;
- }
- } else if (!children.equals(other.children)) {
- return false;
- }
+ // DRILL-1872: Compute equals only on key. See also the comment
+ // in MapVector$MapTransferPair
+
if (key == null) {
if (other.key != null) {
return false;
http://git-wip-us.apache.org/repos/asf/drill/blob/066b6dbc/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
index fb19afa..c5dc5ba 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
@@ -155,6 +155,15 @@ public class MapVector extends AbstractMapVector {
if (vector == null) {
continue;
}
+ //DRILL-1872: we add the child fields for the vector, looking up the field by name. For a map vector,
+ // the child fields may be nested fields of the top level child. For example if the structure
+ // of a child field is oa.oab.oabc then we add oa, then add oab to oa then oabc to oab.
+ // But the children member of a Materialized field is a HashSet. If the fields are added in the
+ // children HashSet, and the hashCode of the Materialized field includes the hash code of the
+ // children, the hashCode value of oa changes *after* the field has been added to the HashSet.
+ // (This is similar to what happens in ScanBatch where the children cannot be added till they are
+ // read). To take care of this, we ensure that the hashCode of the MaterializedField does not
+ // include the hashCode of the children but is based only on MaterializedField$key.
ValueVector newVector = to.addOrGet(child, vector.getField().getType(), vector.getClass());
if (allocate && to.size() != preSize) {
newVector.allocateNew();