diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java index 28f6c63..3871955 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java @@ -423,12 +423,14 @@ public ReusableRowContainer() { } public void setFromOutput(Output output) { - if (refs == null) { - refs = new ArrayList(0); + synchronized (hashMap) { + if (refs == null) { + refs = new ArrayList(0); + } + byte aliasFilter = hashMap.getValueRefs(output.getData(), output.getLength(), refs); + this.aliasFilter = refs.isEmpty() ? (byte) 0xff : aliasFilter; + this.dummyRow = null; } - byte aliasFilter = hashMap.getValueRefs(output.getData(), output.getLength(), refs); - this.aliasFilter = refs.isEmpty() ? (byte) 0xff : aliasFilter; - this.dummyRow = null; } public boolean isEmpty() { @@ -478,23 +480,28 @@ public MapJoinRowContainer copy() throws HiveException { @Override public List next() throws HiveException { - if (dummyRow != null) { - List result = dummyRow; - dummyRow = null; - return result; - } - if (currentRow < 0 || refs.size() < currentRow) throw new HiveException("No rows"); - if (refs.size() == currentRow) return null; - WriteBuffers.ByteSegmentRef ref = refs.get(currentRow++); - if (ref.getLength() == 0) { - return EMPTY_LIST; // shortcut, 0 length means no fields - } - if (ref.getBytes() == null) { - hashMap.populateValue(ref); + synchronized (hashMap) { + if (dummyRow != null) { + List result = dummyRow; + dummyRow = null; + return result; + } + if (currentRow < 0 || refs.size() < currentRow) + throw new HiveException("No rows"); + if (refs.size() == currentRow) + return null; + WriteBuffers.ByteSegmentRef ref = refs.get(currentRow++); + if (ref.getLength() == 0) { + return EMPTY_LIST; // shortcut, 0 length means no fields + } + if (ref.getBytes() == null) { + hashMap.populateValue(ref); + } + uselessIndirection.setData(ref.getBytes()); + valueStruct.init(uselessIndirection, (int) ref.getOffset(), ref.getLength()); + return valueStruct.getFieldsAsList(); // TODO: should we unset bytes + // after that? } - uselessIndirection.setData(ref.getBytes()); - valueStruct.init(uselessIndirection, (int)ref.getOffset(), ref.getLength()); - return valueStruct.getFieldsAsList(); // TODO: should we unset bytes after that? } @Override