Reduce object creation in Unnest.

If an Unnest is run in a Subplan operator, open/close need to be
called many times.

Change-Id: I5b2d1f281dca0655c212aad328fb737d5fec9c71
Reviewed-on: https://asterix-gerrit.ics.uci.edu/957
Reviewed-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/UnnestRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/UnnestRuntimeFactory.java
index 3afa808..300be34 100644
--- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/UnnestRuntimeFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/UnnestRuntimeFactory.java
@@ -94,14 +94,15 @@
         int missingBytesLen = bos.size();
         return new AbstractOneInputOneOutputOneFramePushRuntime() {
             private IPointable p = VoidPointable.FACTORY.createPointable();
-            private ArrayTupleBuilder tupleBuilder;
+            private ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(projectionList.length);
             private IUnnestingEvaluator unnest = unnestingFactory.createUnnestingEvaluator(ctx);
 
             @Override
             public void open() throws HyracksDataException {
                 writer.open();
-                initAccessAppendRef(ctx);
-                tupleBuilder = new ArrayTupleBuilder(projectionList.length);
+                if (tRef == null) {
+                    initAccessAppendRef(ctx);
+                }
             }
 
             @Override