Github user ilooner commented on a diff in the pull request:
https://github.com/apache/drill/pull/984#discussion_r148157140
--- Diff:
exec/java-exec/src/test/java/org/apache/drill/test/BatchUtils.java ---
@@ -0,0 +1,280 @@
+/*
+ * 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.test;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.drill.exec.record.VectorContainer;
+import org.apache.drill.exec.record.VectorWrapper;
+import org.apache.drill.exec.record.selection.SelectionVector4;
+import org.apache.drill.exec.vector.ValueVector;
+import org.junit.Assert;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+public class BatchUtils {
+ static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(BatchUtils.class);
+
+ public static Map<String, List<Object>>
containerToObjects(VectorContainer vectorContainer) {
+ Map<String, List<Object>> rows = Maps.newHashMap();
+ int numCols = vectorContainer.getNumberOfColumns();
+ int recordCount = vectorContainer.getRecordCount();
+
+ for (int columnIndex = 0; columnIndex < numCols; columnIndex++) {
+ String columnName =
vectorContainer.getSchema().getColumn(columnIndex).getName();
+ List<Object> data = Lists.newArrayList();
+
+ ValueVector.Accessor valueVectorAccessor = vectorContainer
+ .getValueVector(columnIndex)
+ .getValueVector()
+ .getAccessor();
+
+ for (int recordIndex = 0; recordIndex < recordCount; recordIndex++) {
+ data.add(valueVectorAccessor.getObject(recordIndex));
+ }
+
+ rows.put(columnName, data);
+ }
+
+ return rows;
+ }
+
+ public static Map<String, List<Object>>
hyperBatchAndSelectorToObjects(VectorContainer vectorContainer,
SelectionVector4 selectionVector4) {
--- End diff --
Done
---