sohami commented on a change in pull request #1344: DRILL-6461: Added basic 
data correctness tests for hash agg, and improved operator unit testing 
framework.
URL: https://github.com/apache/drill/pull/1344#discussion_r210989987
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/svremover/AbstractGenericCopierTest.java
 ##########
 @@ -20,77 +20,106 @@
 import org.apache.drill.common.types.TypeProtos;
 import org.apache.drill.common.types.Types;
 import org.apache.drill.exec.exception.SchemaChangeException;
-import org.apache.drill.exec.memory.RootAllocator;
+import org.apache.drill.exec.memory.BufferAllocator;
+import org.apache.drill.exec.physical.impl.MockRecordBatch;
 import org.apache.drill.exec.record.BatchSchema;
 import org.apache.drill.exec.record.MaterializedField;
 import org.apache.drill.exec.record.RecordBatch;
 import org.apache.drill.exec.record.VectorContainer;
-import org.apache.drill.exec.record.metadata.TupleMetadata;
+import org.apache.drill.exec.record.VectorWrapper;
 import org.apache.drill.exec.vector.SchemaChangeCallBack;
+import org.apache.drill.test.BaseDirTestWatcher;
+import org.apache.drill.test.OperatorFixture;
+import org.apache.drill.test.rowSet.DirectRowSet;
 import org.apache.drill.test.rowSet.RowSet;
-import org.apache.drill.test.rowSet.RowSetBatch;
 import org.apache.drill.test.rowSet.RowSetBuilder;
 import org.apache.drill.test.rowSet.RowSetComparison;
 import org.apache.drill.test.rowSet.schema.SchemaBuilder;
+import org.junit.Rule;
 import org.junit.Test;
 
 public abstract class AbstractGenericCopierTest {
+  @Rule
+  public final BaseDirTestWatcher baseDirTestWatcher = new 
BaseDirTestWatcher();
+
   @Test
-  public void testCopyRecords() throws SchemaChangeException {
-    try (RootAllocator allocator = new RootAllocator(10_000_000)) {
-      final TupleMetadata batchSchema = 
createTestSchema(BatchSchema.SelectionVectorMode.NONE);
+  public void testCopyRecords() throws Exception {
+    try (OperatorFixture operatorFixture = new 
OperatorFixture.Builder(baseDirTestWatcher).build()) {
+      final BufferAllocator allocator = operatorFixture.allocator();
+      final BatchSchema batchSchema = 
createTestSchema(BatchSchema.SelectionVectorMode.NONE);
       final RowSet srcRowSet = createSrcRowSet(allocator);
-      final RowSet destRowSet = new RowSetBuilder(allocator, 
batchSchema).build();
-      final VectorContainer destContainer = destRowSet.container();
-      final Copier copier = createCopier(new RowSetBatch(srcRowSet), 
destContainer, null);
+      final VectorContainer destContainer = new VectorContainer(allocator, 
batchSchema);
+
+      for (VectorWrapper vectorWrapper: destContainer) {
+        vectorWrapper.getValueVector().allocateNew();
 
 Review comment:
   Why we need to allocate memory for destination container here ? Shouldn't 
the copier allocate it when `copyRecords` is called. Since it will do so based 
on incoming record count. Also in case of `StraightCopier` it should not 
allocate any memory for ValueVectors in destination container since there will 
be direct transfer of buffer from incoming to outgoing container ValueVectors.
   
   I think the bug is 
[here](https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/GenericCopier.java#L56)
 instead. It should be same as 
[AbstractCopier::copyRecords](https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/AbstractCopier.java#L45).
 Also `GenericCopier` is not efficient for cases like `StraightCopier` where no 
actual copy is done only transfer of buffer happens.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to