DRILL-2066: Clear target vectors before performing transfer()
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/5b2a11b7 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/5b2a11b7 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/5b2a11b7 Branch: refs/heads/master Commit: 5b2a11b7c1b35d78985dfc523fe616a095e95864 Parents: 4277a25 Author: Mehant Baid <meha...@gmail.com> Authored: Fri Jan 23 14:00:46 2015 -0800 Committer: Mehant Baid <meha...@gmail.com> Committed: Fri Jan 23 16:37:36 2015 -0800 ---------------------------------------------------------------------- .../codegen/templates/FixedValueVectors.java | 1 + .../codegen/templates/RepeatedValueVectors.java | 1 + .../templates/VariableLengthVectors.java | 1 + .../drill/exec/physical/impl/sort/TestSort.java | 33 ++++++++++++++++++++ .../jsoninput/repeatedmap_sort_bug.json | 1 + 5 files changed, 37 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/5b2a11b7/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java index 1663534..b6eb084 100644 --- a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java +++ b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java @@ -159,6 +159,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F } public void transferTo(${minor.class}Vector target){ + target.clear(); target.data = data; target.data.retain(); target.data.writerIndex(data.writerIndex()); http://git-wip-us.apache.org/repos/asf/drill/blob/5b2a11b7/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java b/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java index 572181e..d39040e 100644 --- a/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java +++ b/exec/java-exec/src/main/codegen/templates/RepeatedValueVectors.java @@ -100,6 +100,7 @@ public final class Repeated${minor.class}Vector extends BaseValueVector implemen } public void transferTo(Repeated${minor.class}Vector target){ + target.clear(); offsets.transferTo(target.offsets); values.transferTo(target.values); target.parentValueCount = parentValueCount; http://git-wip-us.apache.org/repos/asf/drill/blob/5b2a11b7/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java b/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java index 9c6454e..aa5b702 100644 --- a/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java +++ b/exec/java-exec/src/main/codegen/templates/VariableLengthVectors.java @@ -161,6 +161,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements V } public void transferTo(${minor.class}Vector target){ + target.clear(); this.offsetVector.transferTo(target.offsetVector); target.data = data; target.data.retain(); http://git-wip-us.apache.org/repos/asf/drill/blob/5b2a11b7/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java new file mode 100644 index 0000000..5dc81b5 --- /dev/null +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSort.java @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.physical.impl.sort; + +import org.apache.drill.BaseTestQuery; +import org.junit.Test; + +/** + * Placeholder for all sort related test. Can be used as we move + * more tests to use the new test framework + */ +public class TestSort extends BaseTestQuery { + + @Test + public void testSortWithComplexInput() throws Exception { + test("select t.a from cp.`jsoninput/repeatedmap_sort_bug.json` t order by t.b"); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/drill/blob/5b2a11b7/exec/java-exec/src/test/resources/jsoninput/repeatedmap_sort_bug.json ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/resources/jsoninput/repeatedmap_sort_bug.json b/exec/java-exec/src/test/resources/jsoninput/repeatedmap_sort_bug.json new file mode 100644 index 0000000..1968133 --- /dev/null +++ b/exec/java-exec/src/test/resources/jsoninput/repeatedmap_sort_bug.json @@ -0,0 +1 @@ +{"a" : [ {"c": 1} ], "b" : 2.1} \ No newline at end of file