Author: brock
Date: Tue Feb 3 01:57:26 2015
New Revision: 1656619
URL: http://svn.apache.org/r1656619
Log:
HIVE-9470 - Use a generic writable object to run ColumnaStorageBench write/read
tests (Sergio Pena via Brock)
Modified:
hive/trunk/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/storage/ColumnarStorageBench.java
Modified:
hive/trunk/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/storage/ColumnarStorageBench.java
URL:
http://svn.apache.org/viewvc/hive/trunk/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/storage/ColumnarStorageBench.java?rev=1656619&r1=1656618&r2=1656619&view=diff
==============================================================================
---
hive/trunk/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/storage/ColumnarStorageBench.java
(original)
+++
hive/trunk/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/storage/ColumnarStorageBench.java
Tue Feb 3 01:57:26 2015
@@ -30,7 +30,8 @@ import org.apache.hadoop.hive.serde2.Ser
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.hive.serde2.SerDeUtils;
import org.apache.hadoop.hive.serde2.io.DoubleWritable;
-import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
+import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
@@ -101,6 +102,11 @@ public class ColumnarStorageBench {
private FileSystem fs;
/**
+ * LazySimpleSerDe is used to create our testing rows.
+ */
+ private LazySimpleSerDe lazySimpleSerDe;
+
+ /**
* Contains implementation for the storage format to test
*/
private StorageFormatTest storageFormatTest;
@@ -113,7 +119,7 @@ public class ColumnarStorageBench {
*/
private Writable recordWritable[];
private Object rows[];
- private StructObjectInspector oi;
+ private ObjectInspector oi;
/**
* These column types are used for the record that will be tested.
@@ -126,14 +132,24 @@ public class ColumnarStorageBench {
recordProperties.setProperty("columns",
getColumnNames(DEFAULT_COLUMN_TYPES));
recordProperties.setProperty("columns.types", DEFAULT_COLUMN_TYPES);
- oi = getObjectInspector(DEFAULT_COLUMN_TYPES);
-
final int NUMBER_OF_ROWS_TO_TEST = 100;
rows = new Object[NUMBER_OF_ROWS_TO_TEST];
recordWritable = new Writable[NUMBER_OF_ROWS_TO_TEST];
- for (int i=0; i<NUMBER_OF_ROWS_TO_TEST; i++) {
- rows[i] = createRandomRow(DEFAULT_COLUMN_TYPES);
+ /**
+ * We use LazySimpleSerDe to generate our testing rows.
+ */
+
+ try {
+ lazySimpleSerDe = new LazySimpleSerDe();
+ SerDeUtils.initializeSerDe(lazySimpleSerDe, new Configuration(),
recordProperties, null);
+ oi = lazySimpleSerDe.getObjectInspector();
+
+ for (int i = 0; i < NUMBER_OF_ROWS_TO_TEST; i++) {
+ rows[i] = createRandomRow(DEFAULT_COLUMN_TYPES);
+ }
+ } catch(SerDeException e) {
+ e.printStackTrace();
}
}
@@ -213,7 +229,7 @@ public class ColumnarStorageBench {
return record(fields);
}
- private StructObjectInspector getObjectInspector(final String columnTypes) {
+ private ObjectInspector getArrayWritableObjectInspector(final String
columnTypes) {
List<TypeInfo> columnTypeList =
TypeInfoUtils.getTypeInfosFromTypeString(columnTypes);
List<String> columnNameList =
Arrays.asList(getColumnNames(columnTypes).split(","));
StructTypeInfo rowTypeInfo =
(StructTypeInfo)TypeInfoFactory.getStructTypeInfo(columnNameList,
columnTypeList);
@@ -221,8 +237,10 @@ public class ColumnarStorageBench {
return new ArrayWritableObjectInspector(rowTypeInfo);
}
- private Object createRandomRow(final String columnTypes) {
- return createRecord(TypeInfoUtils.getTypeInfosFromTypeString(columnTypes));
+ private Object createRandomRow(final String columnTypes) throws
SerDeException {
+ Writable recordWritable =
createRecord(TypeInfoUtils.getTypeInfosFromTypeString(columnTypes));
+ Writable simpleWritable = lazySimpleSerDe.serialize(recordWritable,
getArrayWritableObjectInspector(columnTypes));
+ return lazySimpleSerDe.deserialize(simpleWritable);
}
/**
@@ -245,7 +263,7 @@ public class ColumnarStorageBench {
SerDeUtils.initializeSerDe(serDe, conf, recordProperties, null);
}
- public Writable serialize(Object row, StructObjectInspector oi) throws
SerDeException {
+ public Writable serialize(Object row, ObjectInspector oi) throws
SerDeException {
return serDe.serialize(row, oi);
}