reformat hivesterix sources

git-svn-id: https://hyracks.googlecode.com/svn/branches/fullstack_staging@2670 123451ca-8445-de46-9d55-352943316053
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/ExpressionConstant.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/ExpressionConstant.java
index bf4806f..3c84566 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/ExpressionConstant.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/ExpressionConstant.java
@@ -8,18 +8,18 @@
  */

 public class ExpressionConstant {

 

-    /**

-     * name space for function identifier

-     */

-    public static String NAMESPACE = "hive";

+	/**

+	 * name space for function identifier

+	 */

+	public static String NAMESPACE = "hive";

 

-    /**

-     * field expression: modeled as function in Algebricks

-     */

-    public static String FIELDACCESS = "fieldaccess";

+	/**

+	 * field expression: modeled as function in Algebricks

+	 */

+	public static String FIELDACCESS = "fieldaccess";

 

-    /**

-     * null string: modeled as null in Algebricks

-     */

-    public static String NULL = "null";

+	/**

+	 * null string: modeled as null in Algebricks

+	 */

+	public static String NULL = "null";

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveAlgebricksBuiltInFunctionMap.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveAlgebricksBuiltInFunctionMap.java
index 450e8ad..18380f7 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveAlgebricksBuiltInFunctionMap.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveAlgebricksBuiltInFunctionMap.java
@@ -9,73 +9,75 @@
 

 public class HiveAlgebricksBuiltInFunctionMap {

 

-    /**

-     * hive auqa builtin function map instance

-     */

-    public static HiveAlgebricksBuiltInFunctionMap INSTANCE = new HiveAlgebricksBuiltInFunctionMap();

+	/**

+	 * hive auqa builtin function map instance

+	 */

+	public static HiveAlgebricksBuiltInFunctionMap INSTANCE = new HiveAlgebricksBuiltInFunctionMap();

 

-    /**

-     * hive to Algebricks function name mapping

-     */

-    private HashMap<String, FunctionIdentifier> hiveToAlgebricksMap = new HashMap<String, FunctionIdentifier>();

+	/**

+	 * hive to Algebricks function name mapping

+	 */

+	private HashMap<String, FunctionIdentifier> hiveToAlgebricksMap = new HashMap<String, FunctionIdentifier>();

 

-    /**

-     * Algebricks to hive function name mapping

-     */

-    private HashMap<FunctionIdentifier, String> AlgebricksToHiveMap = new HashMap<FunctionIdentifier, String>();

+	/**

+	 * Algebricks to hive function name mapping

+	 */

+	private HashMap<FunctionIdentifier, String> AlgebricksToHiveMap = new HashMap<FunctionIdentifier, String>();

 

-    /**

-     * the bi-directional mapping between hive functions and Algebricks functions

-     */

-    private HiveAlgebricksBuiltInFunctionMap() {

-        hiveToAlgebricksMap.put("and", AlgebricksBuiltinFunctions.AND);

-        hiveToAlgebricksMap.put("or", AlgebricksBuiltinFunctions.OR);

-        hiveToAlgebricksMap.put("!", AlgebricksBuiltinFunctions.NOT);

-        hiveToAlgebricksMap.put("not", AlgebricksBuiltinFunctions.NOT);

-        hiveToAlgebricksMap.put("=", AlgebricksBuiltinFunctions.EQ);

-        hiveToAlgebricksMap.put("<>", AlgebricksBuiltinFunctions.NEQ);

-        hiveToAlgebricksMap.put(">", AlgebricksBuiltinFunctions.GT);

-        hiveToAlgebricksMap.put("<", AlgebricksBuiltinFunctions.LT);

-        hiveToAlgebricksMap.put(">=", AlgebricksBuiltinFunctions.GE);

-        hiveToAlgebricksMap.put("<=", AlgebricksBuiltinFunctions.LE);

+	/**

+	 * the bi-directional mapping between hive functions and Algebricks

+	 * functions

+	 */

+	private HiveAlgebricksBuiltInFunctionMap() {

+		hiveToAlgebricksMap.put("and", AlgebricksBuiltinFunctions.AND);

+		hiveToAlgebricksMap.put("or", AlgebricksBuiltinFunctions.OR);

+		hiveToAlgebricksMap.put("!", AlgebricksBuiltinFunctions.NOT);

+		hiveToAlgebricksMap.put("not", AlgebricksBuiltinFunctions.NOT);

+		hiveToAlgebricksMap.put("=", AlgebricksBuiltinFunctions.EQ);

+		hiveToAlgebricksMap.put("<>", AlgebricksBuiltinFunctions.NEQ);

+		hiveToAlgebricksMap.put(">", AlgebricksBuiltinFunctions.GT);

+		hiveToAlgebricksMap.put("<", AlgebricksBuiltinFunctions.LT);

+		hiveToAlgebricksMap.put(">=", AlgebricksBuiltinFunctions.GE);

+		hiveToAlgebricksMap.put("<=", AlgebricksBuiltinFunctions.LE);

 

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.AND, "and");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.OR, "or");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NOT, "!");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NOT, "not");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.EQ, "=");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NEQ, "<>");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.GT, ">");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.LT, "<");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.GE, ">=");

-        AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.LE, "<=");

-    }

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.AND, "and");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.OR, "or");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NOT, "!");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NOT, "not");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.EQ, "=");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.NEQ, "<>");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.GT, ">");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.LT, "<");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.GE, ">=");

+		AlgebricksToHiveMap.put(AlgebricksBuiltinFunctions.LE, "<=");

+	}

 

-    /**

-     * get hive function name from Algebricks function identifier

-     * 

-     * @param AlgebricksId

-     * @return hive

-     */

-    public String getHiveFunctionName(FunctionIdentifier AlgebricksId) {

-        return AlgebricksToHiveMap.get(AlgebricksId);

-    }

+	/**

+	 * get hive function name from Algebricks function identifier

+	 * 

+	 * @param AlgebricksId

+	 * @return hive

+	 */

+	public String getHiveFunctionName(FunctionIdentifier AlgebricksId) {

+		return AlgebricksToHiveMap.get(AlgebricksId);

+	}

 

-    /**

-     * get hive UDF or Generic class's corresponding built-in functions

-     * 

-     * @param funcClass

-     * @return function identifier

-     */

-    public FunctionIdentifier getAlgebricksFunctionId(Class<?> funcClass) {

-        Description annotation = (Description) funcClass.getAnnotation(Description.class);

-        String hiveUDFName = "";

-        if (annotation == null) {

-            hiveUDFName = null;

-            return null;

-        } else {

-            hiveUDFName = annotation.name();

-            return hiveToAlgebricksMap.get(hiveUDFName);

-        }

-    }

+	/**

+	 * get hive UDF or Generic class's corresponding built-in functions

+	 * 

+	 * @param funcClass

+	 * @return function identifier

+	 */

+	public FunctionIdentifier getAlgebricksFunctionId(Class<?> funcClass) {

+		Description annotation = (Description) funcClass

+				.getAnnotation(Description.class);

+		String hiveUDFName = "";

+		if (annotation == null) {

+			hiveUDFName = null;

+			return null;

+		} else {

+			hiveUDFName = annotation.name();

+			return hiveToAlgebricksMap.get(hiveUDFName);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveExpressionTypeComputer.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveExpressionTypeComputer.java
index e10e8c1..afb7d39 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveExpressionTypeComputer.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveExpressionTypeComputer.java
@@ -36,144 +36,165 @@
 

 public class HiveExpressionTypeComputer implements IExpressionTypeComputer {

 

-    public static IExpressionTypeComputer INSTANCE = new HiveExpressionTypeComputer();

+	public static IExpressionTypeComputer INSTANCE = new HiveExpressionTypeComputer();

 

-    @Override

-    public Object getType(ILogicalExpression expr, IMetadataProvider<?, ?> metadataProvider,

-            IVariableTypeEnvironment env) throws AlgebricksException {

-        if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {

-            /**

-             * function expression

-             */

-            AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;

-            IFunctionInfo funcInfo = funcExpr.getFunctionInfo();

+	@Override

+	public Object getType(ILogicalExpression expr,

+			IMetadataProvider<?, ?> metadataProvider,

+			IVariableTypeEnvironment env) throws AlgebricksException {

+		if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {

+			/**

+			 * function expression

+			 */

+			AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;

+			IFunctionInfo funcInfo = funcExpr.getFunctionInfo();

 

-            /**

-             * argument expressions, types, object inspectors

-             */

-            List<Mutable<ILogicalExpression>> arguments = funcExpr.getArguments();

-            List<TypeInfo> argumentTypes = new ArrayList<TypeInfo>();

+			/**

+			 * argument expressions, types, object inspectors

+			 */

+			List<Mutable<ILogicalExpression>> arguments = funcExpr

+					.getArguments();

+			List<TypeInfo> argumentTypes = new ArrayList<TypeInfo>();

 

-            /**

-             * get types of argument

-             */

-            for (Mutable<ILogicalExpression> argument : arguments) {

-                TypeInfo type = (TypeInfo) getType(argument.getValue(), metadataProvider, env);

-                argumentTypes.add(type);

-            }

+			/**

+			 * get types of argument

+			 */

+			for (Mutable<ILogicalExpression> argument : arguments) {

+				TypeInfo type = (TypeInfo) getType(argument.getValue(),

+						metadataProvider, env);

+				argumentTypes.add(type);

+			}

 

-            ObjectInspector[] childrenOIs = new ObjectInspector[argumentTypes.size()];

+			ObjectInspector[] childrenOIs = new ObjectInspector[argumentTypes

+					.size()];

 

-            /**

-             * get object inspector

-             */

-            for (int i = 0; i < argumentTypes.size(); i++) {

-                childrenOIs[i] = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(argumentTypes.get(i));

-            }

+			/**

+			 * get object inspector

+			 */

+			for (int i = 0; i < argumentTypes.size(); i++) {

+				childrenOIs[i] = TypeInfoUtils

+						.getStandardWritableObjectInspectorFromTypeInfo(argumentTypes

+								.get(i));

+			}

 

-            /**

-             * type inference for scalar function

-             */

-            if (funcExpr instanceof ScalarFunctionCallExpression) {

+			/**

+			 * type inference for scalar function

+			 */

+			if (funcExpr instanceof ScalarFunctionCallExpression) {

 

-                FunctionIdentifier AlgebricksId = funcInfo.getFunctionIdentifier();

-                Object functionInfo = ((HiveFunctionInfo) funcInfo).getInfo();

-                String udfName = HiveAlgebricksBuiltInFunctionMap.INSTANCE.getHiveFunctionName(AlgebricksId);

-                GenericUDF udf;

-                if (udfName != null) {

-                    /**

-                     * get corresponding function info for built-in functions

-                     */

-                    FunctionInfo fInfo = FunctionRegistry.getFunctionInfo(udfName);

-                    udf = fInfo.getGenericUDF();

-                } else if (functionInfo != null) {

-                    /**

-                     * for GenericUDFBridge: we should not call get type of this

-                     * hive expression, because parameters may have been

-                     * changed!

-                     */

-                    ExprNodeGenericFuncDesc hiveExpr = (ExprNodeGenericFuncDesc) functionInfo;

-                    udf = hiveExpr.getGenericUDF();

-                } else {

-                    /**

-                     * for other generic UDF

-                     */

-                    Class<?> udfClass;

-                    try {

-                        udfClass = Class.forName(AlgebricksId.getName());

-                        udf = (GenericUDF) udfClass.newInstance();

-                    } catch (Exception e) {

-                        e.printStackTrace();

-                        throw new AlgebricksException(e.getMessage());

-                    }

-                }

-                /**

-                 * doing the actual type inference

-                 */

-                ObjectInspector oi = null;

-                try {

-                    oi = udf.initialize(childrenOIs);

-                } catch (Exception e) {

-                    e.printStackTrace();

-                }

+				FunctionIdentifier AlgebricksId = funcInfo

+						.getFunctionIdentifier();

+				Object functionInfo = ((HiveFunctionInfo) funcInfo).getInfo();

+				String udfName = HiveAlgebricksBuiltInFunctionMap.INSTANCE

+						.getHiveFunctionName(AlgebricksId);

+				GenericUDF udf;

+				if (udfName != null) {

+					/**

+					 * get corresponding function info for built-in functions

+					 */

+					FunctionInfo fInfo = FunctionRegistry

+							.getFunctionInfo(udfName);

+					udf = fInfo.getGenericUDF();

+				} else if (functionInfo != null) {

+					/**

+					 * for GenericUDFBridge: we should not call get type of this

+					 * hive expression, because parameters may have been

+					 * changed!

+					 */

+					ExprNodeGenericFuncDesc hiveExpr = (ExprNodeGenericFuncDesc) functionInfo;

+					udf = hiveExpr.getGenericUDF();

+				} else {

+					/**

+					 * for other generic UDF

+					 */

+					Class<?> udfClass;

+					try {

+						udfClass = Class.forName(AlgebricksId.getName());

+						udf = (GenericUDF) udfClass.newInstance();

+					} catch (Exception e) {

+						e.printStackTrace();

+						throw new AlgebricksException(e.getMessage());

+					}

+				}

+				/**

+				 * doing the actual type inference

+				 */

+				ObjectInspector oi = null;

+				try {

+					oi = udf.initialize(childrenOIs);

+				} catch (Exception e) {

+					e.printStackTrace();

+				}

 

-                TypeInfo exprType = TypeInfoUtils.getTypeInfoFromObjectInspector(oi);

-                return exprType;

+				TypeInfo exprType = TypeInfoUtils

+						.getTypeInfoFromObjectInspector(oi);

+				return exprType;

 

-            } else if (funcExpr instanceof AggregateFunctionCallExpression) {

-                /**

-                 * hive aggregation info

-                 */

-                AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo())

-                        .getInfo();

-                /**

-                 * type inference for aggregation function

-                 */

-                GenericUDAFEvaluator result = aggregateDesc.getGenericUDAFEvaluator();

+			} else if (funcExpr instanceof AggregateFunctionCallExpression) {

+				/**

+				 * hive aggregation info

+				 */

+				AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr

+						.getFunctionInfo()).getInfo();

+				/**

+				 * type inference for aggregation function

+				 */

+				GenericUDAFEvaluator result = aggregateDesc

+						.getGenericUDAFEvaluator();

 

-                ObjectInspector returnOI = null;

-                try {

-                    returnOI = result.init(aggregateDesc.getMode(), childrenOIs);

-                } catch (HiveException e) {

-                    e.printStackTrace();

-                }

-                TypeInfo exprType = TypeInfoUtils.getTypeInfoFromObjectInspector(returnOI);

-                return exprType;

-            } else if (funcExpr instanceof UnnestingFunctionCallExpression) {

-                /**

-                 * type inference for UDTF function

-                 */

-                UDTFDesc hiveDesc = (UDTFDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo()).getInfo();

-                GenericUDTF udtf = hiveDesc.getGenericUDTF();

-                ObjectInspector returnOI = null;

-                try {

-                    returnOI = udtf.initialize(childrenOIs);

-                } catch (HiveException e) {

-                    e.printStackTrace();

-                }

-                TypeInfo exprType = TypeInfoUtils.getTypeInfoFromObjectInspector(returnOI);

-                return exprType;

-            } else {

-                throw new IllegalStateException("unrecognized function expression " + expr.getClass().getName());

-            }

-        } else if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {

-            /**

-             * get type for variable in the environment

-             */

-            VariableReferenceExpression varExpr = (VariableReferenceExpression) expr;

-            LogicalVariable var = varExpr.getVariableReference();

-            TypeInfo type = (TypeInfo) env.getVarType(var);

-            return type;

-        } else if (expr.getExpressionTag() == LogicalExpressionTag.CONSTANT) {

-            /**

-             * get type for constant, from its java class

-             */

-            ConstantExpression constExpr = (ConstantExpression) expr;

-            HivesterixConstantValue value = (HivesterixConstantValue) constExpr.getValue();

-            TypeInfo type = TypeInfoFactory.getPrimitiveTypeInfoFromJavaPrimitive(value.getObject().getClass());

-            return type;

-        } else {

-            throw new IllegalStateException("illegal expressions " + expr.getClass().getName());

-        }

-    }

+				ObjectInspector returnOI = null;

+				try {

+					returnOI = result

+							.init(aggregateDesc.getMode(), childrenOIs);

+				} catch (HiveException e) {

+					e.printStackTrace();

+				}

+				TypeInfo exprType = TypeInfoUtils

+						.getTypeInfoFromObjectInspector(returnOI);

+				return exprType;

+			} else if (funcExpr instanceof UnnestingFunctionCallExpression) {

+				/**

+				 * type inference for UDTF function

+				 */

+				UDTFDesc hiveDesc = (UDTFDesc) ((HiveFunctionInfo) funcExpr

+						.getFunctionInfo()).getInfo();

+				GenericUDTF udtf = hiveDesc.getGenericUDTF();

+				ObjectInspector returnOI = null;

+				try {

+					returnOI = udtf.initialize(childrenOIs);

+				} catch (HiveException e) {

+					e.printStackTrace();

+				}

+				TypeInfo exprType = TypeInfoUtils

+						.getTypeInfoFromObjectInspector(returnOI);

+				return exprType;

+			} else {

+				throw new IllegalStateException(

+						"unrecognized function expression "

+								+ expr.getClass().getName());

+			}

+		} else if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {

+			/**

+			 * get type for variable in the environment

+			 */

+			VariableReferenceExpression varExpr = (VariableReferenceExpression) expr;

+			LogicalVariable var = varExpr.getVariableReference();

+			TypeInfo type = (TypeInfo) env.getVarType(var);

+			return type;

+		} else if (expr.getExpressionTag() == LogicalExpressionTag.CONSTANT) {

+			/**

+			 * get type for constant, from its java class

+			 */

+			ConstantExpression constExpr = (ConstantExpression) expr;

+			HivesterixConstantValue value = (HivesterixConstantValue) constExpr

+					.getValue();

+			TypeInfo type = TypeInfoFactory

+					.getPrimitiveTypeInfoFromJavaPrimitive(value.getObject()

+							.getClass());

+			return type;

+		} else {

+			throw new IllegalStateException("illegal expressions "

+					+ expr.getClass().getName());

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveFunctionInfo.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveFunctionInfo.java
index ced8d02..220bd00 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveFunctionInfo.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveFunctionInfo.java
@@ -7,30 +7,30 @@
 

 public class HiveFunctionInfo implements IFunctionInfo, Serializable {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    /**

-     * primary function identifier

-     */

-    private transient FunctionIdentifier fid;

+	/**

+	 * primary function identifier

+	 */

+	private transient FunctionIdentifier fid;

 

-    /**

-     * secondary function identifier: function name

-     */

-    private transient Object secondaryFid;

+	/**

+	 * secondary function identifier: function name

+	 */

+	private transient Object secondaryFid;

 

-    public HiveFunctionInfo(FunctionIdentifier fid, Object secondFid) {

-        this.fid = fid;

-        this.secondaryFid = secondFid;

-    }

+	public HiveFunctionInfo(FunctionIdentifier fid, Object secondFid) {

+		this.fid = fid;

+		this.secondaryFid = secondFid;

+	}

 

-    @Override

-    public FunctionIdentifier getFunctionIdentifier() {

-        return fid;

-    }

+	@Override

+	public FunctionIdentifier getFunctionIdentifier() {

+		return fid;

+	}

 

-    public Object getInfo() {

-        return secondaryFid;

-    }

+	public Object getInfo() {

+		return secondaryFid;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveMergeAggregationExpressionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveMergeAggregationExpressionFactory.java
index d43d7bd..8dea691 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveMergeAggregationExpressionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveMergeAggregationExpressionFactory.java
@@ -26,50 +26,59 @@
  * @author yingyib
  * 
  */
-public class HiveMergeAggregationExpressionFactory implements IMergeAggregationExpressionFactory {
+public class HiveMergeAggregationExpressionFactory implements
+		IMergeAggregationExpressionFactory {
 
-    public static IMergeAggregationExpressionFactory INSTANCE = new HiveMergeAggregationExpressionFactory();
+	public static IMergeAggregationExpressionFactory INSTANCE = new HiveMergeAggregationExpressionFactory();
 
-    @Override
-    public ILogicalExpression createMergeAggregation(ILogicalExpression expr, IOptimizationContext context)
-            throws AlgebricksException {
-        /**
-         * type inference for scalar function
-         */
-        if (expr instanceof AggregateFunctionCallExpression) {
-            AggregateFunctionCallExpression funcExpr = (AggregateFunctionCallExpression) expr;
-            /**
-             * hive aggregation info
-             */
-            AggregationDesc aggregator = (AggregationDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo()).getInfo();
-            LogicalVariable inputVar = context.newVar();
-            ExprNodeDesc col = new ExprNodeColumnDesc(TypeInfoFactory.voidTypeInfo, inputVar.toString(), null, false);
-            ArrayList<ExprNodeDesc> parameters = new ArrayList<ExprNodeDesc>();
-            parameters.add(col);
+	@Override
+	public ILogicalExpression createMergeAggregation(ILogicalExpression expr,
+			IOptimizationContext context) throws AlgebricksException {
+		/**
+		 * type inference for scalar function
+		 */
+		if (expr instanceof AggregateFunctionCallExpression) {
+			AggregateFunctionCallExpression funcExpr = (AggregateFunctionCallExpression) expr;
+			/**
+			 * hive aggregation info
+			 */
+			AggregationDesc aggregator = (AggregationDesc) ((HiveFunctionInfo) funcExpr
+					.getFunctionInfo()).getInfo();
+			LogicalVariable inputVar = context.newVar();
+			ExprNodeDesc col = new ExprNodeColumnDesc(
+					TypeInfoFactory.voidTypeInfo, inputVar.toString(), null,
+					false);
+			ArrayList<ExprNodeDesc> parameters = new ArrayList<ExprNodeDesc>();
+			parameters.add(col);
 
-            GenericUDAFEvaluator.Mode mergeMode;
-            if (aggregator.getMode() == GenericUDAFEvaluator.Mode.PARTIAL1)
-                mergeMode = GenericUDAFEvaluator.Mode.PARTIAL2;
-            else if (aggregator.getMode() == GenericUDAFEvaluator.Mode.COMPLETE)
-                mergeMode = GenericUDAFEvaluator.Mode.FINAL;
-            else
-                mergeMode = aggregator.getMode();
-            AggregationDesc mergeDesc = new AggregationDesc(aggregator.getGenericUDAFName(),
-                    aggregator.getGenericUDAFEvaluator(), parameters, aggregator.getDistinct(), mergeMode);
+			GenericUDAFEvaluator.Mode mergeMode;
+			if (aggregator.getMode() == GenericUDAFEvaluator.Mode.PARTIAL1)
+				mergeMode = GenericUDAFEvaluator.Mode.PARTIAL2;
+			else if (aggregator.getMode() == GenericUDAFEvaluator.Mode.COMPLETE)
+				mergeMode = GenericUDAFEvaluator.Mode.FINAL;
+			else
+				mergeMode = aggregator.getMode();
+			AggregationDesc mergeDesc = new AggregationDesc(
+					aggregator.getGenericUDAFName(),
+					aggregator.getGenericUDAFEvaluator(), parameters,
+					aggregator.getDistinct(), mergeMode);
 
-            String UDAFName = mergeDesc.getGenericUDAFName();
-            List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
-            arguments.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(inputVar)));
+			String UDAFName = mergeDesc.getGenericUDAFName();
+			List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();
+			arguments.add(new MutableObject<ILogicalExpression>(
+					new VariableReferenceExpression(inputVar)));
 
-            FunctionIdentifier funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, UDAFName + "("
-                    + mergeDesc.getMode() + ")");
-            HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, mergeDesc);
-            AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(funcInfo,
-                    false, arguments);
-            return aggregationExpression;
-        } else {
-            throw new IllegalStateException("illegal expressions " + expr.getClass().getName());
-        }
-    }
+			FunctionIdentifier funcId = new FunctionIdentifier(
+					ExpressionConstant.NAMESPACE, UDAFName + "("
+							+ mergeDesc.getMode() + ")");
+			HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, mergeDesc);
+			AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(
+					funcInfo, false, arguments);
+			return aggregationExpression;
+		} else {
+			throw new IllegalStateException("illegal expressions "
+					+ expr.getClass().getName());
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveNullableTypeComputer.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveNullableTypeComputer.java
index 906e3ce..10c9b8a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveNullableTypeComputer.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HiveNullableTypeComputer.java
@@ -5,11 +5,11 @@
 
 public class HiveNullableTypeComputer implements INullableTypeComputer {
 
-    public static INullableTypeComputer INSTANCE = new HiveNullableTypeComputer();
+	public static INullableTypeComputer INSTANCE = new HiveNullableTypeComputer();
 
-    @Override
-    public Object makeNullableType(Object type) throws AlgebricksException {
-        return type;
-    }
+	@Override
+	public Object makeNullableType(Object type) throws AlgebricksException {
+		return type;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivePartialAggregationTypeComputer.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivePartialAggregationTypeComputer.java
index c74966c..7062e26 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivePartialAggregationTypeComputer.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivePartialAggregationTypeComputer.java
@@ -22,81 +22,95 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
 import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
-public class HivePartialAggregationTypeComputer implements IPartialAggregationTypeComputer {
+public class HivePartialAggregationTypeComputer implements
+		IPartialAggregationTypeComputer {
 
-    public static IPartialAggregationTypeComputer INSTANCE = new HivePartialAggregationTypeComputer();
+	public static IPartialAggregationTypeComputer INSTANCE = new HivePartialAggregationTypeComputer();
 
-    @Override
-    public Object getType(ILogicalExpression expr, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
-            IExpressionTypeComputer tc = HiveExpressionTypeComputer.INSTANCE;
-            /**
-             * function expression
-             */
-            AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
+	@Override
+	public Object getType(ILogicalExpression expr,
+			IVariableTypeEnvironment env,
+			IMetadataProvider<?, ?> metadataProvider)
+			throws AlgebricksException {
+		if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
+			IExpressionTypeComputer tc = HiveExpressionTypeComputer.INSTANCE;
+			/**
+			 * function expression
+			 */
+			AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
 
-            /**
-             * argument expressions, types, object inspectors
-             */
-            List<Mutable<ILogicalExpression>> arguments = funcExpr.getArguments();
-            List<TypeInfo> argumentTypes = new ArrayList<TypeInfo>();
+			/**
+			 * argument expressions, types, object inspectors
+			 */
+			List<Mutable<ILogicalExpression>> arguments = funcExpr
+					.getArguments();
+			List<TypeInfo> argumentTypes = new ArrayList<TypeInfo>();
 
-            /**
-             * get types of argument
-             */
-            for (Mutable<ILogicalExpression> argument : arguments) {
-                TypeInfo type = (TypeInfo) tc.getType(argument.getValue(), metadataProvider, env);
-                argumentTypes.add(type);
-            }
+			/**
+			 * get types of argument
+			 */
+			for (Mutable<ILogicalExpression> argument : arguments) {
+				TypeInfo type = (TypeInfo) tc.getType(argument.getValue(),
+						metadataProvider, env);
+				argumentTypes.add(type);
+			}
 
-            ObjectInspector[] childrenOIs = new ObjectInspector[argumentTypes.size()];
+			ObjectInspector[] childrenOIs = new ObjectInspector[argumentTypes
+					.size()];
 
-            /**
-             * get object inspector
-             */
-            for (int i = 0; i < argumentTypes.size(); i++) {
-                childrenOIs[i] = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(argumentTypes.get(i));
-            }
+			/**
+			 * get object inspector
+			 */
+			for (int i = 0; i < argumentTypes.size(); i++) {
+				childrenOIs[i] = TypeInfoUtils
+						.getStandardWritableObjectInspectorFromTypeInfo(argumentTypes
+								.get(i));
+			}
 
-            /**
-             * type inference for scalar function
-             */
-            if (funcExpr instanceof AggregateFunctionCallExpression) {
-                /**
-                 * hive aggregation info
-                 */
-                AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo())
-                        .getInfo();
-                /**
-                 * type inference for aggregation function
-                 */
-                GenericUDAFEvaluator result = aggregateDesc.getGenericUDAFEvaluator();
+			/**
+			 * type inference for scalar function
+			 */
+			if (funcExpr instanceof AggregateFunctionCallExpression) {
+				/**
+				 * hive aggregation info
+				 */
+				AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr
+						.getFunctionInfo()).getInfo();
+				/**
+				 * type inference for aggregation function
+				 */
+				GenericUDAFEvaluator result = aggregateDesc
+						.getGenericUDAFEvaluator();
 
-                ObjectInspector returnOI = null;
-                try {
-                    returnOI = result.init(getPartialMode(aggregateDesc.getMode()), childrenOIs);
-                } catch (HiveException e) {
-                    e.printStackTrace();
-                }
-                TypeInfo exprType = TypeInfoUtils.getTypeInfoFromObjectInspector(returnOI);
-                return exprType;
-            } else {
-                throw new IllegalStateException("illegal expressions " + expr.getClass().getName());
-            }
-        } else {
-            throw new IllegalStateException("illegal expressions " + expr.getClass().getName());
-        }
-    }
+				ObjectInspector returnOI = null;
+				try {
+					returnOI = result.init(
+							getPartialMode(aggregateDesc.getMode()),
+							childrenOIs);
+				} catch (HiveException e) {
+					e.printStackTrace();
+				}
+				TypeInfo exprType = TypeInfoUtils
+						.getTypeInfoFromObjectInspector(returnOI);
+				return exprType;
+			} else {
+				throw new IllegalStateException("illegal expressions "
+						+ expr.getClass().getName());
+			}
+		} else {
+			throw new IllegalStateException("illegal expressions "
+					+ expr.getClass().getName());
+		}
+	}
 
-    private Mode getPartialMode(Mode mode) {
-        Mode partialMode;
-        if (mode == Mode.FINAL)
-            partialMode = Mode.PARTIAL2;
-        else if (mode == Mode.COMPLETE)
-            partialMode = Mode.PARTIAL1;
-        else
-            partialMode = mode;
-        return partialMode;
-    }
+	private Mode getPartialMode(Mode mode) {
+		Mode partialMode;
+		if (mode == Mode.FINAL)
+			partialMode = Mode.PARTIAL2;
+		else if (mode == Mode.COMPLETE)
+			partialMode = Mode.PARTIAL1;
+		else
+			partialMode = mode;
+		return partialMode;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivesterixConstantValue.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivesterixConstantValue.java
index 3d35e1f..de9cea6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivesterixConstantValue.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/HivesterixConstantValue.java
@@ -4,52 +4,52 @@
 
 public class HivesterixConstantValue implements IAlgebricksConstantValue {
 
-    private Object object;
+	private Object object;
 
-    public HivesterixConstantValue(Object object) {
-        this.setObject(object);
-    }
+	public HivesterixConstantValue(Object object) {
+		this.setObject(object);
+	}
 
-    @Override
-    public boolean isFalse() {
-        return object == Boolean.FALSE;
-    }
+	@Override
+	public boolean isFalse() {
+		return object == Boolean.FALSE;
+	}
 
-    @Override
-    public boolean isNull() {
-        return object == null;
-    }
+	@Override
+	public boolean isNull() {
+		return object == null;
+	}
 
-    @Override
-    public boolean isTrue() {
-        return object == Boolean.TRUE;
-    }
+	@Override
+	public boolean isTrue() {
+		return object == Boolean.TRUE;
+	}
 
-    public void setObject(Object object) {
-        this.object = object;
-    }
+	public void setObject(Object object) {
+		this.object = object;
+	}
 
-    public Object getObject() {
-        return object;
-    }
+	public Object getObject() {
+		return object;
+	}
 
-    @Override
-    public String toString() {
-        return object.toString();
-    }
+	@Override
+	public String toString() {
+		return object.toString();
+	}
 
-    @Override
-    public boolean equals(Object o) {
-        if (!(o instanceof HivesterixConstantValue)) {
-            return false;
-        }
-        HivesterixConstantValue v2 = (HivesterixConstantValue) o;
-        return object.equals(v2.getObject());
-    }
+	@Override
+	public boolean equals(Object o) {
+		if (!(o instanceof HivesterixConstantValue)) {
+			return false;
+		}
+		HivesterixConstantValue v2 = (HivesterixConstantValue) o;
+		return object.equals(v2.getObject());
+	}
 
-    @Override
-    public int hashCode() {
-        return object.hashCode();
-    }
+	@Override
+	public int hashCode() {
+		return object.hashCode();
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/Schema.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/Schema.java
index 3982d33..2b1d191 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/Schema.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/expression/Schema.java
@@ -10,30 +10,30 @@
 

 public class Schema implements Serializable {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private List<String> fieldNames;

+	private List<String> fieldNames;

 

-    private List<TypeInfo> fieldTypes;

+	private List<TypeInfo> fieldTypes;

 

-    public Schema(List<String> fieldNames, List<TypeInfo> fieldTypes) {

-        this.fieldNames = fieldNames;

-        this.fieldTypes = fieldTypes;

-    }

+	public Schema(List<String> fieldNames, List<TypeInfo> fieldTypes) {

+		this.fieldNames = fieldNames;

+		this.fieldTypes = fieldTypes;

+	}

 

-    public ObjectInspector toObjectInspector() {

-        return LazyUtils.getLazyObjectInspector(fieldNames, fieldTypes);

-    }

+	public ObjectInspector toObjectInspector() {

+		return LazyUtils.getLazyObjectInspector(fieldNames, fieldTypes);

+	}

 

-    public List<String> getNames() {

-        return fieldNames;

-    }

+	public List<String> getNames() {

+		return fieldNames;

+	}

 

-    public List<TypeInfo> getTypes() {

-        return fieldTypes;

-    }

+	public List<TypeInfo> getTypes() {

+		return fieldTypes;

+	}

 

-    public Object[] getSchema() {

-        return fieldTypes.toArray();

-    }

+	public Object[] getSchema() {

+		return fieldTypes.toArray();

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
index 7586d83..d8cc3fe 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveAlgebricksTranslator.java
@@ -79,727 +79,769 @@
 

 public class HiveAlgebricksTranslator implements Translator {

 

-    private int currentVariable = 0;

+	private int currentVariable = 0;

 

-    private List<Mutable<ILogicalOperator>> logicalOp = new ArrayList<Mutable<ILogicalOperator>>();

+	private List<Mutable<ILogicalOperator>> logicalOp = new ArrayList<Mutable<ILogicalOperator>>();

 

-    private boolean continueTraverse = true;

+	private boolean continueTraverse = true;

 

-    private IMetadataProvider<PartitionDesc, Object> metaData;

+	private IMetadataProvider<PartitionDesc, Object> metaData;

 

-    /**

-     * map variable name to the logical variable

-     */

-    private HashMap<String, LogicalVariable> nameToLogicalVariableMap = new HashMap<String, LogicalVariable>();

+	/**

+	 * map variable name to the logical variable

+	 */

+	private HashMap<String, LogicalVariable> nameToLogicalVariableMap = new HashMap<String, LogicalVariable>();

 

-    /**

-     * map field name to LogicalVariable

-     */

-    private HashMap<String, LogicalVariable> fieldToLogicalVariableMap = new HashMap<String, LogicalVariable>();

+	/**

+	 * map field name to LogicalVariable

+	 */

+	private HashMap<String, LogicalVariable> fieldToLogicalVariableMap = new HashMap<String, LogicalVariable>();

 

-    /**

-     * map logical variable to name

-     */

-    private HashMap<LogicalVariable, String> logicalVariableToFieldMap = new HashMap<LogicalVariable, String>();

+	/**

+	 * map logical variable to name

+	 */

+	private HashMap<LogicalVariable, String> logicalVariableToFieldMap = new HashMap<LogicalVariable, String>();

 

-    /**

-     * asterix root operators

-     */

-    private List<Mutable<ILogicalOperator>> rootOperators = new ArrayList<Mutable<ILogicalOperator>>();

+	/**

+	 * asterix root operators

+	 */

+	private List<Mutable<ILogicalOperator>> rootOperators = new ArrayList<Mutable<ILogicalOperator>>();

 

-    /**

-     * a list of visitors

-     */

-    private List<Visitor> visitors = new ArrayList<Visitor>();

+	/**

+	 * a list of visitors

+	 */

+	private List<Visitor> visitors = new ArrayList<Visitor>();

 

-    /**

-     * output writer to print things out

-     */

-    private static PrintWriter outputWriter = new PrintWriter(new OutputStreamWriter(System.out));

+	/**

+	 * output writer to print things out

+	 */

+	private static PrintWriter outputWriter = new PrintWriter(

+			new OutputStreamWriter(System.out));

 

-    /**

-     * map a logical variable to type info

-     */

-    private HashMap<LogicalVariable, TypeInfo> variableToType = new HashMap<LogicalVariable, TypeInfo>();

+	/**

+	 * map a logical variable to type info

+	 */

+	private HashMap<LogicalVariable, TypeInfo> variableToType = new HashMap<LogicalVariable, TypeInfo>();

 

-    @Override

-    public LogicalVariable getVariable(String fieldName, TypeInfo type) {

-        LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);

-        if (var == null) {

-            currentVariable++;

-            var = new LogicalVariable(currentVariable);

-            fieldToLogicalVariableMap.put(fieldName, var);

-            nameToLogicalVariableMap.put(var.toString(), var);

-            variableToType.put(var, type);

-            logicalVariableToFieldMap.put(var, fieldName);

-        }

-        return var;

-    }

+	@Override

+	public LogicalVariable getVariable(String fieldName, TypeInfo type) {

+		LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);

+		if (var == null) {

+			currentVariable++;

+			var = new LogicalVariable(currentVariable);

+			fieldToLogicalVariableMap.put(fieldName, var);

+			nameToLogicalVariableMap.put(var.toString(), var);

+			variableToType.put(var, type);

+			logicalVariableToFieldMap.put(var, fieldName);

+		}

+		return var;

+	}

 

-    @Override

-    public LogicalVariable getNewVariable(String fieldName, TypeInfo type) {

-        currentVariable++;

-        LogicalVariable var = new LogicalVariable(currentVariable);

-        fieldToLogicalVariableMap.put(fieldName, var);

-        nameToLogicalVariableMap.put(var.toString(), var);

-        variableToType.put(var, type);

-        logicalVariableToFieldMap.put(var, fieldName);

-        return var;

-    }

+	@Override

+	public LogicalVariable getNewVariable(String fieldName, TypeInfo type) {

+		currentVariable++;

+		LogicalVariable var = new LogicalVariable(currentVariable);

+		fieldToLogicalVariableMap.put(fieldName, var);

+		nameToLogicalVariableMap.put(var.toString(), var);

+		variableToType.put(var, type);

+		logicalVariableToFieldMap.put(var, fieldName);

+		return var;

+	}

 

-    @Override

-    public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar) {

-        String name = this.logicalVariableToFieldMap.get(oldVar);

-        if (name != null) {

-            fieldToLogicalVariableMap.put(name, newVar);

-            nameToLogicalVariableMap.put(newVar.toString(), newVar);

-            nameToLogicalVariableMap.put(oldVar.toString(), newVar);

-            logicalVariableToFieldMap.put(newVar, name);

-        }

-    }

+	@Override

+	public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar) {

+		String name = this.logicalVariableToFieldMap.get(oldVar);

+		if (name != null) {

+			fieldToLogicalVariableMap.put(name, newVar);

+			nameToLogicalVariableMap.put(newVar.toString(), newVar);

+			nameToLogicalVariableMap.put(oldVar.toString(), newVar);

+			logicalVariableToFieldMap.put(newVar, name);

+		}

+	}

 

-    @Override

-    public IMetadataProvider<PartitionDesc, Object> getMetadataProvider() {

-        return metaData;

-    }

+	@Override

+	public IMetadataProvider<PartitionDesc, Object> getMetadataProvider() {

+		return metaData;

+	}

 

-    /**

-     * only get an variable, without rewriting it

-     * 

-     * @param fieldName

-     * @return

-     */

-    private LogicalVariable getVariableOnly(String fieldName) {

-        return fieldToLogicalVariableMap.get(fieldName);

-    }

+	/**

+	 * only get an variable, without rewriting it

+	 * 

+	 * @param fieldName

+	 * @return

+	 */

+	private LogicalVariable getVariableOnly(String fieldName) {

+		return fieldToLogicalVariableMap.get(fieldName);

+	}

 

-    private void updateVariable(String fieldName, LogicalVariable variable) {

-        LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);

-        if (var == null) {

-            fieldToLogicalVariableMap.put(fieldName, variable);

-            nameToLogicalVariableMap.put(fieldName, variable);

-        } else if (!var.equals(variable)) {

-            // System.out.println("!!!replace variables!!!");

-            fieldToLogicalVariableMap.put(fieldName, variable);

-            nameToLogicalVariableMap.put(fieldName, variable);

-        }

-    }

+	private void updateVariable(String fieldName, LogicalVariable variable) {

+		LogicalVariable var = fieldToLogicalVariableMap.get(fieldName);

+		if (var == null) {

+			fieldToLogicalVariableMap.put(fieldName, variable);

+			nameToLogicalVariableMap.put(fieldName, variable);

+		} else if (!var.equals(variable)) {

+			// System.out.println("!!!replace variables!!!");

+			fieldToLogicalVariableMap.put(fieldName, variable);

+			nameToLogicalVariableMap.put(fieldName, variable);

+		}

+	}

 

-    /**

-     * get a list of logical variables from the schema

-     * 

-     * @param schema

-     * @return

-     */

-    @Override

-    public List<LogicalVariable> getVariablesFromSchema(Schema schema) {

-        List<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        List<String> names = schema.getNames();

+	/**

+	 * get a list of logical variables from the schema

+	 * 

+	 * @param schema

+	 * @return

+	 */

+	@Override

+	public List<LogicalVariable> getVariablesFromSchema(Schema schema) {

+		List<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		List<String> names = schema.getNames();

 

-        for (String name : names)

-            variables.add(nameToLogicalVariableMap.get(name));

-        return variables;

-    }

+		for (String name : names)

+			variables.add(nameToLogicalVariableMap.get(name));

+		return variables;

+	}

 

-    /**

-     * get variable to typeinfo map

-     * 

-     * @return

-     */

-    public HashMap<LogicalVariable, TypeInfo> getVariableContext() {

-        return this.variableToType;

-    }

+	/**

+	 * get variable to typeinfo map

+	 * 

+	 * @return

+	 */

+	public HashMap<LogicalVariable, TypeInfo> getVariableContext() {

+		return this.variableToType;

+	}

 

-    /**

-     * get the number of variables

-     * 

-     * @return

-     */

-    public int getVariableCounter() {

-        return currentVariable + 1;

-    }

+	/**

+	 * get the number of variables

+	 * 

+	 * @return

+	 */

+	public int getVariableCounter() {

+		return currentVariable + 1;

+	}

 

-    /**

-     * translate from hive operator tree to asterix operator tree

-     * 

-     * @param hive

-     *            roots

-     * @return Algebricks roots

-     */

-    public void translate(List<Operator> hiveRoot, ILogicalOperator parentOperator,

-            HashMap<String, PartitionDesc> aliasToPathMap) throws AlgebricksException {

-        /**

-         * register visitors

-         */

-        visitors.add(new FilterVisitor());

-        visitors.add(new GroupByVisitor());

-        visitors.add(new JoinVisitor());

-        visitors.add(new LateralViewJoinVisitor());

-        visitors.add(new UnionVisitor());

-        visitors.add(new LimitVisitor());

-        visitors.add(new MapJoinVisitor());

-        visitors.add(new ProjectVisitor());

-        visitors.add(new SortVisitor());

-        visitors.add(new ExtractVisitor());

-        visitors.add(new TableScanWriteVisitor(aliasToPathMap));

+	/**

+	 * translate from hive operator tree to asterix operator tree

+	 * 

+	 * @param hive

+	 *            roots

+	 * @return Algebricks roots

+	 */

+	public void translate(List<Operator> hiveRoot,

+			ILogicalOperator parentOperator,

+			HashMap<String, PartitionDesc> aliasToPathMap)

+			throws AlgebricksException {

+		/**

+		 * register visitors

+		 */

+		visitors.add(new FilterVisitor());

+		visitors.add(new GroupByVisitor());

+		visitors.add(new JoinVisitor());

+		visitors.add(new LateralViewJoinVisitor());

+		visitors.add(new UnionVisitor());

+		visitors.add(new LimitVisitor());

+		visitors.add(new MapJoinVisitor());

+		visitors.add(new ProjectVisitor());

+		visitors.add(new SortVisitor());

+		visitors.add(new ExtractVisitor());

+		visitors.add(new TableScanWriteVisitor(aliasToPathMap));

 

-        List<Mutable<ILogicalOperator>> refList = translate(hiveRoot, new MutableObject<ILogicalOperator>(

-                parentOperator));

-        insertReplicateOperator(refList);

-        if (refList != null)

-            rootOperators.addAll(refList);

-    }

+		List<Mutable<ILogicalOperator>> refList = translate(hiveRoot,

+				new MutableObject<ILogicalOperator>(parentOperator));

+		insertReplicateOperator(refList);

+		if (refList != null)

+			rootOperators.addAll(refList);

+	}

 

-    /**

-     * translate operator DAG

-     * 

-     * @param hiveRoot

-     * @param AlgebricksParentOperator

-     * @return

-     */

-    private List<Mutable<ILogicalOperator>> translate(List<Operator> hiveRoot,

-            Mutable<ILogicalOperator> AlgebricksParentOperator) throws AlgebricksException {

+	/**

+	 * translate operator DAG

+	 * 

+	 * @param hiveRoot

+	 * @param AlgebricksParentOperator

+	 * @return

+	 */

+	private List<Mutable<ILogicalOperator>> translate(List<Operator> hiveRoot,

+			Mutable<ILogicalOperator> AlgebricksParentOperator)

+			throws AlgebricksException {

 

-        for (Operator hiveOperator : hiveRoot) {

-            continueTraverse = true;

-            Mutable<ILogicalOperator> currentOperatorRef = null;

-            if (hiveOperator.getType() == OperatorType.FILTER) {

-                FilterOperator fop = (FilterOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.REDUCESINK) {

-                ReduceSinkOperator fop = (ReduceSinkOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.JOIN) {

-                JoinOperator fop = (JoinOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null) {

-                        continueTraverse = true;

-                        break;

-                    } else

-                        continueTraverse = false;

-                }

-                if (currentOperatorRef == null)

-                    return null;

-            } else if (hiveOperator.getType() == OperatorType.LATERALVIEWJOIN) {

-                LateralViewJoinOperator fop = (LateralViewJoinOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-                if (currentOperatorRef == null)

-                    return null;

-            } else if (hiveOperator.getType() == OperatorType.MAPJOIN) {

-                MapJoinOperator fop = (MapJoinOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null) {

-                        continueTraverse = true;

-                        break;

-                    } else

-                        continueTraverse = false;

-                }

-                if (currentOperatorRef == null)

-                    return null;

-            } else if (hiveOperator.getType() == OperatorType.SELECT) {

-                SelectOperator fop = (SelectOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.EXTRACT) {

-                ExtractOperator fop = (ExtractOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.GROUPBY) {

-                GroupByOperator fop = (GroupByOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.TABLESCAN) {

-                TableScanOperator fop = (TableScanOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.FILESINK) {

-                FileSinkOperator fop = (FileSinkOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(fop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.LIMIT) {

-                LimitOperator lop = (LimitOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.UDTF) {

-                UDTFOperator lop = (UDTFOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null)

-                        break;

-                }

-            } else if (hiveOperator.getType() == OperatorType.UNION) {

-                UnionOperator lop = (UnionOperator) hiveOperator;

-                for (Visitor visitor : visitors) {

-                    currentOperatorRef = visitor.visit(lop, AlgebricksParentOperator, this);

-                    if (currentOperatorRef != null) {

-                        continueTraverse = true;

-                        break;

-                    } else

-                        continueTraverse = false;

-                }

-            } else

-                ;

-            if (hiveOperator.getChildOperators() != null && hiveOperator.getChildOperators().size() > 0

-                    && continueTraverse) {

-                List<Operator> children = hiveOperator.getChildOperators();

-                if (currentOperatorRef == null)

-                    currentOperatorRef = AlgebricksParentOperator;

-                translate(children, currentOperatorRef);

-            }

-            if (hiveOperator.getChildOperators() == null || hiveOperator.getChildOperators().size() == 0)

-                logicalOp.add(currentOperatorRef);

-        }

-        return logicalOp;

-    }

+		for (Operator hiveOperator : hiveRoot) {

+			continueTraverse = true;

+			Mutable<ILogicalOperator> currentOperatorRef = null;

+			if (hiveOperator.getType() == OperatorType.FILTER) {

+				FilterOperator fop = (FilterOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.REDUCESINK) {

+				ReduceSinkOperator fop = (ReduceSinkOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.JOIN) {

+				JoinOperator fop = (JoinOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null) {

+						continueTraverse = true;

+						break;

+					} else

+						continueTraverse = false;

+				}

+				if (currentOperatorRef == null)

+					return null;

+			} else if (hiveOperator.getType() == OperatorType.LATERALVIEWJOIN) {

+				LateralViewJoinOperator fop = (LateralViewJoinOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+				if (currentOperatorRef == null)

+					return null;

+			} else if (hiveOperator.getType() == OperatorType.MAPJOIN) {

+				MapJoinOperator fop = (MapJoinOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null) {

+						continueTraverse = true;

+						break;

+					} else

+						continueTraverse = false;

+				}

+				if (currentOperatorRef == null)

+					return null;

+			} else if (hiveOperator.getType() == OperatorType.SELECT) {

+				SelectOperator fop = (SelectOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.EXTRACT) {

+				ExtractOperator fop = (ExtractOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.GROUPBY) {

+				GroupByOperator fop = (GroupByOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.TABLESCAN) {

+				TableScanOperator fop = (TableScanOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.FILESINK) {

+				FileSinkOperator fop = (FileSinkOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(fop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.LIMIT) {

+				LimitOperator lop = (LimitOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(lop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.UDTF) {

+				UDTFOperator lop = (UDTFOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(lop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null)

+						break;

+				}

+			} else if (hiveOperator.getType() == OperatorType.UNION) {

+				UnionOperator lop = (UnionOperator) hiveOperator;

+				for (Visitor visitor : visitors) {

+					currentOperatorRef = visitor.visit(lop,

+							AlgebricksParentOperator, this);

+					if (currentOperatorRef != null) {

+						continueTraverse = true;

+						break;

+					} else

+						continueTraverse = false;

+				}

+			} else

+				;

+			if (hiveOperator.getChildOperators() != null

+					&& hiveOperator.getChildOperators().size() > 0

+					&& continueTraverse) {

+				List<Operator> children = hiveOperator.getChildOperators();

+				if (currentOperatorRef == null)

+					currentOperatorRef = AlgebricksParentOperator;

+				translate(children, currentOperatorRef);

+			}

+			if (hiveOperator.getChildOperators() == null

+					|| hiveOperator.getChildOperators().size() == 0)

+				logicalOp.add(currentOperatorRef);

+		}

+		return logicalOp;

+	}

 

-    /**

-     * used in select, group by to get no-column-expression columns

-     * 

-     * @param cols

-     * @return

-     */

-    public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent, List<ExprNodeDesc> cols,

-            ArrayList<LogicalVariable> variables) {

+	/**

+	 * used in select, group by to get no-column-expression columns

+	 * 

+	 * @param cols

+	 * @return

+	 */

+	public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent,

+			List<ExprNodeDesc> cols, ArrayList<LogicalVariable> variables) {

 

-        ArrayList<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();

+		ArrayList<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>();

 

-        /**

-         * variables to be appended in the assign operator

-         */

-        ArrayList<LogicalVariable> appendedVariables = new ArrayList<LogicalVariable>();

+		/**

+		 * variables to be appended in the assign operator

+		 */

+		ArrayList<LogicalVariable> appendedVariables = new ArrayList<LogicalVariable>();

 

-        // one variable can only be assigned once

-        for (ExprNodeDesc hiveExpr : cols) {

-            rewriteExpression(hiveExpr);

+		// one variable can only be assigned once

+		for (ExprNodeDesc hiveExpr : cols) {

+			rewriteExpression(hiveExpr);

 

-            if (hiveExpr instanceof ExprNodeColumnDesc) {

-                ExprNodeColumnDesc desc2 = (ExprNodeColumnDesc) hiveExpr;

-                String fieldName = desc2.getTabAlias() + "." + desc2.getColumn();

+			if (hiveExpr instanceof ExprNodeColumnDesc) {

+				ExprNodeColumnDesc desc2 = (ExprNodeColumnDesc) hiveExpr;

+				String fieldName = desc2.getTabAlias() + "."

+						+ desc2.getColumn();

 

-                // System.out.println("project expr: " + fieldName);

+				// System.out.println("project expr: " + fieldName);

 

-                if (fieldName.indexOf("$$") < 0) {

-                    LogicalVariable var = getVariable(fieldName, hiveExpr.getTypeInfo());

-                    desc2.setColumn(var.toString());

-                    desc2.setTabAlias("");

-                    variables.add(var);

-                } else {

-                    LogicalVariable var = nameToLogicalVariableMap.get(desc2.getColumn());

-                    String name = this.logicalVariableToFieldMap.get(var);

-                    var = this.getVariableOnly(name);

-                    variables.add(var);

-                }

-            } else {

-                Mutable<ILogicalExpression> asterixExpr = translateScalarFucntion(hiveExpr);

-                expressions.add(asterixExpr);

-                LogicalVariable var = getVariable(hiveExpr.getExprString() + asterixExpr.hashCode(),

-                        hiveExpr.getTypeInfo());

-                variables.add(var);

-                appendedVariables.add(var);

-            }

-        }

+				if (fieldName.indexOf("$$") < 0) {

+					LogicalVariable var = getVariable(fieldName,

+							hiveExpr.getTypeInfo());

+					desc2.setColumn(var.toString());

+					desc2.setTabAlias("");

+					variables.add(var);

+				} else {

+					LogicalVariable var = nameToLogicalVariableMap.get(desc2

+							.getColumn());

+					String name = this.logicalVariableToFieldMap.get(var);

+					var = this.getVariableOnly(name);

+					variables.add(var);

+				}

+			} else {

+				Mutable<ILogicalExpression> asterixExpr = translateScalarFucntion(hiveExpr);

+				expressions.add(asterixExpr);

+				LogicalVariable var = getVariable(hiveExpr.getExprString()

+						+ asterixExpr.hashCode(), hiveExpr.getTypeInfo());

+				variables.add(var);

+				appendedVariables.add(var);

+			}

+		}

 

-        /**

-         * create an assign operator to deal with appending

-         */

-        ILogicalOperator assignOp = null;

-        if (appendedVariables.size() > 0) {

-            assignOp = new AssignOperator(appendedVariables, expressions);

-            assignOp.getInputs().add(parent);

-        }

-        return assignOp;

-    }

+		/**

+		 * create an assign operator to deal with appending

+		 */

+		ILogicalOperator assignOp = null;

+		if (appendedVariables.size() > 0) {

+			assignOp = new AssignOperator(appendedVariables, expressions);

+			assignOp.getInputs().add(parent);

+		}

+		return assignOp;

+	}

 

-    private ILogicalPlan plan;

+	private ILogicalPlan plan;

 

-    public ILogicalPlan genLogicalPlan() {

-        plan = new ALogicalPlanImpl(rootOperators);

-        return plan;

-    }

+	public ILogicalPlan genLogicalPlan() {

+		plan = new ALogicalPlanImpl(rootOperators);

+		return plan;

+	}

 

-    public void printOperators() throws AlgebricksException {

-        LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();

-        StringBuilder buffer = new StringBuilder();

-        PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);

-        outputWriter.println(buffer);

-        outputWriter.println("rewritten variables: ");

-        outputWriter.flush();

-        printVariables();

+	public void printOperators() throws AlgebricksException {

+		LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();

+		StringBuilder buffer = new StringBuilder();

+		PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);

+		outputWriter.println(buffer);

+		outputWriter.println("rewritten variables: ");

+		outputWriter.flush();

+		printVariables();

 

-    }

+	}

 

-    public static void setOutputPrinter(PrintWriter writer) {

-        outputWriter = writer;

-    }

+	public static void setOutputPrinter(PrintWriter writer) {

+		outputWriter = writer;

+	}

 

-    private void printVariables() {

-        Set<Entry<String, LogicalVariable>> entries = fieldToLogicalVariableMap.entrySet();

+	private void printVariables() {

+		Set<Entry<String, LogicalVariable>> entries = fieldToLogicalVariableMap

+				.entrySet();

 

-        for (Entry<String, LogicalVariable> entry : entries) {

-            outputWriter.println(entry.getKey() + " -> " + entry.getValue());

-        }

-        outputWriter.flush();

-    }

+		for (Entry<String, LogicalVariable> entry : entries) {

+			outputWriter.println(entry.getKey() + " -> " + entry.getValue());

+		}

+		outputWriter.flush();

+	}

 

-    /**

-     * generate the object inspector for the output of an operator

-     * 

-     * @param operator

-     *            The Hive operator

-     * @return an ObjectInspector object

-     */

-    public Schema generateInputSchema(Operator operator) {

-        List<String> variableNames = new ArrayList<String>();

-        List<TypeInfo> typeList = new ArrayList<TypeInfo>();

-        List<ColumnInfo> columns = operator.getSchema().getSignature();

+	/**

+	 * generate the object inspector for the output of an operator

+	 * 

+	 * @param operator

+	 *            The Hive operator

+	 * @return an ObjectInspector object

+	 */

+	public Schema generateInputSchema(Operator operator) {

+		List<String> variableNames = new ArrayList<String>();

+		List<TypeInfo> typeList = new ArrayList<TypeInfo>();

+		List<ColumnInfo> columns = operator.getSchema().getSignature();

 

-        for (ColumnInfo col : columns) {

-            // typeList.add();

-            TypeInfo type = col.getType();

-            typeList.add(type);

+		for (ColumnInfo col : columns) {

+			// typeList.add();

+			TypeInfo type = col.getType();

+			typeList.add(type);

 

-            String fieldName = col.getInternalName();

-            variableNames.add(fieldName);

-        }

+			String fieldName = col.getInternalName();

+			variableNames.add(fieldName);

+		}

 

-        return new Schema(variableNames, typeList);

-    }

+		return new Schema(variableNames, typeList);

+	}

 

-    /**

-     * rewrite the names of output columns for feature expression evaluators to

-     * use

-     * 

-     * @param operator

-     */

-    public void rewriteOperatorOutputSchema(Operator operator) {

-        List<ColumnInfo> columns = operator.getSchema().getSignature();

+	/**

+	 * rewrite the names of output columns for feature expression evaluators to

+	 * use

+	 * 

+	 * @param operator

+	 */

+	public void rewriteOperatorOutputSchema(Operator operator) {

+		List<ColumnInfo> columns = operator.getSchema().getSignature();

 

-        for (ColumnInfo column : columns) {

-            String columnName = column.getTabAlias() + "." + column.getInternalName();

-            if (columnName.indexOf("$$") < 0) {

-                LogicalVariable var = getVariable(columnName, column.getType());

-                column.setInternalName(var.toString());

-            }

-        }

-    }

+		for (ColumnInfo column : columns) {

+			String columnName = column.getTabAlias() + "."

+					+ column.getInternalName();

+			if (columnName.indexOf("$$") < 0) {

+				LogicalVariable var = getVariable(columnName, column.getType());

+				column.setInternalName(var.toString());

+			}

+		}

+	}

 

-    @Override

-    public void rewriteOperatorOutputSchema(List<LogicalVariable> variables, Operator operator) {

+	@Override

+	public void rewriteOperatorOutputSchema(List<LogicalVariable> variables,

+			Operator operator) {

 

-        printOperatorSchema(operator);

-        List<ColumnInfo> columns = operator.getSchema().getSignature();

-        if (variables.size() != columns.size()) {

-            System.out.println("output cardinality error " + operator.getName() + " variable size: " + variables.size()

-                    + " expected " + columns.size());

-        }

+		printOperatorSchema(operator);

+		List<ColumnInfo> columns = operator.getSchema().getSignature();

+		if (variables.size() != columns.size()) {

+			System.out.println("output cardinality error " + operator.getName()

+					+ " variable size: " + variables.size() + " expected "

+					+ columns.size());

+		}

 

-        for (int i = 0; i < variables.size(); i++) {

-            LogicalVariable var = variables.get(i);

-            ColumnInfo column = columns.get(i);

-            String fieldName = column.getTabAlias() + "." + column.getInternalName();

-            if (fieldName.indexOf("$$") < 0) {

-                updateVariable(fieldName, var);

-                column.setInternalName(var.toString());

-            }

-        }

-        printOperatorSchema(operator);

-    }

+		for (int i = 0; i < variables.size(); i++) {

+			LogicalVariable var = variables.get(i);

+			ColumnInfo column = columns.get(i);

+			String fieldName = column.getTabAlias() + "."

+					+ column.getInternalName();

+			if (fieldName.indexOf("$$") < 0) {

+				updateVariable(fieldName, var);

+				column.setInternalName(var.toString());

+			}

+		}

+		printOperatorSchema(operator);

+	}

 

-    /**

-     * rewrite an expression and substitute variables

-     * 

-     * @param expr

-     *            hive expression

-     */

-    public void rewriteExpression(ExprNodeDesc expr) {

-        if (expr instanceof ExprNodeColumnDesc) {

-            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;

-            String fieldName = desc.getTabAlias() + "." + desc.getColumn();

-            if (fieldName.indexOf("$$") < 0) {

-                LogicalVariable var = getVariableOnly(fieldName);

-                if (var == null) {

-                    fieldName = "." + desc.getColumn();

-                    var = getVariableOnly(fieldName);

-                    if (var == null) {

-                        fieldName = "null." + desc.getColumn();

-                        var = getVariableOnly(fieldName);

-                        if (var == null) {

-                            System.out.println(fieldName + " is wrong!!! ");

-                        }

-                    }

-                }

-                String name = this.logicalVariableToFieldMap.get(var);

-                var = getVariableOnly(name);

-                desc.setColumn(var.toString());

-            }

-        } else {

-            if (expr.getChildren() != null && expr.getChildren().size() > 0) {

-                List<ExprNodeDesc> children = expr.getChildren();

-                for (ExprNodeDesc desc : children)

-                    rewriteExpression(desc);

-            }

-        }

-    }

+	/**

+	 * rewrite an expression and substitute variables

+	 * 

+	 * @param expr

+	 *            hive expression

+	 */

+	public void rewriteExpression(ExprNodeDesc expr) {

+		if (expr instanceof ExprNodeColumnDesc) {

+			ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;

+			String fieldName = desc.getTabAlias() + "." + desc.getColumn();

+			if (fieldName.indexOf("$$") < 0) {

+				LogicalVariable var = getVariableOnly(fieldName);

+				if (var == null) {

+					fieldName = "." + desc.getColumn();

+					var = getVariableOnly(fieldName);

+					if (var == null) {

+						fieldName = "null." + desc.getColumn();

+						var = getVariableOnly(fieldName);

+						if (var == null) {

+							System.out.println(fieldName + " is wrong!!! ");

+						}

+					}

+				}

+				String name = this.logicalVariableToFieldMap.get(var);

+				var = getVariableOnly(name);

+				desc.setColumn(var.toString());

+			}

+		} else {

+			if (expr.getChildren() != null && expr.getChildren().size() > 0) {

+				List<ExprNodeDesc> children = expr.getChildren();

+				for (ExprNodeDesc desc : children)

+					rewriteExpression(desc);

+			}

+		}

+	}

 

-    /**

-     * rewrite an expression and substitute variables

-     * 

-     * @param expr

-     *            hive expression

-     */

-    public void rewriteExpressionPartial(ExprNodeDesc expr) {

-        if (expr instanceof ExprNodeColumnDesc) {

-            ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;

-            String fieldName = desc.getTabAlias() + "." + desc.getColumn();

-            if (fieldName.indexOf("$$") < 0) {

-                LogicalVariable var = getVariableOnly(fieldName);

-                desc.setColumn(var.toString());

-            }

-        } else {

-            if (expr.getChildren() != null && expr.getChildren().size() > 0) {

-                List<ExprNodeDesc> children = expr.getChildren();

-                for (ExprNodeDesc desc : children)

-                    rewriteExpressionPartial(desc);

-            }

-        }

-    }

+	/**

+	 * rewrite an expression and substitute variables

+	 * 

+	 * @param expr

+	 *            hive expression

+	 */

+	public void rewriteExpressionPartial(ExprNodeDesc expr) {

+		if (expr instanceof ExprNodeColumnDesc) {

+			ExprNodeColumnDesc desc = (ExprNodeColumnDesc) expr;

+			String fieldName = desc.getTabAlias() + "." + desc.getColumn();

+			if (fieldName.indexOf("$$") < 0) {

+				LogicalVariable var = getVariableOnly(fieldName);

+				desc.setColumn(var.toString());

+			}

+		} else {

+			if (expr.getChildren() != null && expr.getChildren().size() > 0) {

+				List<ExprNodeDesc> children = expr.getChildren();

+				for (ExprNodeDesc desc : children)

+					rewriteExpressionPartial(desc);

+			}

+		}

+	}

 

-    private void printOperatorSchema(Operator operator) {

-        System.out.println(operator.getName());

-        List<ColumnInfo> columns = operator.getSchema().getSignature();

-        for (ColumnInfo column : columns) {

-            System.out.print(column.getTabAlias() + "." + column.getInternalName() + "  ");

-        }

-        System.out.println();

-    }

+	private void printOperatorSchema(Operator operator) {

+		System.out.println(operator.getName());

+		List<ColumnInfo> columns = operator.getSchema().getSignature();

+		for (ColumnInfo column : columns) {

+			System.out.print(column.getTabAlias() + "."

+					+ column.getInternalName() + "  ");

+		}

+		System.out.println();

+	}

 

-    /**

-     * translate scalar function expression

-     * 

-     * @param hiveExpr

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateScalarFucntion(ExprNodeDesc hiveExpr) {

-        ILogicalExpression AlgebricksExpr;

+	/**

+	 * translate scalar function expression

+	 * 

+	 * @param hiveExpr

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateScalarFucntion(

+			ExprNodeDesc hiveExpr) {

+		ILogicalExpression AlgebricksExpr;

 

-        if (hiveExpr instanceof ExprNodeGenericFuncDesc) {

-            List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();

-            List<ExprNodeDesc> children = hiveExpr.getChildren();

+		if (hiveExpr instanceof ExprNodeGenericFuncDesc) {

+			List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();

+			List<ExprNodeDesc> children = hiveExpr.getChildren();

 

-            for (ExprNodeDesc child : children)

-                arguments.add(translateScalarFucntion(child));

+			for (ExprNodeDesc child : children)

+				arguments.add(translateScalarFucntion(child));

 

-            ExprNodeGenericFuncDesc funcExpr = (ExprNodeGenericFuncDesc) hiveExpr;

-            GenericUDF genericUdf = funcExpr.getGenericUDF();

-            UDF udf = null;

-            if (genericUdf instanceof GenericUDFBridge) {

-                GenericUDFBridge bridge = (GenericUDFBridge) genericUdf;

-                try {

-                    udf = bridge.getUdfClass().newInstance();

-                } catch (Exception e) {

-                    e.printStackTrace();

-                }

-            }

+			ExprNodeGenericFuncDesc funcExpr = (ExprNodeGenericFuncDesc) hiveExpr;

+			GenericUDF genericUdf = funcExpr.getGenericUDF();

+			UDF udf = null;

+			if (genericUdf instanceof GenericUDFBridge) {

+				GenericUDFBridge bridge = (GenericUDFBridge) genericUdf;

+				try {

+					udf = bridge.getUdfClass().newInstance();

+				} catch (Exception e) {

+					e.printStackTrace();

+				}

+			}

 

-            /**

-             * set up the hive function

-             */

-            Object hiveFunction = genericUdf;

-            if (udf != null)

-                hiveFunction = udf;

+			/**

+			 * set up the hive function

+			 */

+			Object hiveFunction = genericUdf;

+			if (udf != null)

+				hiveFunction = udf;

 

-            FunctionIdentifier funcId = HiveAlgebricksBuiltInFunctionMap.INSTANCE.getAlgebricksFunctionId(hiveFunction

-                    .getClass());

-            if (funcId == null) {

-                funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, hiveFunction.getClass().getName());

-            }

+			FunctionIdentifier funcId = HiveAlgebricksBuiltInFunctionMap.INSTANCE

+					.getAlgebricksFunctionId(hiveFunction.getClass());

+			if (funcId == null) {

+				funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,

+						hiveFunction.getClass().getName());

+			}

 

-            Object functionInfo = null;

-            if (genericUdf instanceof GenericUDFBridge) {

-                functionInfo = funcExpr;

-            }

+			Object functionInfo = null;

+			if (genericUdf instanceof GenericUDFBridge) {

+				functionInfo = funcExpr;

+			}

 

-            /**

-             * generate the function call expression

-             */

-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(

-                    funcId, functionInfo), arguments);

-            AlgebricksExpr = AlgebricksFuncExpr;

+			/**

+			 * generate the function call expression

+			 */

+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(

+					new HiveFunctionInfo(funcId, functionInfo), arguments);

+			AlgebricksExpr = AlgebricksFuncExpr;

 

-        } else if (hiveExpr instanceof ExprNodeColumnDesc) {

-            ExprNodeColumnDesc column = (ExprNodeColumnDesc) hiveExpr;

-            LogicalVariable var = this.getVariable(column.getColumn());

-            AlgebricksExpr = new VariableReferenceExpression(var);

+		} else if (hiveExpr instanceof ExprNodeColumnDesc) {

+			ExprNodeColumnDesc column = (ExprNodeColumnDesc) hiveExpr;

+			LogicalVariable var = this.getVariable(column.getColumn());

+			AlgebricksExpr = new VariableReferenceExpression(var);

 

-        } else if (hiveExpr instanceof ExprNodeFieldDesc) {

-            FunctionIdentifier funcId;

-            funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, ExpressionConstant.FIELDACCESS);

+		} else if (hiveExpr instanceof ExprNodeFieldDesc) {

+			FunctionIdentifier funcId;

+			funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,

+					ExpressionConstant.FIELDACCESS);

 

-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(

-                    funcId, hiveExpr));

-            AlgebricksExpr = AlgebricksFuncExpr;

-        } else if (hiveExpr instanceof ExprNodeConstantDesc) {

-            ExprNodeConstantDesc hiveConst = (ExprNodeConstantDesc) hiveExpr;

-            Object value = hiveConst.getValue();

-            AlgebricksExpr = new ConstantExpression(new HivesterixConstantValue(value));

-        } else if (hiveExpr instanceof ExprNodeNullDesc) {

-            FunctionIdentifier funcId;

-            funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, ExpressionConstant.NULL);

+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(

+					new HiveFunctionInfo(funcId, hiveExpr));

+			AlgebricksExpr = AlgebricksFuncExpr;

+		} else if (hiveExpr instanceof ExprNodeConstantDesc) {

+			ExprNodeConstantDesc hiveConst = (ExprNodeConstantDesc) hiveExpr;

+			Object value = hiveConst.getValue();

+			AlgebricksExpr = new ConstantExpression(

+					new HivesterixConstantValue(value));

+		} else if (hiveExpr instanceof ExprNodeNullDesc) {

+			FunctionIdentifier funcId;

+			funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE,

+					ExpressionConstant.NULL);

 

-            ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(new HiveFunctionInfo(

-                    funcId, hiveExpr));

+			ScalarFunctionCallExpression AlgebricksFuncExpr = new ScalarFunctionCallExpression(

+					new HiveFunctionInfo(funcId, hiveExpr));

 

-            AlgebricksExpr = AlgebricksFuncExpr;

-        } else {

-            throw new IllegalStateException("unknown hive expression");

-        }

-        return new MutableObject<ILogicalExpression>(AlgebricksExpr);

-    }

+			AlgebricksExpr = AlgebricksFuncExpr;

+		} else {

+			throw new IllegalStateException("unknown hive expression");

+		}

+		return new MutableObject<ILogicalExpression>(AlgebricksExpr);

+	}

 

-    /**

-     * translate aggregation function expression

-     * 

-     * @param aggregateDesc

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateAggregation(AggregationDesc aggregateDesc) {

+	/**

+	 * translate aggregation function expression

+	 * 

+	 * @param aggregateDesc

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateAggregation(

+			AggregationDesc aggregateDesc) {

 

-        String UDAFName = aggregateDesc.getGenericUDAFName();

+		String UDAFName = aggregateDesc.getGenericUDAFName();

 

-        List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();

-        List<ExprNodeDesc> children = aggregateDesc.getParameters();

+		List<Mutable<ILogicalExpression>> arguments = new ArrayList<Mutable<ILogicalExpression>>();

+		List<ExprNodeDesc> children = aggregateDesc.getParameters();

 

-        for (ExprNodeDesc child : children)

-            arguments.add(translateScalarFucntion(child));

+		for (ExprNodeDesc child : children)

+			arguments.add(translateScalarFucntion(child));

 

-        FunctionIdentifier funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, UDAFName + "("

-                + aggregateDesc.getMode() + ")");

-        HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, aggregateDesc);

-        AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(funcInfo, false,

-                arguments);

-        return new MutableObject<ILogicalExpression>(aggregationExpression);

-    }

+		FunctionIdentifier funcId = new FunctionIdentifier(

+				ExpressionConstant.NAMESPACE, UDAFName + "("

+						+ aggregateDesc.getMode() + ")");

+		HiveFunctionInfo funcInfo = new HiveFunctionInfo(funcId, aggregateDesc);

+		AggregateFunctionCallExpression aggregationExpression = new AggregateFunctionCallExpression(

+				funcInfo, false, arguments);

+		return new MutableObject<ILogicalExpression>(aggregationExpression);

+	}

 

-    /**

-     * translate aggregation function expression

-     * 

-     * @param aggregator

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateUnnestFunction(UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument) {

+	/**

+	 * translate aggregation function expression

+	 * 

+	 * @param aggregator

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateUnnestFunction(

+			UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument) {

 

-        String UDTFName = udtfDesc.getUDTFName();

+		String UDTFName = udtfDesc.getUDTFName();

 

-        FunctionIdentifier funcId = new FunctionIdentifier(ExpressionConstant.NAMESPACE, UDTFName);

-        UnnestingFunctionCallExpression unnestingExpression = new UnnestingFunctionCallExpression(new HiveFunctionInfo(

-                funcId, udtfDesc));

-        unnestingExpression.getArguments().add(argument);

-        return new MutableObject<ILogicalExpression>(unnestingExpression);

-    }

+		FunctionIdentifier funcId = new FunctionIdentifier(

+				ExpressionConstant.NAMESPACE, UDTFName);

+		UnnestingFunctionCallExpression unnestingExpression = new UnnestingFunctionCallExpression(

+				new HiveFunctionInfo(funcId, udtfDesc));

+		unnestingExpression.getArguments().add(argument);

+		return new MutableObject<ILogicalExpression>(unnestingExpression);

+	}

 

-    /**

-     * get typeinfo

-     */

-    @Override

-    public TypeInfo getType(LogicalVariable var) {

-        return variableToType.get(var);

-    }

+	/**

+	 * get typeinfo

+	 */

+	@Override

+	public TypeInfo getType(LogicalVariable var) {

+		return variableToType.get(var);

+	}

 

-    /**

-     * get variable from variable name

-     */

-    @Override

-    public LogicalVariable getVariable(String name) {

-        return nameToLogicalVariableMap.get(name);

-    }

+	/**

+	 * get variable from variable name

+	 */

+	@Override

+	public LogicalVariable getVariable(String name) {

+		return nameToLogicalVariableMap.get(name);

+	}

 

-    @Override

-    public LogicalVariable getVariableFromFieldName(String fieldName) {

-        return this.getVariableOnly(fieldName);

-    }

+	@Override

+	public LogicalVariable getVariableFromFieldName(String fieldName) {

+		return this.getVariableOnly(fieldName);

+	}

 

-    /**

-     * set the metadata provider

-     */

-    @Override

-    public void setMetadataProvider(IMetadataProvider<PartitionDesc, Object> metadata) {

-        this.metaData = metadata;

-    }

+	/**

+	 * set the metadata provider

+	 */

+	@Override

+	public void setMetadataProvider(

+			IMetadataProvider<PartitionDesc, Object> metadata) {

+		this.metaData = metadata;

+	}

 

-    /**

-     * insert ReplicateOperator when necessary

-     */

-    private void insertReplicateOperator(List<Mutable<ILogicalOperator>> roots) {

-        Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childToParentsMap = new HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>>();

-        buildChildToParentsMapping(roots, childToParentsMap);

-        for (Entry<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> entry : childToParentsMap.entrySet()) {

-            List<Mutable<ILogicalOperator>> pList = entry.getValue();

-            if (pList.size() > 1) {

-                ILogicalOperator rop = new ReplicateOperator(pList.size());

-                Mutable<ILogicalOperator> ropRef = new MutableObject<ILogicalOperator>(rop);

-                Mutable<ILogicalOperator> childRef = entry.getKey();

-                rop.getInputs().add(childRef);

-                for (Mutable<ILogicalOperator> parentRef : pList) {

-                    ILogicalOperator parentOp = parentRef.getValue();

-                    int index = parentOp.getInputs().indexOf(childRef);

-                    parentOp.getInputs().set(index, ropRef);

-                }

-            }

-        }

-    }

+	/**

+	 * insert ReplicateOperator when necessary

+	 */

+	private void insertReplicateOperator(List<Mutable<ILogicalOperator>> roots) {

+		Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childToParentsMap = new HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>>();

+		buildChildToParentsMapping(roots, childToParentsMap);

+		for (Entry<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> entry : childToParentsMap

+				.entrySet()) {

+			List<Mutable<ILogicalOperator>> pList = entry.getValue();

+			if (pList.size() > 1) {

+				ILogicalOperator rop = new ReplicateOperator(pList.size());

+				Mutable<ILogicalOperator> ropRef = new MutableObject<ILogicalOperator>(

+						rop);

+				Mutable<ILogicalOperator> childRef = entry.getKey();

+				rop.getInputs().add(childRef);

+				for (Mutable<ILogicalOperator> parentRef : pList) {

+					ILogicalOperator parentOp = parentRef.getValue();

+					int index = parentOp.getInputs().indexOf(childRef);

+					parentOp.getInputs().set(index, ropRef);

+				}

+			}

+		}

+	}

 

-    /**

-     * build the mapping from child to Parents

-     * 

-     * @param roots

-     * @param childToParentsMap

-     */

-    private void buildChildToParentsMapping(List<Mutable<ILogicalOperator>> roots,

-            Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> map) {

-        for (Mutable<ILogicalOperator> opRef : roots) {

-            List<Mutable<ILogicalOperator>> childRefs = opRef.getValue().getInputs();

-            for (Mutable<ILogicalOperator> childRef : childRefs) {

-                List<Mutable<ILogicalOperator>> parentList = map.get(childRef);

-                if (parentList == null) {

-                    parentList = new ArrayList<Mutable<ILogicalOperator>>();

-                    map.put(childRef, parentList);

-                }

-                if (!parentList.contains(opRef))

-                    parentList.add(opRef);

-            }

-            buildChildToParentsMapping(childRefs, map);

-        }

-    }

+	/**

+	 * build the mapping from child to Parents

+	 * 

+	 * @param roots

+	 * @param childToParentsMap

+	 */

+	private void buildChildToParentsMapping(

+			List<Mutable<ILogicalOperator>> roots,

+			Map<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> map) {

+		for (Mutable<ILogicalOperator> opRef : roots) {

+			List<Mutable<ILogicalOperator>> childRefs = opRef.getValue()

+					.getInputs();

+			for (Mutable<ILogicalOperator> childRef : childRefs) {

+				List<Mutable<ILogicalOperator>> parentList = map.get(childRef);

+				if (parentList == null) {

+					parentList = new ArrayList<Mutable<ILogicalOperator>>();

+					map.put(childRef, parentList);

+				}

+				if (!parentList.contains(opRef))

+					parentList.add(opRef);

+			}

+			buildChildToParentsMapping(childRefs, map);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveLogicalPlanAndMetaData.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveLogicalPlanAndMetaData.java
index a34371a..b33e725 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveLogicalPlanAndMetaData.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveLogicalPlanAndMetaData.java
@@ -7,28 +7,29 @@
 

 public class HiveLogicalPlanAndMetaData implements ILogicalPlanAndMetadata {

 

-    IMetadataProvider metadata;

-    ILogicalPlan plan;

+	IMetadataProvider metadata;

+	ILogicalPlan plan;

 

-    public HiveLogicalPlanAndMetaData(ILogicalPlan plan, IMetadataProvider metadata) {

-        this.plan = plan;

-        this.metadata = metadata;

-    }

+	public HiveLogicalPlanAndMetaData(ILogicalPlan plan,

+			IMetadataProvider metadata) {

+		this.plan = plan;

+		this.metadata = metadata;

+	}

 

-    @Override

-    public IMetadataProvider getMetadataProvider() {

-        return metadata;

-    }

+	@Override

+	public IMetadataProvider getMetadataProvider() {

+		return metadata;

+	}

 

-    @Override

-    public ILogicalPlan getPlan() {

-        return plan;

-    }

+	@Override

+	public ILogicalPlan getPlan() {

+		return plan;

+	}

 

-    @Override

-    public AlgebricksPartitionConstraint getClusterLocations() {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public AlgebricksPartitionConstraint getClusterLocations() {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveOperatorAnnotations.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveOperatorAnnotations.java
index bf59900..0d234fb 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveOperatorAnnotations.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/HiveOperatorAnnotations.java
@@ -2,7 +2,7 @@
 
 public class HiveOperatorAnnotations {
 
-    // hints
-    public static final String LOCAL_GROUP_BY = "LOCAL_GROUP_BY"; 
-    
+	// hints
+	public static final String LOCAL_GROUP_BY = "LOCAL_GROUP_BY";
+
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ExtractVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ExtractVisitor.java
index 6b0aacd..9a84164 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ExtractVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ExtractVisitor.java
@@ -13,14 +13,16 @@
 

 public class ExtractVisitor extends DefaultVisitor {

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ExtractOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) {

-        Schema currentSchema = t.generateInputSchema(operator.getParentOperators().get(0));

-        operator.setSchema(operator.getParentOperators().get(0).getSchema());

-        List<LogicalVariable> latestOutputSchema = t.getVariablesFromSchema(currentSchema);

-        t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(ExtractOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		Schema currentSchema = t.generateInputSchema(operator

+				.getParentOperators().get(0));

+		operator.setSchema(operator.getParentOperators().get(0).getSchema());

+		List<LogicalVariable> latestOutputSchema = t

+				.getVariablesFromSchema(currentSchema);

+		t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/FilterVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/FilterVisitor.java
index 529fc09..b276ba9 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/FilterVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/FilterVisitor.java
@@ -18,24 +18,27 @@
 

 public class FilterVisitor extends DefaultVisitor {

 

-    @Override

-    public Mutable<ILogicalOperator> visit(FilterOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) {

-        Schema currentSchema = t.generateInputSchema(operator.getParentOperators().get(0));

+	@Override

+	public Mutable<ILogicalOperator> visit(FilterOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		Schema currentSchema = t.generateInputSchema(operator

+				.getParentOperators().get(0));

 

-        FilterDesc desc = (FilterDesc) operator.getConf();

-        ExprNodeDesc predicate = desc.getPredicate();

-        t.rewriteExpression(predicate);

+		FilterDesc desc = (FilterDesc) operator.getConf();

+		ExprNodeDesc predicate = desc.getPredicate();

+		t.rewriteExpression(predicate);

 

-        Mutable<ILogicalExpression> exprs = t.translateScalarFucntion(desc.getPredicate());

-        ILogicalOperator currentOperator = new SelectOperator(exprs);

-        currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+		Mutable<ILogicalExpression> exprs = t.translateScalarFucntion(desc

+				.getPredicate());

+		ILogicalOperator currentOperator = new SelectOperator(exprs);

+		currentOperator.getInputs().add(AlgebricksParentOperatorRef);

 

-        // populate the schema from upstream operator

-        operator.setSchema(operator.getParentOperators().get(0).getSchema());

-        List<LogicalVariable> latestOutputSchema = t.getVariablesFromSchema(currentSchema);

-        t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		// populate the schema from upstream operator

+		operator.setSchema(operator.getParentOperators().get(0).getSchema());

+		List<LogicalVariable> latestOutputSchema = t

+				.getVariablesFromSchema(currentSchema);

+		t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/GroupByVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/GroupByVisitor.java
index 4f6a31f..2ab941a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/GroupByVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/GroupByVisitor.java
@@ -46,218 +46,245 @@
 

 public class GroupByVisitor extends DefaultVisitor {

 

-    private List<Mutable<ILogicalExpression>> AlgebricksAggs = new ArrayList<Mutable<ILogicalExpression>>();

-    private List<IFunctionInfo> localAggs = new ArrayList<IFunctionInfo>();

-    private boolean isDistinct = false;

-    private boolean gbyKeyNotRedKey = false;

+	private List<Mutable<ILogicalExpression>> AlgebricksAggs = new ArrayList<Mutable<ILogicalExpression>>();

+	private List<IFunctionInfo> localAggs = new ArrayList<IFunctionInfo>();

+	private boolean isDistinct = false;

+	private boolean gbyKeyNotRedKey = false;

 

-    @Override

-    public Mutable<ILogicalOperator> visit(GroupByOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException {

+	@Override

+	public Mutable<ILogicalOperator> visit(GroupByOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException {

 

-        // get descriptors

-        GroupByDesc desc = (GroupByDesc) operator.getConf();

-        GroupByDesc.Mode mode = desc.getMode();

+		// get descriptors

+		GroupByDesc desc = (GroupByDesc) operator.getConf();

+		GroupByDesc.Mode mode = desc.getMode();

 

-        List<ExprNodeDesc> keys = desc.getKeys();

-        List<AggregationDesc> aggregators = desc.getAggregators();

+		List<ExprNodeDesc> keys = desc.getKeys();

+		List<AggregationDesc> aggregators = desc.getAggregators();

 

-        Operator child = operator.getChildOperators().get(0);

+		Operator child = operator.getChildOperators().get(0);

 

-        if (child.getType() == OperatorType.REDUCESINK) {

-            List<ExprNodeDesc> partKeys = ((ReduceSinkDesc) child.getConf()).getPartitionCols();

-            if (keys.size() != partKeys.size())

-                gbyKeyNotRedKey = true;

-        }

+		if (child.getType() == OperatorType.REDUCESINK) {

+			List<ExprNodeDesc> partKeys = ((ReduceSinkDesc) child.getConf())

+					.getPartitionCols();

+			if (keys.size() != partKeys.size())

+				gbyKeyNotRedKey = true;

+		}

 

-        if (mode == GroupByDesc.Mode.PARTIAL1 || mode == GroupByDesc.Mode.HASH || mode == GroupByDesc.Mode.COMPLETE

-                || (aggregators.size() == 0 && isDistinct == false) || gbyKeyNotRedKey) {

-            AlgebricksAggs.clear();

-            // add an assign operator if the key is not a column expression

-            ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

-            ILogicalOperator currentOperator = null;

-            ILogicalOperator assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef, keys, keyVariables);

-            if (assignOperator != null) {

-                currentOperator = assignOperator;

-                AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-            }

+		if (mode == GroupByDesc.Mode.PARTIAL1 || mode == GroupByDesc.Mode.HASH

+				|| mode == GroupByDesc.Mode.COMPLETE

+				|| (aggregators.size() == 0 && isDistinct == false)

+				|| gbyKeyNotRedKey) {

+			AlgebricksAggs.clear();

+			// add an assign operator if the key is not a column expression

+			ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

+			ILogicalOperator currentOperator = null;

+			ILogicalOperator assignOperator = t.getAssignOperator(

+					AlgebricksParentOperatorRef, keys, keyVariables);

+			if (assignOperator != null) {

+				currentOperator = assignOperator;

+				AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+						currentOperator);

+			}

 

-            // get key variable expression list

-            List<Mutable<ILogicalExpression>> keyExprs = new ArrayList<Mutable<ILogicalExpression>>();

-            for (LogicalVariable var : keyVariables) {

-                keyExprs.add(t.translateScalarFucntion(new ExprNodeColumnDesc(TypeInfoFactory.intTypeInfo, var

-                        .toString(), "", false)));

-            }

+			// get key variable expression list

+			List<Mutable<ILogicalExpression>> keyExprs = new ArrayList<Mutable<ILogicalExpression>>();

+			for (LogicalVariable var : keyVariables) {

+				keyExprs.add(t.translateScalarFucntion(new ExprNodeColumnDesc(

+						TypeInfoFactory.intTypeInfo, var.toString(), "", false)));

+			}

 

-            if (aggregators.size() == 0) {

-                List<Mutable<ILogicalExpression>> distinctExprs = new ArrayList<Mutable<ILogicalExpression>>();

-                for (LogicalVariable var : keyVariables) {

-                    Mutable<ILogicalExpression> varExpr = new MutableObject<ILogicalExpression>(

-                            new VariableReferenceExpression(var));

-                    distinctExprs.add(varExpr);

-                }

-                t.rewriteOperatorOutputSchema(keyVariables, operator);

-                isDistinct = true;

-                ILogicalOperator lop = new DistinctOperator(distinctExprs);

-                lop.getInputs().add(AlgebricksParentOperatorRef);

-                return new MutableObject<ILogicalOperator>(lop);

-            }

+			if (aggregators.size() == 0) {

+				List<Mutable<ILogicalExpression>> distinctExprs = new ArrayList<Mutable<ILogicalExpression>>();

+				for (LogicalVariable var : keyVariables) {

+					Mutable<ILogicalExpression> varExpr = new MutableObject<ILogicalExpression>(

+							new VariableReferenceExpression(var));

+					distinctExprs.add(varExpr);

+				}

+				t.rewriteOperatorOutputSchema(keyVariables, operator);

+				isDistinct = true;

+				ILogicalOperator lop = new DistinctOperator(distinctExprs);

+				lop.getInputs().add(AlgebricksParentOperatorRef);

+				return new MutableObject<ILogicalOperator>(lop);

+			}

 

-            // get the pair<LogicalVariable, ILogicalExpression> list

-            List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> keyParameters = new ArrayList<Pair<LogicalVariable, Mutable<ILogicalExpression>>>();

-            keyVariables.clear();

-            for (Mutable<ILogicalExpression> expr : keyExprs) {

-                LogicalVariable keyVar = t.getVariable(expr.getValue().toString(), TypeInfoFactory.unknownTypeInfo);

-                keyParameters.add(new Pair(keyVar, expr));

-                keyVariables.add(keyVar);

-            }

+			// get the pair<LogicalVariable, ILogicalExpression> list

+			List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> keyParameters = new ArrayList<Pair<LogicalVariable, Mutable<ILogicalExpression>>>();

+			keyVariables.clear();

+			for (Mutable<ILogicalExpression> expr : keyExprs) {

+				LogicalVariable keyVar = t.getVariable(expr.getValue()

+						.toString(), TypeInfoFactory.unknownTypeInfo);

+				keyParameters.add(new Pair(keyVar, expr));

+				keyVariables.add(keyVar);

+			}

 

-            // get the parameters for the aggregator operator

-            ArrayList<LogicalVariable> aggVariables = new ArrayList<LogicalVariable>();

-            ArrayList<Mutable<ILogicalExpression>> aggExprs = new ArrayList<Mutable<ILogicalExpression>>();

+			// get the parameters for the aggregator operator

+			ArrayList<LogicalVariable> aggVariables = new ArrayList<LogicalVariable>();

+			ArrayList<Mutable<ILogicalExpression>> aggExprs = new ArrayList<Mutable<ILogicalExpression>>();

 

-            // get the type of each aggregation function

-            HashMap<AggregationDesc, TypeInfo> aggToType = new HashMap<AggregationDesc, TypeInfo>();

-            List<ColumnInfo> columns = operator.getSchema().getSignature();

-            int offset = keys.size();

-            for (int i = offset; i < columns.size(); i++) {

-                aggToType.put(aggregators.get(i - offset), columns.get(i).getType());

-            }

+			// get the type of each aggregation function

+			HashMap<AggregationDesc, TypeInfo> aggToType = new HashMap<AggregationDesc, TypeInfo>();

+			List<ColumnInfo> columns = operator.getSchema().getSignature();

+			int offset = keys.size();

+			for (int i = offset; i < columns.size(); i++) {

+				aggToType.put(aggregators.get(i - offset), columns.get(i)

+						.getType());

+			}

 

-            localAggs.clear();

-            // rewrite parameter expressions for all aggregators

-            for (AggregationDesc aggregator : aggregators) {

-                for (ExprNodeDesc parameter : aggregator.getParameters()) {

-                    t.rewriteExpression(parameter);

-                }

-                Mutable<ILogicalExpression> aggExpr = t.translateAggregation(aggregator);

-                AbstractFunctionCallExpression localAggExpr = (AbstractFunctionCallExpression) aggExpr.getValue();

-                localAggs.add(localAggExpr.getFunctionInfo());

+			localAggs.clear();

+			// rewrite parameter expressions for all aggregators

+			for (AggregationDesc aggregator : aggregators) {

+				for (ExprNodeDesc parameter : aggregator.getParameters()) {

+					t.rewriteExpression(parameter);

+				}

+				Mutable<ILogicalExpression> aggExpr = t

+						.translateAggregation(aggregator);

+				AbstractFunctionCallExpression localAggExpr = (AbstractFunctionCallExpression) aggExpr

+						.getValue();

+				localAggs.add(localAggExpr.getFunctionInfo());

 

-                AggregationDesc logicalAgg = new AggregationDesc(aggregator.getGenericUDAFName(),

-                        aggregator.getGenericUDAFEvaluator(), aggregator.getParameters(), aggregator.getDistinct(),

-                        Mode.COMPLETE);

-                Mutable<ILogicalExpression> logicalAggExpr = t.translateAggregation(logicalAgg);

+				AggregationDesc logicalAgg = new AggregationDesc(

+						aggregator.getGenericUDAFName(),

+						aggregator.getGenericUDAFEvaluator(),

+						aggregator.getParameters(), aggregator.getDistinct(),

+						Mode.COMPLETE);

+				Mutable<ILogicalExpression> logicalAggExpr = t

+						.translateAggregation(logicalAgg);

 

-                AlgebricksAggs.add(logicalAggExpr);

-                if (!gbyKeyNotRedKey)

-                    aggExprs.add(logicalAggExpr);

-                else

-                    aggExprs.add(aggExpr);

+				AlgebricksAggs.add(logicalAggExpr);

+				if (!gbyKeyNotRedKey)

+					aggExprs.add(logicalAggExpr);

+				else

+					aggExprs.add(aggExpr);

 

-                aggVariables.add(t.getVariable(aggregator.getExprString() + aggregator.getMode(),

-                        aggToType.get(aggregator)));

-            }

+				aggVariables.add(t.getVariable(aggregator.getExprString()

+						+ aggregator.getMode(), aggToType.get(aggregator)));

+			}

 

-            if (child.getType() != OperatorType.REDUCESINK)

-                gbyKeyNotRedKey = false;

+			if (child.getType() != OperatorType.REDUCESINK)

+				gbyKeyNotRedKey = false;

 

-            // get the sub plan list

-            AggregateOperator aggOperator = new AggregateOperator(aggVariables, aggExprs);

-            NestedTupleSourceOperator nestedTupleSource = new NestedTupleSourceOperator(

-                    new MutableObject<ILogicalOperator>());

-            aggOperator.getInputs().add(new MutableObject<ILogicalOperator>(nestedTupleSource));

+			// get the sub plan list

+			AggregateOperator aggOperator = new AggregateOperator(aggVariables,

+					aggExprs);

+			NestedTupleSourceOperator nestedTupleSource = new NestedTupleSourceOperator(

+					new MutableObject<ILogicalOperator>());

+			aggOperator.getInputs().add(

+					new MutableObject<ILogicalOperator>(nestedTupleSource));

 

-            List<Mutable<ILogicalOperator>> subRoots = new ArrayList<Mutable<ILogicalOperator>>();

-            subRoots.add(new MutableObject<ILogicalOperator>(aggOperator));

-            ILogicalPlan subPlan = new ALogicalPlanImpl(subRoots);

-            List<ILogicalPlan> subPlans = new ArrayList<ILogicalPlan>();

-            subPlans.add(subPlan);

+			List<Mutable<ILogicalOperator>> subRoots = new ArrayList<Mutable<ILogicalOperator>>();

+			subRoots.add(new MutableObject<ILogicalOperator>(aggOperator));

+			ILogicalPlan subPlan = new ALogicalPlanImpl(subRoots);

+			List<ILogicalPlan> subPlans = new ArrayList<ILogicalPlan>();

+			subPlans.add(subPlan);

 

-            // create the group by operator

-            currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator(

-                    keyParameters, new ArrayList<Pair<LogicalVariable, Mutable<ILogicalExpression>>>(), subPlans);

-            currentOperator.getInputs().add(AlgebricksParentOperatorRef);

-            nestedTupleSource.getDataSourceReference().setValue(currentOperator);

+			// create the group by operator

+			currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator(

+					keyParameters,

+					new ArrayList<Pair<LogicalVariable, Mutable<ILogicalExpression>>>(),

+					subPlans);

+			currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+			nestedTupleSource.getDataSourceReference()

+					.setValue(currentOperator);

 

-            List<LogicalVariable> outputVariables = new ArrayList<LogicalVariable>();

-            outputVariables.addAll(keyVariables);

-            outputVariables.addAll(aggVariables);

-            t.rewriteOperatorOutputSchema(outputVariables, operator);

+			List<LogicalVariable> outputVariables = new ArrayList<LogicalVariable>();

+			outputVariables.addAll(keyVariables);

+			outputVariables.addAll(aggVariables);

+			t.rewriteOperatorOutputSchema(outputVariables, operator);

 

-            if (gbyKeyNotRedKey) {

-                currentOperator.getAnnotations().put(HiveOperatorAnnotations.LOCAL_GROUP_BY, Boolean.TRUE);

-            }

+			if (gbyKeyNotRedKey) {

+				currentOperator.getAnnotations().put(

+						HiveOperatorAnnotations.LOCAL_GROUP_BY, Boolean.TRUE);

+			}

 

-            HiveConf conf = ConfUtil.getHiveConf();

-            Boolean extGby = conf.getBoolean("hive.algebricks.groupby.external", false);

+			HiveConf conf = ConfUtil.getHiveConf();

+			Boolean extGby = conf.getBoolean(

+					"hive.algebricks.groupby.external", false);

 

-            if (extGby && isSerializable(aggregators)) {

-                currentOperator.getAnnotations().put(OperatorAnnotations.USE_EXTERNAL_GROUP_BY, Boolean.TRUE);

-            }

-            return new MutableObject<ILogicalOperator>(currentOperator);

-        } else {

-            isDistinct = false;

-            // rewrite parameter expressions for all aggregators

-            int i = 0;

-            for (AggregationDesc aggregator : aggregators) {

-                for (ExprNodeDesc parameter : aggregator.getParameters()) {

-                    t.rewriteExpression(parameter);

-                }

-                Mutable<ILogicalExpression> agg = t.translateAggregation(aggregator);

-                AggregateFunctionCallExpression originalAgg = (AggregateFunctionCallExpression) AlgebricksAggs.get(i)

-                        .getValue();

-                originalAgg.setStepOneAggregate(localAggs.get(i));

-                AggregateFunctionCallExpression currentAgg = (AggregateFunctionCallExpression) agg.getValue();

-                if (currentAgg.getFunctionInfo() != null) {

-                    originalAgg.setTwoStep(true);

-                    originalAgg.setStepTwoAggregate(currentAgg.getFunctionInfo());

-                }

-                i++;

-            }

-            return null;

-        }

-    }

+			if (extGby && isSerializable(aggregators)) {

+				currentOperator.getAnnotations()

+						.put(OperatorAnnotations.USE_EXTERNAL_GROUP_BY,

+								Boolean.TRUE);

+			}

+			return new MutableObject<ILogicalOperator>(currentOperator);

+		} else {

+			isDistinct = false;

+			// rewrite parameter expressions for all aggregators

+			int i = 0;

+			for (AggregationDesc aggregator : aggregators) {

+				for (ExprNodeDesc parameter : aggregator.getParameters()) {

+					t.rewriteExpression(parameter);

+				}

+				Mutable<ILogicalExpression> agg = t

+						.translateAggregation(aggregator);

+				AggregateFunctionCallExpression originalAgg = (AggregateFunctionCallExpression) AlgebricksAggs

+						.get(i).getValue();

+				originalAgg.setStepOneAggregate(localAggs.get(i));

+				AggregateFunctionCallExpression currentAgg = (AggregateFunctionCallExpression) agg

+						.getValue();

+				if (currentAgg.getFunctionInfo() != null) {

+					originalAgg.setTwoStep(true);

+					originalAgg.setStepTwoAggregate(currentAgg

+							.getFunctionInfo());

+				}

+				i++;

+			}

+			return null;

+		}

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

-        Operator downStream = (Operator) operator.getChildOperators().get(0);

-        if (!(downStream instanceof GroupByOperator)) {

-            return null;

-        }

+	@Override

+	public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		Operator downStream = (Operator) operator.getChildOperators().get(0);

+		if (!(downStream instanceof GroupByOperator)) {

+			return null;

+		}

 

-        ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

-        List<ExprNodeDesc> keys = desc.getKeyCols();

-        List<ExprNodeDesc> values = desc.getValueCols();

+		ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

+		List<ExprNodeDesc> keys = desc.getKeyCols();

+		List<ExprNodeDesc> values = desc.getValueCols();

 

-        // insert assign for keys

-        ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

-        t.getAssignOperator(AlgebricksParentOperatorRef, keys, keyVariables);

+		// insert assign for keys

+		ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

+		t.getAssignOperator(AlgebricksParentOperatorRef, keys, keyVariables);

 

-        // insert assign for values

-        ArrayList<LogicalVariable> valueVariables = new ArrayList<LogicalVariable>();

-        t.getAssignOperator(AlgebricksParentOperatorRef, values, valueVariables);

+		// insert assign for values

+		ArrayList<LogicalVariable> valueVariables = new ArrayList<LogicalVariable>();

+		t.getAssignOperator(AlgebricksParentOperatorRef, values, valueVariables);

 

-        ArrayList<LogicalVariable> columns = new ArrayList<LogicalVariable>();

-        columns.addAll(keyVariables);

-        columns.addAll(valueVariables);

+		ArrayList<LogicalVariable> columns = new ArrayList<LogicalVariable>();

+		columns.addAll(keyVariables);

+		columns.addAll(valueVariables);

 

-        t.rewriteOperatorOutputSchema(columns, operator);

-        return null;

-    }

+		t.rewriteOperatorOutputSchema(columns, operator);

+		return null;

+	}

 

-    private boolean isSerializable(List<AggregationDesc> descs) throws AlgebricksException {

-        try {

-            for (AggregationDesc desc : descs) {

-                GenericUDAFEvaluator udaf = desc.getGenericUDAFEvaluator();

-                AggregationBuffer buf = udaf.getNewAggregationBuffer();

-                Class<?> bufferClass = buf.getClass();

-                Field[] fields = bufferClass.getDeclaredFields();

-                for (Field field : fields) {

-                    field.setAccessible(true);

-                    String type = field.getType().toString();

-                    if (!(type.equals("int") || type.equals("long") || type.equals("float") || type.equals("double") || type

-                            .equals("boolean"))) {

-                        return false;

-                    }

-                }

+	private boolean isSerializable(List<AggregationDesc> descs)

+			throws AlgebricksException {

+		try {

+			for (AggregationDesc desc : descs) {

+				GenericUDAFEvaluator udaf = desc.getGenericUDAFEvaluator();

+				AggregationBuffer buf = udaf.getNewAggregationBuffer();

+				Class<?> bufferClass = buf.getClass();

+				Field[] fields = bufferClass.getDeclaredFields();

+				for (Field field : fields) {

+					field.setAccessible(true);

+					String type = field.getType().toString();

+					if (!(type.equals("int") || type.equals("long")

+							|| type.equals("float") || type.equals("double") || type

+								.equals("boolean"))) {

+						return false;

+					}

+				}

 

-            }

-            return true;

-        } catch (Exception e) {

-            throw new AlgebricksException(e);

-        }

-    }

+			}

+			return true;

+		} catch (Exception e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/JoinVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/JoinVisitor.java
index 41a492d..ddff42a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/JoinVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/JoinVisitor.java
@@ -35,380 +35,410 @@
 

 public class JoinVisitor extends DefaultVisitor {

 

-    /**

-     * reduce sink operator to variables

-     */

-    private HashMap<Operator, List<LogicalVariable>> reduceSinkToKeyVariables = new HashMap<Operator, List<LogicalVariable>>();

+	/**

+	 * reduce sink operator to variables

+	 */

+	private HashMap<Operator, List<LogicalVariable>> reduceSinkToKeyVariables = new HashMap<Operator, List<LogicalVariable>>();

 

-    /**

-     * reduce sink operator to variables

-     */

-    private HashMap<Operator, List<String>> reduceSinkToFieldNames = new HashMap<Operator, List<String>>();

+	/**

+	 * reduce sink operator to variables

+	 */

+	private HashMap<Operator, List<String>> reduceSinkToFieldNames = new HashMap<Operator, List<String>>();

 

-    /**

-     * reduce sink operator to variables

-     */

-    private HashMap<Operator, List<TypeInfo>> reduceSinkToTypes = new HashMap<Operator, List<TypeInfo>>();

+	/**

+	 * reduce sink operator to variables

+	 */

+	private HashMap<Operator, List<TypeInfo>> reduceSinkToTypes = new HashMap<Operator, List<TypeInfo>>();

 

-    /**

-     * map a join operator (in hive) to its parent operators (in hive)

-     */

-    private HashMap<Operator, List<Operator>> operatorToHiveParents = new HashMap<Operator, List<Operator>>();

+	/**

+	 * map a join operator (in hive) to its parent operators (in hive)

+	 */

+	private HashMap<Operator, List<Operator>> operatorToHiveParents = new HashMap<Operator, List<Operator>>();

 

-    /**

-     * map a join operator (in hive) to its parent operators (in asterix)

-     */

-    private HashMap<Operator, List<ILogicalOperator>> operatorToAsterixParents = new HashMap<Operator, List<ILogicalOperator>>();

+	/**

+	 * map a join operator (in hive) to its parent operators (in asterix)

+	 */

+	private HashMap<Operator, List<ILogicalOperator>> operatorToAsterixParents = new HashMap<Operator, List<ILogicalOperator>>();

 

-    /**

-     * the latest traversed reduce sink operator

-     */

-    private Operator latestReduceSink = null;

+	/**

+	 * the latest traversed reduce sink operator

+	 */

+	private Operator latestReduceSink = null;

 

-    /**

-     * the latest generated parent for join

-     */

-    private ILogicalOperator latestAlgebricksOperator = null;

+	/**

+	 * the latest generated parent for join

+	 */

+	private ILogicalOperator latestAlgebricksOperator = null;

 

-    /**

-     * process a join operator

-     */

-    @Override

-    public Mutable<ILogicalOperator> visit(JoinOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) {

-        latestAlgebricksOperator = AlgebricksParentOperator.getValue();

-        translateJoinOperatorPreprocess(operator, t);

-        List<Operator> parents = operatorToHiveParents.get(operator);

-        if (parents.size() < operator.getParentOperators().size()) {

-            return null;

-        } else {

-            ILogicalOperator joinOp = translateJoinOperator(operator, AlgebricksParentOperator, t);

-            // clearStatus();

-            return new MutableObject<ILogicalOperator>(joinOp);

-        }

-    }

+	/**

+	 * process a join operator

+	 */

+	@Override

+	public Mutable<ILogicalOperator> visit(JoinOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t) {

+		latestAlgebricksOperator = AlgebricksParentOperator.getValue();

+		translateJoinOperatorPreprocess(operator, t);

+		List<Operator> parents = operatorToHiveParents.get(operator);

+		if (parents.size() < operator.getParentOperators().size()) {

+			return null;

+		} else {

+			ILogicalOperator joinOp = translateJoinOperator(operator,

+					AlgebricksParentOperator, t);

+			// clearStatus();

+			return new MutableObject<ILogicalOperator>(joinOp);

+		}

+	}

 

-    private void reorder(Byte[] order, List<ILogicalOperator> parents, List<Operator> hiveParents) {

-        ILogicalOperator[] lops = new ILogicalOperator[parents.size()];

-        Operator[] ops = new Operator[hiveParents.size()];

+	private void reorder(Byte[] order, List<ILogicalOperator> parents,

+			List<Operator> hiveParents) {

+		ILogicalOperator[] lops = new ILogicalOperator[parents.size()];

+		Operator[] ops = new Operator[hiveParents.size()];

 

-        for (Operator op : hiveParents) {

-            ReduceSinkOperator rop = (ReduceSinkOperator) op;

-            ReduceSinkDesc rdesc = rop.getConf();

-            int tag = rdesc.getTag();

+		for (Operator op : hiveParents) {

+			ReduceSinkOperator rop = (ReduceSinkOperator) op;

+			ReduceSinkDesc rdesc = rop.getConf();

+			int tag = rdesc.getTag();

 

-            int index = -1;

-            for (int i = 0; i < order.length; i++)

-                if (order[i] == tag) {

-                    index = i;

-                    break;

-                }

-            lops[index] = parents.get(hiveParents.indexOf(op));

-            ops[index] = op;

-        }

+			int index = -1;

+			for (int i = 0; i < order.length; i++)

+				if (order[i] == tag) {

+					index = i;

+					break;

+				}

+			lops[index] = parents.get(hiveParents.indexOf(op));

+			ops[index] = op;

+		}

 

-        parents.clear();

-        hiveParents.clear();

+		parents.clear();

+		hiveParents.clear();

 

-        for (int i = 0; i < lops.length; i++) {

-            parents.add(lops[i]);

-            hiveParents.add(ops[i]);

-        }

-    }

+		for (int i = 0; i < lops.length; i++) {

+			parents.add(lops[i]);

+			hiveParents.add(ops[i]);

+		}

+	}

 

-    /**

-     * translate a hive join operator to asterix join operator->assign

-     * operator->project operator

-     * 

-     * @param parentOperator

-     * @param operator

-     * @return

-     */

-    private ILogicalOperator translateJoinOperator(Operator operator, Mutable<ILogicalOperator> parentOperator,

-            Translator t) {

+	/**

+	 * translate a hive join operator to asterix join operator->assign

+	 * operator->project operator

+	 * 

+	 * @param parentOperator

+	 * @param operator

+	 * @return

+	 */

+	private ILogicalOperator translateJoinOperator(Operator operator,

+			Mutable<ILogicalOperator> parentOperator, Translator t) {

 

-        JoinDesc joinDesc = (JoinDesc) operator.getConf();

+		JoinDesc joinDesc = (JoinDesc) operator.getConf();

 

-        // get the projection expression (already re-written) from each source

-        // table

-        Map<Byte, List<ExprNodeDesc>> exprMap = joinDesc.getExprs();

-        reorder(joinDesc.getTagOrder(), operatorToAsterixParents.get(operator), operatorToHiveParents.get(operator));

+		// get the projection expression (already re-written) from each source

+		// table

+		Map<Byte, List<ExprNodeDesc>> exprMap = joinDesc.getExprs();

+		reorder(joinDesc.getTagOrder(), operatorToAsterixParents.get(operator),

+				operatorToHiveParents.get(operator));

 

-        // make an reduce join operator

-        ILogicalOperator currentOperator = generateJoinTree(joinDesc.getCondsList(),

-                operatorToAsterixParents.get(operator), operatorToHiveParents.get(operator), 0, t);

-        parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

+		// make an reduce join operator

+		ILogicalOperator currentOperator = generateJoinTree(

+				joinDesc.getCondsList(),

+				operatorToAsterixParents.get(operator),

+				operatorToHiveParents.get(operator), 0, t);

+		parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

 

-        // add assign and project operator on top of a join

-        // output variables

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        Set<Entry<Byte, List<ExprNodeDesc>>> entries = exprMap.entrySet();

-        Iterator<Entry<Byte, List<ExprNodeDesc>>> iterator = entries.iterator();

-        while (iterator.hasNext()) {

-            List<ExprNodeDesc> outputExprs = iterator.next().getValue();

-            ILogicalOperator assignOperator = t.getAssignOperator(parentOperator, outputExprs, variables);

+		// add assign and project operator on top of a join

+		// output variables

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		Set<Entry<Byte, List<ExprNodeDesc>>> entries = exprMap.entrySet();

+		Iterator<Entry<Byte, List<ExprNodeDesc>>> iterator = entries.iterator();

+		while (iterator.hasNext()) {

+			List<ExprNodeDesc> outputExprs = iterator.next().getValue();

+			ILogicalOperator assignOperator = t.getAssignOperator(

+					parentOperator, outputExprs, variables);

 

-            if (assignOperator != null) {

-                currentOperator = assignOperator;

-                parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

-            }

-        }

+			if (assignOperator != null) {

+				currentOperator = assignOperator;

+				parentOperator = new MutableObject<ILogicalOperator>(

+						currentOperator);

+			}

+		}

 

-        ILogicalOperator po = new ProjectOperator(variables);

-        po.getInputs().add(parentOperator);

-        t.rewriteOperatorOutputSchema(variables, operator);

-        return po;

-    }

+		ILogicalOperator po = new ProjectOperator(variables);

+		po.getInputs().add(parentOperator);

+		t.rewriteOperatorOutputSchema(variables, operator);

+		return po;

+	}

 

-    /**

-     * deal with reduce sink operator for the case of join

-     */

-    @Override

-    public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator, Mutable<ILogicalOperator> parentOperator,

-            Translator t) {

+	/**

+	 * deal with reduce sink operator for the case of join

+	 */

+	@Override

+	public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator,

+			Mutable<ILogicalOperator> parentOperator, Translator t) {

 

-        Operator downStream = (Operator) operator.getChildOperators().get(0);

-        if (!(downStream instanceof JoinOperator))

-            return null;

+		Operator downStream = (Operator) operator.getChildOperators().get(0);

+		if (!(downStream instanceof JoinOperator))

+			return null;

 

-        ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

-        List<ExprNodeDesc> keys = desc.getKeyCols();

-        List<ExprNodeDesc> values = desc.getValueCols();

-        List<ExprNodeDesc> partitionCols = desc.getPartitionCols();

+		ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

+		List<ExprNodeDesc> keys = desc.getKeyCols();

+		List<ExprNodeDesc> values = desc.getValueCols();

+		List<ExprNodeDesc> partitionCols = desc.getPartitionCols();

 

-        /**

-         * rewrite key, value, paritioncol expressions

-         */

-        for (ExprNodeDesc key : keys)

-            t.rewriteExpression(key);

-        for (ExprNodeDesc value : values)

-            t.rewriteExpression(value);

-        for (ExprNodeDesc col : partitionCols)

-            t.rewriteExpression(col);

+		/**

+		 * rewrite key, value, paritioncol expressions

+		 */

+		for (ExprNodeDesc key : keys)

+			t.rewriteExpression(key);

+		for (ExprNodeDesc value : values)

+			t.rewriteExpression(value);

+		for (ExprNodeDesc col : partitionCols)

+			t.rewriteExpression(col);

 

-        ILogicalOperator currentOperator = null;

+		ILogicalOperator currentOperator = null;

 

-        // add assign operator for keys if necessary

-        ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

-        ILogicalOperator assignOperator = t.getAssignOperator(parentOperator, keys, keyVariables);

-        if (assignOperator != null) {

-            currentOperator = assignOperator;

-            parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

-        }

+		// add assign operator for keys if necessary

+		ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

+		ILogicalOperator assignOperator = t.getAssignOperator(parentOperator,

+				keys, keyVariables);

+		if (assignOperator != null) {

+			currentOperator = assignOperator;

+			parentOperator = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

 

-        // add assign operator for values if necessary

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        assignOperator = t.getAssignOperator(parentOperator, values, variables);

-        if (assignOperator != null) {

-            currentOperator = assignOperator;

-            parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

-        }

+		// add assign operator for values if necessary

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		assignOperator = t.getAssignOperator(parentOperator, values, variables);

+		if (assignOperator != null) {

+			currentOperator = assignOperator;

+			parentOperator = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

 

-        // unified schema: key, value

-        ArrayList<LogicalVariable> unifiedKeyValues = new ArrayList<LogicalVariable>();

-        unifiedKeyValues.addAll(keyVariables);

-        for (LogicalVariable value : variables)

-            if (keyVariables.indexOf(value) < 0)

-                unifiedKeyValues.add(value);

+		// unified schema: key, value

+		ArrayList<LogicalVariable> unifiedKeyValues = new ArrayList<LogicalVariable>();

+		unifiedKeyValues.addAll(keyVariables);

+		for (LogicalVariable value : variables)

+			if (keyVariables.indexOf(value) < 0)

+				unifiedKeyValues.add(value);

 

-        // insert projection operator, it is a *must*,

-        // in hive, reduce sink sometimes also do the projection operator's

-        // task

-        currentOperator = new ProjectOperator(unifiedKeyValues);

-        currentOperator.getInputs().add(parentOperator);

-        parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

+		// insert projection operator, it is a *must*,

+		// in hive, reduce sink sometimes also do the projection operator's

+		// task

+		currentOperator = new ProjectOperator(unifiedKeyValues);

+		currentOperator.getInputs().add(parentOperator);

+		parentOperator = new MutableObject<ILogicalOperator>(currentOperator);

 

-        reduceSinkToKeyVariables.put(operator, keyVariables);

-        List<String> fieldNames = new ArrayList<String>();

-        List<TypeInfo> types = new ArrayList<TypeInfo>();

-        for (LogicalVariable var : unifiedKeyValues) {

-            fieldNames.add(var.toString());

-            types.add(t.getType(var));

-        }

-        reduceSinkToFieldNames.put(operator, fieldNames);

-        reduceSinkToTypes.put(operator, types);

-        t.rewriteOperatorOutputSchema(variables, operator);

+		reduceSinkToKeyVariables.put(operator, keyVariables);

+		List<String> fieldNames = new ArrayList<String>();

+		List<TypeInfo> types = new ArrayList<TypeInfo>();

+		for (LogicalVariable var : unifiedKeyValues) {

+			fieldNames.add(var.toString());

+			types.add(t.getType(var));

+		}

+		reduceSinkToFieldNames.put(operator, fieldNames);

+		reduceSinkToTypes.put(operator, types);

+		t.rewriteOperatorOutputSchema(variables, operator);

 

-        latestAlgebricksOperator = currentOperator;

-        latestReduceSink = operator;

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		latestAlgebricksOperator = currentOperator;

+		latestReduceSink = operator;

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

-    /**

-     * partial rewrite a join operator

-     * 

-     * @param operator

-     * @param t

-     */

-    private void translateJoinOperatorPreprocess(Operator operator, Translator t) {

-        JoinDesc desc = (JoinDesc) operator.getConf();

-        ReduceSinkDesc reduceSinkDesc = (ReduceSinkDesc) latestReduceSink.getConf();

-        int tag = reduceSinkDesc.getTag();

+	/**

+	 * partial rewrite a join operator

+	 * 

+	 * @param operator

+	 * @param t

+	 */

+	private void translateJoinOperatorPreprocess(Operator operator, Translator t) {

+		JoinDesc desc = (JoinDesc) operator.getConf();

+		ReduceSinkDesc reduceSinkDesc = (ReduceSinkDesc) latestReduceSink

+				.getConf();

+		int tag = reduceSinkDesc.getTag();

 

-        Map<Byte, List<ExprNodeDesc>> exprMap = desc.getExprs();

-        List<ExprNodeDesc> exprs = exprMap.get(Byte.valueOf((byte) tag));

+		Map<Byte, List<ExprNodeDesc>> exprMap = desc.getExprs();

+		List<ExprNodeDesc> exprs = exprMap.get(Byte.valueOf((byte) tag));

 

-        for (ExprNodeDesc expr : exprs)

-            t.rewriteExpression(expr);

+		for (ExprNodeDesc expr : exprs)

+			t.rewriteExpression(expr);

 

-        List<Operator> parents = operatorToHiveParents.get(operator);

-        if (parents == null) {

-            parents = new ArrayList<Operator>();

-            operatorToHiveParents.put(operator, parents);

-        }

-        parents.add(latestReduceSink);

+		List<Operator> parents = operatorToHiveParents.get(operator);

+		if (parents == null) {

+			parents = new ArrayList<Operator>();

+			operatorToHiveParents.put(operator, parents);

+		}

+		parents.add(latestReduceSink);

 

-        List<ILogicalOperator> asterixParents = operatorToAsterixParents.get(operator);

-        if (asterixParents == null) {

-            asterixParents = new ArrayList<ILogicalOperator>();

-            operatorToAsterixParents.put(operator, asterixParents);

-        }

-        asterixParents.add(latestAlgebricksOperator);

-    }

+		List<ILogicalOperator> asterixParents = operatorToAsterixParents

+				.get(operator);

+		if (asterixParents == null) {

+			asterixParents = new ArrayList<ILogicalOperator>();

+			operatorToAsterixParents.put(operator, asterixParents);

+		}

+		asterixParents.add(latestAlgebricksOperator);

+	}

 

-    // generate a join tree from a list of exchange/reducesink operator

-    // both exchanges and reduce sinks have the same order

-    private ILogicalOperator generateJoinTree(List<JoinCondDesc> conds, List<ILogicalOperator> exchanges,

-            List<Operator> reduceSinks, int offset, Translator t) {

-        // get a list of reduce sink descs (input descs)

-        int inputSize = reduceSinks.size() - offset;

+	// generate a join tree from a list of exchange/reducesink operator

+	// both exchanges and reduce sinks have the same order

+	private ILogicalOperator generateJoinTree(List<JoinCondDesc> conds,

+			List<ILogicalOperator> exchanges, List<Operator> reduceSinks,

+			int offset, Translator t) {

+		// get a list of reduce sink descs (input descs)

+		int inputSize = reduceSinks.size() - offset;

 

-        if (inputSize == 2) {

-            ILogicalOperator currentRoot;

+		if (inputSize == 2) {

+			ILogicalOperator currentRoot;

 

-            List<ReduceSinkDesc> reduceSinkDescs = new ArrayList<ReduceSinkDesc>();

-            for (int i = reduceSinks.size() - 1; i >= offset; i--)

-                reduceSinkDescs.add((ReduceSinkDesc) reduceSinks.get(i).getConf());

+			List<ReduceSinkDesc> reduceSinkDescs = new ArrayList<ReduceSinkDesc>();

+			for (int i = reduceSinks.size() - 1; i >= offset; i--)

+				reduceSinkDescs.add((ReduceSinkDesc) reduceSinks.get(i)

+						.getConf());

 

-            // get the object inspector for the join

-            List<String> fieldNames = new ArrayList<String>();

-            List<TypeInfo> types = new ArrayList<TypeInfo>();

-            for (int i = reduceSinks.size() - 1; i >= offset; i--) {

-                fieldNames.addAll(reduceSinkToFieldNames.get(reduceSinks.get(i)));

-                types.addAll(reduceSinkToTypes.get(reduceSinks.get(i)));

-            }

+			// get the object inspector for the join

+			List<String> fieldNames = new ArrayList<String>();

+			List<TypeInfo> types = new ArrayList<TypeInfo>();

+			for (int i = reduceSinks.size() - 1; i >= offset; i--) {

+				fieldNames

+						.addAll(reduceSinkToFieldNames.get(reduceSinks.get(i)));

+				types.addAll(reduceSinkToTypes.get(reduceSinks.get(i)));

+			}

 

-            // get number of equality conjunctions in the final join condition

-            int size = reduceSinkDescs.get(0).getKeyCols().size();

+			// get number of equality conjunctions in the final join condition

+			int size = reduceSinkDescs.get(0).getKeyCols().size();

 

-            // make up the join conditon expression

-            List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

-            for (int i = 0; i < size; i++) {

-                // create a join key pair

-                List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

-                for (ReduceSinkDesc sink : reduceSinkDescs) {

-                    keyPair.add(sink.getKeyCols().get(i));

-                }

-                // create a hive equal condition

-                ExprNodeDesc equality = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo,

-                        new GenericUDFOPEqual(), keyPair);

-                // add the equal condition to the conjunction list

-                joinConditionChildren.add(equality);

-            }

-            // get final conjunction expression

-            ExprNodeDesc conjunct = null;

+			// make up the join conditon expression

+			List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

+			for (int i = 0; i < size; i++) {

+				// create a join key pair

+				List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

+				for (ReduceSinkDesc sink : reduceSinkDescs) {

+					keyPair.add(sink.getKeyCols().get(i));

+				}

+				// create a hive equal condition

+				ExprNodeDesc equality = new ExprNodeGenericFuncDesc(

+						TypeInfoFactory.booleanTypeInfo,

+						new GenericUDFOPEqual(), keyPair);

+				// add the equal condition to the conjunction list

+				joinConditionChildren.add(equality);

+			}

+			// get final conjunction expression

+			ExprNodeDesc conjunct = null;

 

-            if (joinConditionChildren.size() > 1)

-                conjunct = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

-                        joinConditionChildren);

-            else if (joinConditionChildren.size() == 1)

-                conjunct = joinConditionChildren.get(0);

-            else {

-                // there is no join equality condition, equal-join

-                conjunct = new ExprNodeConstantDesc(TypeInfoFactory.booleanTypeInfo, new Boolean(true));

-            }

-            // get an ILogicalExpression from hive's expression

-            Mutable<ILogicalExpression> expression = t.translateScalarFucntion(conjunct);

+			if (joinConditionChildren.size() > 1)

+				conjunct = new ExprNodeGenericFuncDesc(

+						TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

+						joinConditionChildren);

+			else if (joinConditionChildren.size() == 1)

+				conjunct = joinConditionChildren.get(0);

+			else {

+				// there is no join equality condition, equal-join

+				conjunct = new ExprNodeConstantDesc(

+						TypeInfoFactory.booleanTypeInfo, new Boolean(true));

+			}

+			// get an ILogicalExpression from hive's expression

+			Mutable<ILogicalExpression> expression = t

+					.translateScalarFucntion(conjunct);

 

-            Mutable<ILogicalOperator> leftBranch = new MutableObject<ILogicalOperator>(exchanges.get(exchanges.size() - 1));

-            Mutable<ILogicalOperator> rightBranch = new MutableObject<ILogicalOperator>(exchanges.get(exchanges.size() - 2));

-            // get the join operator

-            if (conds.get(offset).getType() == JoinDesc.LEFT_OUTER_JOIN) {

-                currentRoot = new LeftOuterJoinOperator(expression);

-                Mutable<ILogicalOperator> temp = leftBranch;

-                leftBranch = rightBranch;

-                rightBranch = temp;

-            } else if (conds.get(offset).getType() == JoinDesc.RIGHT_OUTER_JOIN) {

-                currentRoot = new LeftOuterJoinOperator(expression);

-            } else

-                currentRoot = new InnerJoinOperator(expression);

+			Mutable<ILogicalOperator> leftBranch = new MutableObject<ILogicalOperator>(

+					exchanges.get(exchanges.size() - 1));

+			Mutable<ILogicalOperator> rightBranch = new MutableObject<ILogicalOperator>(

+					exchanges.get(exchanges.size() - 2));

+			// get the join operator

+			if (conds.get(offset).getType() == JoinDesc.LEFT_OUTER_JOIN) {

+				currentRoot = new LeftOuterJoinOperator(expression);

+				Mutable<ILogicalOperator> temp = leftBranch;

+				leftBranch = rightBranch;

+				rightBranch = temp;

+			} else if (conds.get(offset).getType() == JoinDesc.RIGHT_OUTER_JOIN) {

+				currentRoot = new LeftOuterJoinOperator(expression);

+			} else

+				currentRoot = new InnerJoinOperator(expression);

 

-            currentRoot.getInputs().add(leftBranch);

-            currentRoot.getInputs().add(rightBranch);

+			currentRoot.getInputs().add(leftBranch);

+			currentRoot.getInputs().add(rightBranch);

 

-            // rewriteOperatorOutputSchema(variables, operator);

-            return currentRoot;

-        } else {

-            // get the child join operator and insert and one-to-one exchange

-            ILogicalOperator joinSrcOne = generateJoinTree(conds, exchanges, reduceSinks, offset + 1, t);

-            // joinSrcOne.addInput(childJoin);

+			// rewriteOperatorOutputSchema(variables, operator);

+			return currentRoot;

+		} else {

+			// get the child join operator and insert and one-to-one exchange

+			ILogicalOperator joinSrcOne = generateJoinTree(conds, exchanges,

+					reduceSinks, offset + 1, t);

+			// joinSrcOne.addInput(childJoin);

 

-            ILogicalOperator currentRoot;

+			ILogicalOperator currentRoot;

 

-            List<ReduceSinkDesc> reduceSinkDescs = new ArrayList<ReduceSinkDesc>();

-            for (int i = offset; i < offset + 2; i++)

-                reduceSinkDescs.add((ReduceSinkDesc) reduceSinks.get(i).getConf());

+			List<ReduceSinkDesc> reduceSinkDescs = new ArrayList<ReduceSinkDesc>();

+			for (int i = offset; i < offset + 2; i++)

+				reduceSinkDescs.add((ReduceSinkDesc) reduceSinks.get(i)

+						.getConf());

 

-            // get the object inspector for the join

-            List<String> fieldNames = new ArrayList<String>();

-            List<TypeInfo> types = new ArrayList<TypeInfo>();

-            for (int i = offset; i < reduceSinks.size(); i++) {

-                fieldNames.addAll(reduceSinkToFieldNames.get(reduceSinks.get(i)));

-                types.addAll(reduceSinkToTypes.get(reduceSinks.get(i)));

-            }

+			// get the object inspector for the join

+			List<String> fieldNames = new ArrayList<String>();

+			List<TypeInfo> types = new ArrayList<TypeInfo>();

+			for (int i = offset; i < reduceSinks.size(); i++) {

+				fieldNames

+						.addAll(reduceSinkToFieldNames.get(reduceSinks.get(i)));

+				types.addAll(reduceSinkToTypes.get(reduceSinks.get(i)));

+			}

 

-            // get number of equality conjunctions in the final join condition

-            int size = reduceSinkDescs.get(0).getKeyCols().size();

+			// get number of equality conjunctions in the final join condition

+			int size = reduceSinkDescs.get(0).getKeyCols().size();

 

-            // make up the join condition expression

-            List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

-            for (int i = 0; i < size; i++) {

-                // create a join key pair

-                List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

-                for (ReduceSinkDesc sink : reduceSinkDescs) {

-                    keyPair.add(sink.getKeyCols().get(i));

-                }

-                // create a hive equal condition

-                ExprNodeDesc equality = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo,

-                        new GenericUDFOPEqual(), keyPair);

-                // add the equal condition to the conjunction list

-                joinConditionChildren.add(equality);

-            }

-            // get final conjunction expression

-            ExprNodeDesc conjunct = null;

+			// make up the join condition expression

+			List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

+			for (int i = 0; i < size; i++) {

+				// create a join key pair

+				List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

+				for (ReduceSinkDesc sink : reduceSinkDescs) {

+					keyPair.add(sink.getKeyCols().get(i));

+				}

+				// create a hive equal condition

+				ExprNodeDesc equality = new ExprNodeGenericFuncDesc(

+						TypeInfoFactory.booleanTypeInfo,

+						new GenericUDFOPEqual(), keyPair);

+				// add the equal condition to the conjunction list

+				joinConditionChildren.add(equality);

+			}

+			// get final conjunction expression

+			ExprNodeDesc conjunct = null;

 

-            if (joinConditionChildren.size() > 1)

-                conjunct = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

-                        joinConditionChildren);

-            else if (joinConditionChildren.size() == 1)

-                conjunct = joinConditionChildren.get(0);

-            else {

-                // there is no join equality condition, full outer join

-                conjunct = new ExprNodeConstantDesc(TypeInfoFactory.booleanTypeInfo, new Boolean(true));

-            }

-            // get an ILogicalExpression from hive's expression

-            Mutable<ILogicalExpression> expression = t.translateScalarFucntion(conjunct);

+			if (joinConditionChildren.size() > 1)

+				conjunct = new ExprNodeGenericFuncDesc(

+						TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

+						joinConditionChildren);

+			else if (joinConditionChildren.size() == 1)

+				conjunct = joinConditionChildren.get(0);

+			else {

+				// there is no join equality condition, full outer join

+				conjunct = new ExprNodeConstantDesc(

+						TypeInfoFactory.booleanTypeInfo, new Boolean(true));

+			}

+			// get an ILogicalExpression from hive's expression

+			Mutable<ILogicalExpression> expression = t

+					.translateScalarFucntion(conjunct);

 

-            Mutable<ILogicalOperator> leftBranch = new MutableObject<ILogicalOperator>(joinSrcOne);

-            Mutable<ILogicalOperator> rightBranch = new MutableObject<ILogicalOperator>(exchanges.get(offset));

+			Mutable<ILogicalOperator> leftBranch = new MutableObject<ILogicalOperator>(

+					joinSrcOne);

+			Mutable<ILogicalOperator> rightBranch = new MutableObject<ILogicalOperator>(

+					exchanges.get(offset));

 

-            // get the join operator

-            if (conds.get(offset).getType() == JoinDesc.LEFT_OUTER_JOIN) {

-                currentRoot = new LeftOuterJoinOperator(expression);

-                Mutable<ILogicalOperator> temp = leftBranch;

-                leftBranch = rightBranch;

-                rightBranch = temp;

-            } else if (conds.get(offset).getType() == JoinDesc.RIGHT_OUTER_JOIN) {

-                currentRoot = new LeftOuterJoinOperator(expression);

-            } else

-                currentRoot = new InnerJoinOperator(expression);

+			// get the join operator

+			if (conds.get(offset).getType() == JoinDesc.LEFT_OUTER_JOIN) {

+				currentRoot = new LeftOuterJoinOperator(expression);

+				Mutable<ILogicalOperator> temp = leftBranch;

+				leftBranch = rightBranch;

+				rightBranch = temp;

+			} else if (conds.get(offset).getType() == JoinDesc.RIGHT_OUTER_JOIN) {

+				currentRoot = new LeftOuterJoinOperator(expression);

+			} else

+				currentRoot = new InnerJoinOperator(expression);

 

-            // set the inputs from Algebricks join operator

-            // add the current table

-            currentRoot.getInputs().add(leftBranch);

-            currentRoot.getInputs().add(rightBranch);

+			// set the inputs from Algebricks join operator

+			// add the current table

+			currentRoot.getInputs().add(leftBranch);

+			currentRoot.getInputs().add(rightBranch);

 

-            return currentRoot;

-        }

-    }

+			return currentRoot;

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LateralViewJoinVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LateralViewJoinVisitor.java
index 56b0ef4..b829e67 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LateralViewJoinVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LateralViewJoinVisitor.java
@@ -55,67 +55,76 @@
 

 public class LateralViewJoinVisitor extends DefaultVisitor {

 

-    private UDTFDesc udtf;

+	private UDTFDesc udtf;

 

-    private List<Mutable<ILogicalOperator>> parents = new ArrayList<Mutable<ILogicalOperator>>();

+	private List<Mutable<ILogicalOperator>> parents = new ArrayList<Mutable<ILogicalOperator>>();

 

-    @Override

-    public Mutable<ILogicalOperator> visit(LateralViewJoinOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException {

+	@Override

+	public Mutable<ILogicalOperator> visit(LateralViewJoinOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException {

 

-        parents.add(AlgebricksParentOperatorRef);

-        if (operator.getParentOperators().size() > parents.size()) {

-            return null;

-        }

+		parents.add(AlgebricksParentOperatorRef);

+		if (operator.getParentOperators().size() > parents.size()) {

+			return null;

+		}

 

-        Operator parent0 = operator.getParentOperators().get(0);

-        Operator parent1 = operator.getParentOperators().get(1);

-        List<LogicalVariable> variables;

+		Operator parent0 = operator.getParentOperators().get(0);

+		Operator parent1 = operator.getParentOperators().get(1);

+		List<LogicalVariable> variables;

 

-        ILogicalOperator parentOperator;

-        ILogicalExpression unnestArg;

-        if (parent0 instanceof UDTFOperator) {

-            variables = t.getVariablesFromSchema(t.generateInputSchema(parent1));

-            List<LogicalVariable> unnestVars = new ArrayList<LogicalVariable>();

-            VariableUtilities.getLiveVariables(parents.get(1).getValue(), unnestVars);

-            unnestArg = new VariableReferenceExpression(unnestVars.get(0));

-            parentOperator = parents.get(1).getValue();

-        } else {

-            variables = t.getVariablesFromSchema(t.generateInputSchema(parent0));

-            List<LogicalVariable> unnestVars = new ArrayList<LogicalVariable>();

-            VariableUtilities.getLiveVariables(parents.get(0).getValue(), unnestVars);

-            unnestArg = new VariableReferenceExpression(unnestVars.get(0));

-            parentOperator = parents.get(0).getValue();

-        }

+		ILogicalOperator parentOperator;

+		ILogicalExpression unnestArg;

+		if (parent0 instanceof UDTFOperator) {

+			variables = t

+					.getVariablesFromSchema(t.generateInputSchema(parent1));

+			List<LogicalVariable> unnestVars = new ArrayList<LogicalVariable>();

+			VariableUtilities.getLiveVariables(parents.get(1).getValue(),

+					unnestVars);

+			unnestArg = new VariableReferenceExpression(unnestVars.get(0));

+			parentOperator = parents.get(1).getValue();

+		} else {

+			variables = t

+					.getVariablesFromSchema(t.generateInputSchema(parent0));

+			List<LogicalVariable> unnestVars = new ArrayList<LogicalVariable>();

+			VariableUtilities.getLiveVariables(parents.get(0).getValue(),

+					unnestVars);

+			unnestArg = new VariableReferenceExpression(unnestVars.get(0));

+			parentOperator = parents.get(0).getValue();

+		}

 

-        LogicalVariable var = t.getVariable(udtf.toString(), TypeInfoFactory.unknownTypeInfo);

+		LogicalVariable var = t.getVariable(udtf.toString(),

+				TypeInfoFactory.unknownTypeInfo);

 

-        Mutable<ILogicalExpression> unnestExpr = t.translateUnnestFunction(udtf, new MutableObject<ILogicalExpression>(

-                unnestArg));

-        ILogicalOperator currentOperator = new UnnestOperator(var, unnestExpr);

+		Mutable<ILogicalExpression> unnestExpr = t.translateUnnestFunction(

+				udtf, new MutableObject<ILogicalExpression>(unnestArg));

+		ILogicalOperator currentOperator = new UnnestOperator(var, unnestExpr);

 

-        List<LogicalVariable> outputVars = new ArrayList<LogicalVariable>();

-        VariableUtilities.getLiveVariables(parentOperator, outputVars);

-        outputVars.add(var);

-        currentOperator.getInputs().add(new MutableObject<ILogicalOperator>(parentOperator));

+		List<LogicalVariable> outputVars = new ArrayList<LogicalVariable>();

+		VariableUtilities.getLiveVariables(parentOperator, outputVars);

+		outputVars.add(var);

+		currentOperator.getInputs().add(

+				new MutableObject<ILogicalOperator>(parentOperator));

 

-        parents.clear();

-        udtf = null;

-        t.rewriteOperatorOutputSchema(outputVars, operator);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		parents.clear();

+		udtf = null;

+		t.rewriteOperatorOutputSchema(outputVars, operator);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(UDTFOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

-        Schema currentSchema = t.generateInputSchema(operator.getParentOperators().get(0));

-        udtf = (UDTFDesc) operator.getConf();

+	@Override

+	public Mutable<ILogicalOperator> visit(UDTFOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		Schema currentSchema = t.generateInputSchema(operator

+				.getParentOperators().get(0));

+		udtf = (UDTFDesc) operator.getConf();

 

-        // populate the schema from upstream operator

-        operator.setSchema(operator.getParentOperators().get(0).getSchema());

-        List<LogicalVariable> latestOutputSchema = t.getVariablesFromSchema(currentSchema);

-        t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

-        return null;

-    }

+		// populate the schema from upstream operator

+		operator.setSchema(operator.getParentOperators().get(0).getSchema());

+		List<LogicalVariable> latestOutputSchema = t

+				.getVariablesFromSchema(currentSchema);

+		t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LimitVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LimitVisitor.java
index d7d6d67..84cdf00 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LimitVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/LimitVisitor.java
@@ -18,24 +18,27 @@
 

 public class LimitVisitor extends DefaultVisitor {

 

-    @Override

-    public Mutable<ILogicalOperator> visit(LimitOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) {

-        Schema currentSchema = t.generateInputSchema(operator.getParentOperators().get(0));

+	@Override

+	public Mutable<ILogicalOperator> visit(LimitOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		Schema currentSchema = t.generateInputSchema(operator

+				.getParentOperators().get(0));

 

-        LimitDesc desc = (LimitDesc) operator.getConf();

-        int limit = desc.getLimit();

-        Integer limitValue = new Integer(limit);

+		LimitDesc desc = (LimitDesc) operator.getConf();

+		int limit = desc.getLimit();

+		Integer limitValue = new Integer(limit);

 

-        ILogicalExpression expr = new ConstantExpression(new HivesterixConstantValue(limitValue));

-        ILogicalOperator currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.LimitOperator(

-                expr, true);

-        currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+		ILogicalExpression expr = new ConstantExpression(

+				new HivesterixConstantValue(limitValue));

+		ILogicalOperator currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.LimitOperator(

+				expr, true);

+		currentOperator.getInputs().add(AlgebricksParentOperatorRef);

 

-        operator.setSchema(operator.getParentOperators().get(0).getSchema());

-        List<LogicalVariable> latestOutputSchema = t.getVariablesFromSchema(currentSchema);

-        t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		operator.setSchema(operator.getParentOperators().get(0).getSchema());

+		List<LogicalVariable> latestOutputSchema = t

+				.getVariablesFromSchema(currentSchema);

+		t.rewriteOperatorOutputSchema(latestOutputSchema, operator);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/MapJoinVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/MapJoinVisitor.java
index f8af063..d0400a4 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/MapJoinVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/MapJoinVisitor.java
@@ -33,139 +33,151 @@
 

 public class MapJoinVisitor extends DefaultVisitor {

 

-    /**

-     * map a join operator (in hive) to its parent operators (in asterix)

-     */

-    private HashMap<Operator, List<Mutable<ILogicalOperator>>> opMap = new HashMap<Operator, List<Mutable<ILogicalOperator>>>();

+	/**

+	 * map a join operator (in hive) to its parent operators (in asterix)

+	 */

+	private HashMap<Operator, List<Mutable<ILogicalOperator>>> opMap = new HashMap<Operator, List<Mutable<ILogicalOperator>>>();

 

-    @Override

-    public Mutable<ILogicalOperator> visit(MapJoinOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

-        List<Operator<? extends Serializable>> joinSrc = operator.getParentOperators();

-        List<Mutable<ILogicalOperator>> parents = opMap.get(operator);

-        if (parents == null) {

-            parents = new ArrayList<Mutable<ILogicalOperator>>();

-            opMap.put(operator, parents);

-        }

-        parents.add(AlgebricksParentOperatorRef);

-        if (joinSrc.size() != parents.size())

-            return null;

+	@Override

+	public Mutable<ILogicalOperator> visit(MapJoinOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) {

+		List<Operator<? extends Serializable>> joinSrc = operator

+				.getParentOperators();

+		List<Mutable<ILogicalOperator>> parents = opMap.get(operator);

+		if (parents == null) {

+			parents = new ArrayList<Mutable<ILogicalOperator>>();

+			opMap.put(operator, parents);

+		}

+		parents.add(AlgebricksParentOperatorRef);

+		if (joinSrc.size() != parents.size())

+			return null;

 

-        ILogicalOperator currentOperator;

-        // make an map join operator

-        // TODO: will have trouble for n-way joins

-        MapJoinDesc joinDesc = (MapJoinDesc) operator.getConf();

+		ILogicalOperator currentOperator;

+		// make an map join operator

+		// TODO: will have trouble for n-way joins

+		MapJoinDesc joinDesc = (MapJoinDesc) operator.getConf();

 

-        Map<Byte, List<ExprNodeDesc>> keyMap = joinDesc.getKeys();

-        // get the projection expression (already re-written) from each source

-        // table

-        Map<Byte, List<ExprNodeDesc>> exprMap = joinDesc.getExprs();

+		Map<Byte, List<ExprNodeDesc>> keyMap = joinDesc.getKeys();

+		// get the projection expression (already re-written) from each source

+		// table

+		Map<Byte, List<ExprNodeDesc>> exprMap = joinDesc.getExprs();

 

-        int inputSize = operator.getParentOperators().size();

-        // get a list of reduce sink descs (input descs)

+		int inputSize = operator.getParentOperators().size();

+		// get a list of reduce sink descs (input descs)

 

-        // get the parent operator

-        List<Mutable<ILogicalOperator>> parentOps = parents;

+		// get the parent operator

+		List<Mutable<ILogicalOperator>> parentOps = parents;

 

-        List<String> fieldNames = new ArrayList<String>();

-        List<TypeInfo> types = new ArrayList<TypeInfo>();

-        for (Operator ts : joinSrc) {

-            List<ColumnInfo> columns = ts.getSchema().getSignature();

-            for (ColumnInfo col : columns) {

-                fieldNames.add(col.getInternalName());

-                types.add(col.getType());

-            }

-        }

+		List<String> fieldNames = new ArrayList<String>();

+		List<TypeInfo> types = new ArrayList<TypeInfo>();

+		for (Operator ts : joinSrc) {

+			List<ColumnInfo> columns = ts.getSchema().getSignature();

+			for (ColumnInfo col : columns) {

+				fieldNames.add(col.getInternalName());

+				types.add(col.getType());

+			}

+		}

 

-        // get number of equality conjunctions in the final join condition

-        Set<Entry<Byte, List<ExprNodeDesc>>> keyEntries = keyMap.entrySet();

-        List<List<ExprNodeDesc>> keyLists = new ArrayList<List<ExprNodeDesc>>();

-        Iterator<Entry<Byte, List<ExprNodeDesc>>> entry = keyEntries.iterator();

+		// get number of equality conjunctions in the final join condition

+		Set<Entry<Byte, List<ExprNodeDesc>>> keyEntries = keyMap.entrySet();

+		List<List<ExprNodeDesc>> keyLists = new ArrayList<List<ExprNodeDesc>>();

+		Iterator<Entry<Byte, List<ExprNodeDesc>>> entry = keyEntries.iterator();

 

-        int size = 0;

-        if (entry.hasNext())

-            size = entry.next().getValue().size();

+		int size = 0;

+		if (entry.hasNext())

+			size = entry.next().getValue().size();

 

-        // make up the join conditon expression

-        List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

-        for (int i = 0; i < size; i++) {

-            // create a join key pair

-            List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

-            for (int j = 0; j < inputSize; j++) {

-                keyPair.add(keyMap.get(Byte.valueOf((byte) j)).get(i));

-            }

-            // create a hive equal condition

-            ExprNodeDesc equality = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo,

-                    new GenericUDFOPEqual(), keyPair);

-            // add the equal condition to the conjunction list

-            joinConditionChildren.add(equality);

-        }

-        // get final conjunction expression

-        ExprNodeDesc conjunct = null;

+		// make up the join conditon expression

+		List<ExprNodeDesc> joinConditionChildren = new ArrayList<ExprNodeDesc>();

+		for (int i = 0; i < size; i++) {

+			// create a join key pair

+			List<ExprNodeDesc> keyPair = new ArrayList<ExprNodeDesc>();

+			for (int j = 0; j < inputSize; j++) {

+				keyPair.add(keyMap.get(Byte.valueOf((byte) j)).get(i));

+			}

+			// create a hive equal condition

+			ExprNodeDesc equality = new ExprNodeGenericFuncDesc(

+					TypeInfoFactory.booleanTypeInfo, new GenericUDFOPEqual(),

+					keyPair);

+			// add the equal condition to the conjunction list

+			joinConditionChildren.add(equality);

+		}

+		// get final conjunction expression

+		ExprNodeDesc conjunct = null;

 

-        if (joinConditionChildren.size() > 1)

-            conjunct = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

-                    joinConditionChildren);

-        else if (joinConditionChildren.size() == 1)

-            conjunct = joinConditionChildren.get(0);

-        else {

-            // there is no join equality condition, full outer join

-            conjunct = new ExprNodeConstantDesc(TypeInfoFactory.booleanTypeInfo, new Boolean(true));

-        }

-        // get an ILogicalExpression from hive's expression

-        Mutable<ILogicalExpression> expression = t.translateScalarFucntion(conjunct);

+		if (joinConditionChildren.size() > 1)

+			conjunct = new ExprNodeGenericFuncDesc(

+					TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(),

+					joinConditionChildren);

+		else if (joinConditionChildren.size() == 1)

+			conjunct = joinConditionChildren.get(0);

+		else {

+			// there is no join equality condition, full outer join

+			conjunct = new ExprNodeConstantDesc(

+					TypeInfoFactory.booleanTypeInfo, new Boolean(true));

+		}

+		// get an ILogicalExpression from hive's expression

+		Mutable<ILogicalExpression> expression = t

+				.translateScalarFucntion(conjunct);

 

-        ArrayList<LogicalVariable> left = new ArrayList<LogicalVariable>();

-        ArrayList<LogicalVariable> right = new ArrayList<LogicalVariable>();

+		ArrayList<LogicalVariable> left = new ArrayList<LogicalVariable>();

+		ArrayList<LogicalVariable> right = new ArrayList<LogicalVariable>();

 

-        Set<Entry<Byte, List<ExprNodeDesc>>> kentries = keyMap.entrySet();

-        Iterator<Entry<Byte, List<ExprNodeDesc>>> kiterator = kentries.iterator();

-        int iteration = 0;

-        ILogicalOperator assignOperator = null;

-        while (kiterator.hasNext()) {

-            List<ExprNodeDesc> outputExprs = kiterator.next().getValue();

+		Set<Entry<Byte, List<ExprNodeDesc>>> kentries = keyMap.entrySet();

+		Iterator<Entry<Byte, List<ExprNodeDesc>>> kiterator = kentries

+				.iterator();

+		int iteration = 0;

+		ILogicalOperator assignOperator = null;

+		while (kiterator.hasNext()) {

+			List<ExprNodeDesc> outputExprs = kiterator.next().getValue();

 

-            if (iteration == 0)

-                assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef, outputExprs, left);

-            else

-                assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef, outputExprs, right);

+			if (iteration == 0)

+				assignOperator = t.getAssignOperator(

+						AlgebricksParentOperatorRef, outputExprs, left);

+			else

+				assignOperator = t.getAssignOperator(

+						AlgebricksParentOperatorRef, outputExprs, right);

 

-            if (assignOperator != null) {

-                currentOperator = assignOperator;

-                AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-            }

-            iteration++;

-        }

+			if (assignOperator != null) {

+				currentOperator = assignOperator;

+				AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+						currentOperator);

+			}

+			iteration++;

+		}

 

-        List<Mutable<ILogicalOperator>> inputs = parentOps;

+		List<Mutable<ILogicalOperator>> inputs = parentOps;

 

-        // get the join operator

-        currentOperator = new InnerJoinOperator(expression);

+		// get the join operator

+		currentOperator = new InnerJoinOperator(expression);

 

-        // set the inputs from asterix join operator

-        for (Mutable<ILogicalOperator> input : inputs)

-            currentOperator.getInputs().add(input);

-        AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

+		// set the inputs from asterix join operator

+		for (Mutable<ILogicalOperator> input : inputs)

+			currentOperator.getInputs().add(input);

+		AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+				currentOperator);

 

-        // add assign and project operator

-        // output variables

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        Set<Entry<Byte, List<ExprNodeDesc>>> entries = exprMap.entrySet();

-        Iterator<Entry<Byte, List<ExprNodeDesc>>> iterator = entries.iterator();

-        while (iterator.hasNext()) {

-            List<ExprNodeDesc> outputExprs = iterator.next().getValue();

-            assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef, outputExprs, variables);

+		// add assign and project operator

+		// output variables

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		Set<Entry<Byte, List<ExprNodeDesc>>> entries = exprMap.entrySet();

+		Iterator<Entry<Byte, List<ExprNodeDesc>>> iterator = entries.iterator();

+		while (iterator.hasNext()) {

+			List<ExprNodeDesc> outputExprs = iterator.next().getValue();

+			assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef,

+					outputExprs, variables);

 

-            if (assignOperator != null) {

-                currentOperator = assignOperator;

-                AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-            }

-        }

+			if (assignOperator != null) {

+				currentOperator = assignOperator;

+				AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+						currentOperator);

+			}

+		}

 

-        currentOperator = new ProjectOperator(variables);

-        currentOperator.getInputs().add(AlgebricksParentOperatorRef);

-        t.rewriteOperatorOutputSchema(variables, operator);

-        // opMap.clear();

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		currentOperator = new ProjectOperator(variables);

+		currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+		t.rewriteOperatorOutputSchema(variables, operator);

+		// opMap.clear();

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ProjectVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ProjectVisitor.java
index eb0922f..0d2067c 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ProjectVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/ProjectVisitor.java
@@ -17,40 +17,42 @@
 

 public class ProjectVisitor extends DefaultVisitor {

 

-    /**

-     * translate project operator

-     */

-    @Override

-    public Mutable<ILogicalOperator> visit(SelectOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) {

+	/**

+	 * translate project operator

+	 */

+	@Override

+	public Mutable<ILogicalOperator> visit(SelectOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t) {

 

-        SelectDesc desc = (SelectDesc) operator.getConf();

+		SelectDesc desc = (SelectDesc) operator.getConf();

 

-        if (desc == null)

-            return null;

+		if (desc == null)

+			return null;

 

-        List<ExprNodeDesc> cols = desc.getColList();

+		List<ExprNodeDesc> cols = desc.getColList();

 

-        if (cols == null)

-            return null;

+		if (cols == null)

+			return null;

 

-        // insert assign operator if necessary

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		// insert assign operator if necessary

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

 

-        for (ExprNodeDesc expr : cols)

-            t.rewriteExpression(expr);

+		for (ExprNodeDesc expr : cols)

+			t.rewriteExpression(expr);

 

-        ILogicalOperator assignOp = t.getAssignOperator(AlgebricksParentOperator, cols, variables);

-        ILogicalOperator currentOperator = null;

-        if (assignOp != null) {

-            currentOperator = assignOp;

-            AlgebricksParentOperator = new MutableObject<ILogicalOperator>(currentOperator);

-        }

+		ILogicalOperator assignOp = t.getAssignOperator(

+				AlgebricksParentOperator, cols, variables);

+		ILogicalOperator currentOperator = null;

+		if (assignOp != null) {

+			currentOperator = assignOp;

+			AlgebricksParentOperator = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

 

-        currentOperator = new ProjectOperator(variables);

-        currentOperator.getInputs().add(AlgebricksParentOperator);

-        t.rewriteOperatorOutputSchema(variables, operator);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		currentOperator = new ProjectOperator(variables);

+		currentOperator.getInputs().add(AlgebricksParentOperator);

+		t.rewriteOperatorOutputSchema(variables, operator);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/SortVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/SortVisitor.java
index a4fc765..fbded84 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/SortVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/SortVisitor.java
@@ -26,87 +26,99 @@
 

 public class SortVisitor extends DefaultVisitor {

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException {

-        ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

-        Operator downStream = (Operator) operator.getChildOperators().get(0);

-        List<ExprNodeDesc> keys = desc.getKeyCols();

-        if (!(downStream instanceof ExtractOperator && desc.getNumReducers() == 1 && keys.size() > 0)) {

-            return null;

-        }

+	@Override

+	public Mutable<ILogicalOperator> visit(ReduceSinkOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException {

+		ReduceSinkDesc desc = (ReduceSinkDesc) operator.getConf();

+		Operator downStream = (Operator) operator.getChildOperators().get(0);

+		List<ExprNodeDesc> keys = desc.getKeyCols();

+		if (!(downStream instanceof ExtractOperator

+				&& desc.getNumReducers() == 1 && keys.size() > 0)) {

+			return null;

+		}

 

-        List<ExprNodeDesc> schema = new ArrayList<ExprNodeDesc>();

-        List<ExprNodeDesc> values = desc.getValueCols();

-        List<ExprNodeDesc> partitionCols = desc.getPartitionCols();

-        for (ExprNodeDesc key : keys) {

-            t.rewriteExpression(key);

-        }

-        for (ExprNodeDesc value : values) {

-            t.rewriteExpression(value);

-        }

-        for (ExprNodeDesc col : partitionCols) {

-            t.rewriteExpression(col);

-        }

+		List<ExprNodeDesc> schema = new ArrayList<ExprNodeDesc>();

+		List<ExprNodeDesc> values = desc.getValueCols();

+		List<ExprNodeDesc> partitionCols = desc.getPartitionCols();

+		for (ExprNodeDesc key : keys) {

+			t.rewriteExpression(key);

+		}

+		for (ExprNodeDesc value : values) {

+			t.rewriteExpression(value);

+		}

+		for (ExprNodeDesc col : partitionCols) {

+			t.rewriteExpression(col);

+		}

 

-        // add a order-by operator and limit if any

-        List<Pair<IOrder, Mutable<ILogicalExpression>>> pairs = new ArrayList<Pair<IOrder, Mutable<ILogicalExpression>>>();

-        char[] orders = desc.getOrder().toCharArray();

-        int i = 0;

-        for (ExprNodeDesc key : keys) {

-            Mutable<ILogicalExpression> expr = t.translateScalarFucntion(key);

-            IOrder order = orders[i] == '+' ? OrderOperator.ASC_ORDER : OrderOperator.DESC_ORDER;

+		// add a order-by operator and limit if any

+		List<Pair<IOrder, Mutable<ILogicalExpression>>> pairs = new ArrayList<Pair<IOrder, Mutable<ILogicalExpression>>>();

+		char[] orders = desc.getOrder().toCharArray();

+		int i = 0;

+		for (ExprNodeDesc key : keys) {

+			Mutable<ILogicalExpression> expr = t.translateScalarFucntion(key);

+			IOrder order = orders[i] == '+' ? OrderOperator.ASC_ORDER

+					: OrderOperator.DESC_ORDER;

 

-            Pair<IOrder, Mutable<ILogicalExpression>> pair = new Pair<IOrder, Mutable<ILogicalExpression>>(order, expr);

-            pairs.add(pair);

-            i++;

-        }

+			Pair<IOrder, Mutable<ILogicalExpression>> pair = new Pair<IOrder, Mutable<ILogicalExpression>>(

+					order, expr);

+			pairs.add(pair);

+			i++;

+		}

 

-        // get input variables

-        ArrayList<LogicalVariable> inputVariables = new ArrayList<LogicalVariable>();

-        VariableUtilities.getProducedVariables(AlgebricksParentOperatorRef.getValue(), inputVariables);

+		// get input variables

+		ArrayList<LogicalVariable> inputVariables = new ArrayList<LogicalVariable>();

+		VariableUtilities.getProducedVariables(

+				AlgebricksParentOperatorRef.getValue(), inputVariables);

 

-        ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

-        ILogicalOperator currentOperator;

-        ILogicalOperator assignOp = t.getAssignOperator(AlgebricksParentOperatorRef, keys, keyVariables);

-        if (assignOp != null) {

-            currentOperator = assignOp;

-            AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-        }

+		ArrayList<LogicalVariable> keyVariables = new ArrayList<LogicalVariable>();

+		ILogicalOperator currentOperator;

+		ILogicalOperator assignOp = t.getAssignOperator(

+				AlgebricksParentOperatorRef, keys, keyVariables);

+		if (assignOp != null) {

+			currentOperator = assignOp;

+			AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

 

-        OrderColumn[] keyColumns = new OrderColumn[keyVariables.size()];

+		OrderColumn[] keyColumns = new OrderColumn[keyVariables.size()];

 

-        for (int j = 0; j < keyColumns.length; j++)

-            keyColumns[j] = new OrderColumn(keyVariables.get(j), pairs.get(j).first.getKind());

+		for (int j = 0; j < keyColumns.length; j++)

+			keyColumns[j] = new OrderColumn(keyVariables.get(j),

+					pairs.get(j).first.getKind());

 

-        // handle order operator

-        currentOperator = new OrderOperator(pairs);

-        currentOperator.getInputs().add(AlgebricksParentOperatorRef);

-        AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

+		// handle order operator

+		currentOperator = new OrderOperator(pairs);

+		currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+		AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+				currentOperator);

 

-        // project back, remove generated sort-key columns if any

-        if (assignOp != null) {

-            currentOperator = new ProjectOperator(inputVariables);

-            currentOperator.getInputs().add(AlgebricksParentOperatorRef);

-            AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-        }

+		// project back, remove generated sort-key columns if any

+		if (assignOp != null) {

+			currentOperator = new ProjectOperator(inputVariables);

+			currentOperator.getInputs().add(AlgebricksParentOperatorRef);

+			AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

 

-        /**

-         * a special rule for hive's order by output schema of reduce sink

-         * operator only contains the columns

-         */

-        for (ExprNodeDesc value : values) {

-            schema.add(value);

-        }

+		/**

+		 * a special rule for hive's order by output schema of reduce sink

+		 * operator only contains the columns

+		 */

+		for (ExprNodeDesc value : values) {

+			schema.add(value);

+		}

 

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        ILogicalOperator assignOperator = t.getAssignOperator(AlgebricksParentOperatorRef, schema, variables);

-        t.rewriteOperatorOutputSchema(variables, operator);

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		ILogicalOperator assignOperator = t.getAssignOperator(

+				AlgebricksParentOperatorRef, schema, variables);

+		t.rewriteOperatorOutputSchema(variables, operator);

 

-        if (assignOperator != null) {

-            currentOperator = assignOperator;

-            AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(currentOperator);

-        }

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		if (assignOperator != null) {

+			currentOperator = assignOperator;

+			AlgebricksParentOperatorRef = new MutableObject<ILogicalOperator>(

+					currentOperator);

+		}

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/TableScanWriteVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/TableScanWriteVisitor.java
index 6071716..3e12bb9 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/TableScanWriteVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/TableScanWriteVisitor.java
@@ -34,103 +34,115 @@
 

 public class TableScanWriteVisitor extends DefaultVisitor {

 

-    /**

-     * map from alias to partition desc

-     */

-    private HashMap<String, PartitionDesc> aliasToPathMap;

+	/**

+	 * map from alias to partition desc

+	 */

+	private HashMap<String, PartitionDesc> aliasToPathMap;

 

-    /**

-     * map from partition desc to data source

-     */

-    private HashMap<PartitionDesc, IDataSource<PartitionDesc>> dataSourceMap = new HashMap<PartitionDesc, IDataSource<PartitionDesc>>();

+	/**

+	 * map from partition desc to data source

+	 */

+	private HashMap<PartitionDesc, IDataSource<PartitionDesc>> dataSourceMap = new HashMap<PartitionDesc, IDataSource<PartitionDesc>>();

 

-    /**

-     * constructor

-     * 

-     * @param aliasToPathMap

-     */

-    public TableScanWriteVisitor(HashMap<String, PartitionDesc> aliasToPathMap) {

-        this.aliasToPathMap = aliasToPathMap;

-    }

+	/**

+	 * constructor

+	 * 

+	 * @param aliasToPathMap

+	 */

+	public TableScanWriteVisitor(HashMap<String, PartitionDesc> aliasToPathMap) {

+		this.aliasToPathMap = aliasToPathMap;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(TableScanOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        TableScanDesc desc = (TableScanDesc) operator.getConf();

-        if (desc == null) {

-            List<LogicalVariable> schema = new ArrayList<LogicalVariable>();

-            VariableUtilities.getLiveVariables(AlgebricksParentOperator.getValue(), schema);

-            t.rewriteOperatorOutputSchema(schema, operator);

-            return null;

-        }

+	@Override

+	public Mutable<ILogicalOperator> visit(TableScanOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		TableScanDesc desc = (TableScanDesc) operator.getConf();

+		if (desc == null) {

+			List<LogicalVariable> schema = new ArrayList<LogicalVariable>();

+			VariableUtilities.getLiveVariables(

+					AlgebricksParentOperator.getValue(), schema);

+			t.rewriteOperatorOutputSchema(schema, operator);

+			return null;

+		}

 

-        List<ColumnInfo> columns = operator.getSchema().getSignature();

-        for (int i = columns.size() - 1; i >= 0; i--)

-            if (columns.get(i).getIsVirtualCol() == true)

-                columns.remove(i);

+		List<ColumnInfo> columns = operator.getSchema().getSignature();

+		for (int i = columns.size() - 1; i >= 0; i--)

+			if (columns.get(i).getIsVirtualCol() == true)

+				columns.remove(i);

 

-        // start with empty tuple operator

-        List<TypeInfo> types = new ArrayList<TypeInfo>();

-        ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

-        List<String> names = new ArrayList<String>();

-        for (ColumnInfo column : columns) {

-            types.add(column.getType());

+		// start with empty tuple operator

+		List<TypeInfo> types = new ArrayList<TypeInfo>();

+		ArrayList<LogicalVariable> variables = new ArrayList<LogicalVariable>();

+		List<String> names = new ArrayList<String>();

+		for (ColumnInfo column : columns) {

+			types.add(column.getType());

 

-            LogicalVariable var = t.getVariableFromFieldName(column.getTabAlias() + "." + column.getInternalName());

-            LogicalVariable varNew;

+			LogicalVariable var = t.getVariableFromFieldName(column

+					.getTabAlias() + "." + column.getInternalName());

+			LogicalVariable varNew;

 

-            if (var != null) {

-                varNew = t.getVariable(

-                        column.getTabAlias() + "." + column.getInternalName() + operator.toString(),

-                        column.getType());

-                t.replaceVariable(var, varNew);

-                var = varNew;

-            } else

-                var = t.getNewVariable(column.getTabAlias() + "." + column.getInternalName(), column.getType());

+			if (var != null) {

+				varNew = t.getVariable(

+						column.getTabAlias() + "." + column.getInternalName()

+								+ operator.toString(), column.getType());

+				t.replaceVariable(var, varNew);

+				var = varNew;

+			} else

+				var = t.getNewVariable(

+						column.getTabAlias() + "." + column.getInternalName(),

+						column.getType());

 

-            variables.add(var);

-            names.add(column.getInternalName());

-        }

-        Schema currentSchema = new Schema(names, types);

+			variables.add(var);

+			names.add(column.getInternalName());

+		}

+		Schema currentSchema = new Schema(names, types);

 

-        String alias = desc.getAlias();

-        PartitionDesc partDesc = aliasToPathMap.get(alias);

-        IDataSource<PartitionDesc> dataSource = new HiveDataSource<PartitionDesc>(partDesc, currentSchema.getSchema());

-        ILogicalOperator currentOperator = new DataSourceScanOperator(variables, dataSource);

+		String alias = desc.getAlias();

+		PartitionDesc partDesc = aliasToPathMap.get(alias);

+		IDataSource<PartitionDesc> dataSource = new HiveDataSource<PartitionDesc>(

+				partDesc, currentSchema.getSchema());

+		ILogicalOperator currentOperator = new DataSourceScanOperator(

+				variables, dataSource);

 

-        // set empty tuple source operator

-        ILogicalOperator ets = new EmptyTupleSourceOperator();

-        currentOperator.getInputs().add(new MutableObject<ILogicalOperator>(ets));

+		// set empty tuple source operator

+		ILogicalOperator ets = new EmptyTupleSourceOperator();

+		currentOperator.getInputs().add(

+				new MutableObject<ILogicalOperator>(ets));

 

-        // setup data source

-        dataSourceMap.put(partDesc, dataSource);

-        t.rewriteOperatorOutputSchema(variables, operator);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		// setup data source

+		dataSourceMap.put(partDesc, dataSource);

+		t.rewriteOperatorOutputSchema(variables, operator);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) {

+	@Override

+	public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t) {

 

-        if (hiveOperator.getChildOperators() != null && hiveOperator.getChildOperators().size() > 0)

-            return null;

+		if (hiveOperator.getChildOperators() != null

+				&& hiveOperator.getChildOperators().size() > 0)

+			return null;

 

-        Schema currentSchema = t.generateInputSchema(hiveOperator.getParentOperators().get(0));

+		Schema currentSchema = t.generateInputSchema(hiveOperator

+				.getParentOperators().get(0));

 

-        IDataSink sink = new HiveDataSink(hiveOperator, currentSchema.getSchema());

-        List<Mutable<ILogicalExpression> > exprList = new ArrayList<Mutable<ILogicalExpression>>();

-        for (String column : currentSchema.getNames()) {

-            exprList.add(new MutableObject<ILogicalExpression> (new VariableReferenceExpression(t.getVariable(column))));

-        }

+		IDataSink sink = new HiveDataSink(hiveOperator,

+				currentSchema.getSchema());

+		List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();

+		for (String column : currentSchema.getNames()) {

+			exprList.add(new MutableObject<ILogicalExpression>(

+					new VariableReferenceExpression(t.getVariable(column))));

+		}

 

-        ILogicalOperator currentOperator = new WriteOperator(exprList, sink);

-        if (AlgebricksParentOperator != null) {

-            currentOperator.getInputs().add(AlgebricksParentOperator);

-        }

+		ILogicalOperator currentOperator = new WriteOperator(exprList, sink);

+		if (AlgebricksParentOperator != null) {

+			currentOperator.getInputs().add(AlgebricksParentOperator);

+		}

 

-        IMetadataProvider<PartitionDesc, Object> metaData = new HiveMetaDataProvider<PartitionDesc, Object>(

-                hiveOperator, currentSchema, dataSourceMap);

-        t.setMetadataProvider(metaData);

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		IMetadataProvider<PartitionDesc, Object> metaData = new HiveMetaDataProvider<PartitionDesc, Object>(

+				hiveOperator, currentSchema, dataSourceMap);

+		t.setMetadataProvider(metaData);

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/UnionVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/UnionVisitor.java
index 96b9463..f4e74f6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/UnionVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/UnionVisitor.java
@@ -18,45 +18,47 @@
 

 public class UnionVisitor extends DefaultVisitor {

 

-    List<Mutable<ILogicalOperator>> parents = new ArrayList<Mutable<ILogicalOperator>>();

+	List<Mutable<ILogicalOperator>> parents = new ArrayList<Mutable<ILogicalOperator>>();

 

-    @Override

-    public Mutable<ILogicalOperator> visit(UnionOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

+	@Override

+	public Mutable<ILogicalOperator> visit(UnionOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

 

-        parents.add(AlgebricksParentOperator);

-        if (operator.getParentOperators().size() > parents.size()) {

-            return null;

-        }

+		parents.add(AlgebricksParentOperator);

+		if (operator.getParentOperators().size() > parents.size()) {

+			return null;

+		}

 

-        List<LogicalVariable> leftVars = new ArrayList<LogicalVariable>();

-        List<LogicalVariable> rightVars = new ArrayList<LogicalVariable>();

+		List<LogicalVariable> leftVars = new ArrayList<LogicalVariable>();

+		List<LogicalVariable> rightVars = new ArrayList<LogicalVariable>();

 

-        VariableUtilities.getUsedVariables(parents.get(0).getValue(), leftVars);

-        VariableUtilities.getUsedVariables(parents.get(1).getValue(), rightVars);

+		VariableUtilities.getUsedVariables(parents.get(0).getValue(), leftVars);

+		VariableUtilities

+				.getUsedVariables(parents.get(1).getValue(), rightVars);

 

-        List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> triples = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>();

-        List<LogicalVariable> unionVars = new ArrayList<LogicalVariable>();

+		List<Triple<LogicalVariable, LogicalVariable, LogicalVariable>> triples = new ArrayList<Triple<LogicalVariable, LogicalVariable, LogicalVariable>>();

+		List<LogicalVariable> unionVars = new ArrayList<LogicalVariable>();

 

-        for (int i = 0; i < leftVars.size(); i++) {

-            LogicalVariable unionVar = t.getVariable(

-                    leftVars.get(i).getId() + "union" + AlgebricksParentOperator.hashCode(),

-                    TypeInfoFactory.unknownTypeInfo);

-            unionVars.add(unionVar);

-            Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(

-                    leftVars.get(i), rightVars.get(i), unionVar);

-            t.replaceVariable(leftVars.get(i), unionVar);

-            t.replaceVariable(rightVars.get(i), unionVar);

-            triples.add(triple);

-        }

-        ILogicalOperator currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator(

-                triples);

-        for (Mutable<ILogicalOperator> parent : parents)

-            currentOperator.getInputs().add(parent);

+		for (int i = 0; i < leftVars.size(); i++) {

+			LogicalVariable unionVar = t.getVariable(leftVars.get(i).getId()

+					+ "union" + AlgebricksParentOperator.hashCode(),

+					TypeInfoFactory.unknownTypeInfo);

+			unionVars.add(unionVar);

+			Triple<LogicalVariable, LogicalVariable, LogicalVariable> triple = new Triple<LogicalVariable, LogicalVariable, LogicalVariable>(

+					leftVars.get(i), rightVars.get(i), unionVar);

+			t.replaceVariable(leftVars.get(i), unionVar);

+			t.replaceVariable(rightVars.get(i), unionVar);

+			triples.add(triple);

+		}

+		ILogicalOperator currentOperator = new edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator(

+				triples);

+		for (Mutable<ILogicalOperator> parent : parents)

+			currentOperator.getInputs().add(parent);

 

-        t.rewriteOperatorOutputSchema(unionVars, operator);

-        parents.clear();

-        return new MutableObject<ILogicalOperator>(currentOperator);

-    }

+		t.rewriteOperatorOutputSchema(unionVars, operator);

+		parents.clear();

+		return new MutableObject<ILogicalOperator>(currentOperator);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/DefaultVisitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/DefaultVisitor.java
index 972deed..20013e3 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/DefaultVisitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/DefaultVisitor.java
@@ -31,115 +31,136 @@
  */

 public class DefaultVisitor implements Visitor {

 

-    @Override

-    public Mutable<ILogicalOperator> visit(CollectOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(CollectOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(JoinOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(JoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ExtractOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(ExtractOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(MapJoinOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(MapJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(SMBMapJoinOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(SMBMapJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    public Mutable<ILogicalOperator> visit(ReduceSinkOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	public Mutable<ILogicalOperator> visit(ReduceSinkOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(FilterOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(FilterOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ForwardOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(ForwardOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(GroupByOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(GroupByOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(LateralViewForwardOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(

+			LateralViewForwardOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(LateralViewJoinOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(

+			LateralViewJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(LimitOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(LimitOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(MapOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(MapOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(ScriptOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(ScriptOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(SelectOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(SelectOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(TableScanOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(TableScanOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(UDTFOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(UDTFOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public Mutable<ILogicalOperator> visit(UnionOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperator,

-            Translator t) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public Mutable<ILogicalOperator> visit(UnionOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperator, Translator t)

+			throws AlgebricksException {

+		return null;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Translator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Translator.java
index da87f53..7b2747e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Translator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Translator.java
@@ -19,151 +19,155 @@
 

 public interface Translator {

 

-    /**

-     * generate input schema

-     * 

-     * @param operator

-     * @return

-     */

-    public Schema generateInputSchema(Operator operator);

+	/**

+	 * generate input schema

+	 * 

+	 * @param operator

+	 * @return

+	 */

+	public Schema generateInputSchema(Operator operator);

 

-    /**

-     * rewrite the names of output columns for feture expression evaluators to

-     * use

-     * 

-     * @param operator

-     */

-    public void rewriteOperatorOutputSchema(List<LogicalVariable> vars, Operator operator);

+	/**

+	 * rewrite the names of output columns for feture expression evaluators to

+	 * use

+	 * 

+	 * @param operator

+	 */

+	public void rewriteOperatorOutputSchema(List<LogicalVariable> vars,

+			Operator operator);

 

-    /**

-     * rewrite the names of output columns for feture expression evaluators to

-     * use

-     * 

-     * @param operator

-     */

-    public void rewriteOperatorOutputSchema(Operator operator);

+	/**

+	 * rewrite the names of output columns for feture expression evaluators to

+	 * use

+	 * 

+	 * @param operator

+	 */

+	public void rewriteOperatorOutputSchema(Operator operator);

 

-    /**

-     * rewrite an expression and substitute variables

-     * 

-     * @param expr

-     *            hive expression

-     */

-    public void rewriteExpression(ExprNodeDesc expr);

+	/**

+	 * rewrite an expression and substitute variables

+	 * 

+	 * @param expr

+	 *            hive expression

+	 */

+	public void rewriteExpression(ExprNodeDesc expr);

 

-    /**

-     * rewrite an expression and substitute variables

-     * 

-     * @param expr

-     *            hive expression

-     */

-    public void rewriteExpressionPartial(ExprNodeDesc expr);

+	/**

+	 * rewrite an expression and substitute variables

+	 * 

+	 * @param expr

+	 *            hive expression

+	 */

+	public void rewriteExpressionPartial(ExprNodeDesc expr);

 

-    /**

-     * get an assign operator as a child of parent

-     * 

-     * @param parent

-     * @param cols

-     * @param variables

-     * @return

-     */

-    public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent, List<ExprNodeDesc> cols,

-            ArrayList<LogicalVariable> variables);

+	/**

+	 * get an assign operator as a child of parent

+	 * 

+	 * @param parent

+	 * @param cols

+	 * @param variables

+	 * @return

+	 */

+	public ILogicalOperator getAssignOperator(Mutable<ILogicalOperator> parent,

+			List<ExprNodeDesc> cols, ArrayList<LogicalVariable> variables);

 

-    /**

-     * get type for a logical variable

-     * 

-     * @param var

-     * @return type info

-     */

-    public TypeInfo getType(LogicalVariable var);

+	/**

+	 * get type for a logical variable

+	 * 

+	 * @param var

+	 * @return type info

+	 */

+	public TypeInfo getType(LogicalVariable var);

 

-    /**

-     * translate an expression from hive to Algebricks

-     * 

-     * @param desc

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateScalarFucntion(ExprNodeDesc desc);

+	/**

+	 * translate an expression from hive to Algebricks

+	 * 

+	 * @param desc

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateScalarFucntion(ExprNodeDesc desc);

 

-    /**

-     * translate an aggregation from hive to Algebricks

-     * 

-     * @param aggregateDesc

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateAggregation(AggregationDesc aggregateDesc);

+	/**

+	 * translate an aggregation from hive to Algebricks

+	 * 

+	 * @param aggregateDesc

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateAggregation(

+			AggregationDesc aggregateDesc);

 

-    /**

-     * translate unnesting (UDTF) function expression

-     * 

-     * @param aggregator

-     * @return

-     */

-    public Mutable<ILogicalExpression> translateUnnestFunction(UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument);

+	/**

+	 * translate unnesting (UDTF) function expression

+	 * 

+	 * @param aggregator

+	 * @return

+	 */

+	public Mutable<ILogicalExpression> translateUnnestFunction(

+			UDTFDesc udtfDesc, Mutable<ILogicalExpression> argument);

 

-    /**

-     * get variable from a schema

-     * 

-     * @param schema

-     * @return

-     */

-    public List<LogicalVariable> getVariablesFromSchema(Schema schema);

+	/**

+	 * get variable from a schema

+	 * 

+	 * @param schema

+	 * @return

+	 */

+	public List<LogicalVariable> getVariablesFromSchema(Schema schema);

 

-    /**

-     * get variable from name

-     * 

-     * @param name

-     * @return

-     */

-    public LogicalVariable getVariable(String name);

+	/**

+	 * get variable from name

+	 * 

+	 * @param name

+	 * @return

+	 */

+	public LogicalVariable getVariable(String name);

 

-    /**

-     * get variable from field name

-     * 

-     * @param name

-     * @return

-     */

-    public LogicalVariable getVariableFromFieldName(String name);

+	/**

+	 * get variable from field name

+	 * 

+	 * @param name

+	 * @return

+	 */

+	public LogicalVariable getVariableFromFieldName(String name);

 

-    /**

-     * get variable from name, type

-     * 

-     * @param fieldName

-     * @param type

-     * @return

-     */

-    public LogicalVariable getVariable(String fieldName, TypeInfo type);

+	/**

+	 * get variable from name, type

+	 * 

+	 * @param fieldName

+	 * @param type

+	 * @return

+	 */

+	public LogicalVariable getVariable(String fieldName, TypeInfo type);

 

-    /**

-     * get new variable from name, type

-     * 

-     * @param fieldName

-     * @param type

-     * @return

-     */

-    public LogicalVariable getNewVariable(String fieldName, TypeInfo type);

+	/**

+	 * get new variable from name, type

+	 * 

+	 * @param fieldName

+	 * @param type

+	 * @return

+	 */

+	public LogicalVariable getNewVariable(String fieldName, TypeInfo type);

 

-    /**

-     * set the metadata provider

-     * 

-     * @param metadata

-     */

-    public void setMetadataProvider(IMetadataProvider<PartitionDesc, Object> metadata);

+	/**

+	 * set the metadata provider

+	 * 

+	 * @param metadata

+	 */

+	public void setMetadataProvider(

+			IMetadataProvider<PartitionDesc, Object> metadata);

 

-    /**

-     * get the metadata provider

-     * 

-     * @param metadata

-     */

-    public IMetadataProvider<PartitionDesc, Object> getMetadataProvider();

+	/**

+	 * get the metadata provider

+	 * 

+	 * @param metadata

+	 */

+	public IMetadataProvider<PartitionDesc, Object> getMetadataProvider();

 

-    /**

-     * replace the variable

-     * 

-     * @param oldVar

-     * @param newVar

-     */

-    public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar);

+	/**

+	 * replace the variable

+	 * 

+	 * @param oldVar

+	 * @param newVar

+	 */

+	public void replaceVariable(LogicalVariable oldVar, LogicalVariable newVar);

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Visitor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Visitor.java
index 495f3ee..745f93e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Visitor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/logical/plan/visitor/base/Visitor.java
@@ -26,60 +26,81 @@
 

 public interface Visitor {

 

-    public Mutable<ILogicalOperator> visit(CollectOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(CollectOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(JoinOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(JoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(ExtractOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(ExtractOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(MapJoinOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(MapJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(SMBMapJoinOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(SMBMapJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(FilterOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(FilterOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(ForwardOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(ForwardOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(GroupByOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(GroupByOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(LateralViewForwardOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(

+			LateralViewForwardOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(LateralViewJoinOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(

+			LateralViewJoinOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(LimitOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(LimitOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(MapOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(MapOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(ScriptOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(ScriptOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(SelectOperator hiveOperator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(SelectOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(TableScanOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(TableScanOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(FileSinkOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(ReduceSinkOperator hiveOperator,

-            Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(ReduceSinkOperator hiveOperator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(UDTFOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(UDTFOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 

-    public Mutable<ILogicalOperator> visit(UnionOperator operator, Mutable<ILogicalOperator> AlgebricksParentOperatorRef,

-            Translator t) throws AlgebricksException;

+	public Mutable<ILogicalOperator> visit(UnionOperator operator,

+			Mutable<ILogicalOperator> AlgebricksParentOperatorRef, Translator t)

+			throws AlgebricksException;

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rulecollections/HiveRuleCollections.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rulecollections/HiveRuleCollections.java
index 7e4e271..4ebea0a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rulecollections/HiveRuleCollections.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rulecollections/HiveRuleCollections.java
@@ -37,77 +37,78 @@
 

 public final class HiveRuleCollections {

 

-    public final static LinkedList<IAlgebraicRewriteRule> NORMALIZATION = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        NORMALIZATION.add(new EliminateSubplanRule());

-        NORMALIZATION.add(new IntroduceAggregateCombinerRule());

-        NORMALIZATION.add(new BreakSelectIntoConjunctsRule());

-        NORMALIZATION.add(new IntroduceAggregateCombinerRule());

-        NORMALIZATION.add(new PushSelectIntoJoinRule());

-        NORMALIZATION.add(new ExtractGbyExpressionsRule());

-        NORMALIZATION.add(new RemoveRedundantSelectRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> NORMALIZATION = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		NORMALIZATION.add(new EliminateSubplanRule());

+		NORMALIZATION.add(new IntroduceAggregateCombinerRule());

+		NORMALIZATION.add(new BreakSelectIntoConjunctsRule());

+		NORMALIZATION.add(new IntroduceAggregateCombinerRule());

+		NORMALIZATION.add(new PushSelectIntoJoinRule());

+		NORMALIZATION.add(new ExtractGbyExpressionsRule());

+		NORMALIZATION.add(new RemoveRedundantSelectRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> COND_PUSHDOWN_AND_JOIN_INFERENCE = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new PushSelectDownRule());

-        COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new InlineVariablesRule());

-        COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new FactorRedundantGroupAndDecorVarsRule());

-        COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new EliminateSubplanRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> COND_PUSHDOWN_AND_JOIN_INFERENCE = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new PushSelectDownRule());

+		COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new InlineVariablesRule());

+		COND_PUSHDOWN_AND_JOIN_INFERENCE

+				.add(new FactorRedundantGroupAndDecorVarsRule());

+		COND_PUSHDOWN_AND_JOIN_INFERENCE.add(new EliminateSubplanRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> LOAD_FIELDS = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        // should LoadRecordFieldsRule be applied in only one pass over the

-        // plan?

-        LOAD_FIELDS.add(new InlineVariablesRule());

-        // LOAD_FIELDS.add(new RemoveUnusedAssignAndAggregateRule());

-        LOAD_FIELDS.add(new ComplexJoinInferenceRule());

-        LOAD_FIELDS.add(new InferTypesRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> LOAD_FIELDS = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		// should LoadRecordFieldsRule be applied in only one pass over the

+		// plan?

+		LOAD_FIELDS.add(new InlineVariablesRule());

+		// LOAD_FIELDS.add(new RemoveUnusedAssignAndAggregateRule());

+		LOAD_FIELDS.add(new ComplexJoinInferenceRule());

+		LOAD_FIELDS.add(new InferTypesRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> OP_PUSHDOWN = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        OP_PUSHDOWN.add(new PushProjectDownRule());

-        OP_PUSHDOWN.add(new PushSelectDownRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> OP_PUSHDOWN = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		OP_PUSHDOWN.add(new PushProjectDownRule());

+		OP_PUSHDOWN.add(new PushSelectDownRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> DATA_EXCHANGE = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        DATA_EXCHANGE.add(new SetExecutionModeRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> DATA_EXCHANGE = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		DATA_EXCHANGE.add(new SetExecutionModeRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> CONSOLIDATION = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        CONSOLIDATION.add(new RemoveRedundantProjectionRule());

-        CONSOLIDATION.add(new ConsolidateSelectsRule());

-        CONSOLIDATION.add(new IntroduceEarlyProjectRule());

-        CONSOLIDATION.add(new ConsolidateAssignsRule());

-        CONSOLIDATION.add(new IntroduceGroupByCombinerRule());

-        CONSOLIDATION.add(new RemoveUnusedAssignAndAggregateRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> CONSOLIDATION = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		CONSOLIDATION.add(new RemoveRedundantProjectionRule());

+		CONSOLIDATION.add(new ConsolidateSelectsRule());

+		CONSOLIDATION.add(new IntroduceEarlyProjectRule());

+		CONSOLIDATION.add(new ConsolidateAssignsRule());

+		CONSOLIDATION.add(new IntroduceGroupByCombinerRule());

+		CONSOLIDATION.add(new RemoveUnusedAssignAndAggregateRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> PHYSICAL_PLAN_REWRITES = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        PHYSICAL_PLAN_REWRITES.add(new PullSelectOutOfEqJoin());

-        PHYSICAL_PLAN_REWRITES.add(new SetAlgebricksPhysicalOperatorsRule());

-        PHYSICAL_PLAN_REWRITES.add(new EnforceStructuralPropertiesRule());

-        PHYSICAL_PLAN_REWRITES.add(new PushProjectDownRule());

-        PHYSICAL_PLAN_REWRITES.add(new SetAlgebricksPhysicalOperatorsRule());

-        PHYSICAL_PLAN_REWRITES.add(new PushLimitDownRule());

-        PHYSICAL_PLAN_REWRITES.add(new InsertProjectBeforeWriteRule());

-        PHYSICAL_PLAN_REWRITES.add(new InsertProjectBeforeUnionRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> PHYSICAL_PLAN_REWRITES = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		PHYSICAL_PLAN_REWRITES.add(new PullSelectOutOfEqJoin());

+		PHYSICAL_PLAN_REWRITES.add(new SetAlgebricksPhysicalOperatorsRule());

+		PHYSICAL_PLAN_REWRITES.add(new EnforceStructuralPropertiesRule());

+		PHYSICAL_PLAN_REWRITES.add(new PushProjectDownRule());

+		PHYSICAL_PLAN_REWRITES.add(new SetAlgebricksPhysicalOperatorsRule());

+		PHYSICAL_PLAN_REWRITES.add(new PushLimitDownRule());

+		PHYSICAL_PLAN_REWRITES.add(new InsertProjectBeforeWriteRule());

+		PHYSICAL_PLAN_REWRITES.add(new InsertProjectBeforeUnionRule());

+	}

 

-    public final static LinkedList<IAlgebraicRewriteRule> prepareJobGenRules = new LinkedList<IAlgebraicRewriteRule>();

-    static {

-        prepareJobGenRules.add(new ReinferAllTypesRule());

-        prepareJobGenRules.add(new IsolateHyracksOperatorsRule(

-                HeuristicOptimizer.hyraxOperatorsBelowWhichJobGenIsDisabled));

-        prepareJobGenRules.add(new ExtractCommonOperatorsRule());

-        prepareJobGenRules.add(new LocalGroupByRule());

-        prepareJobGenRules.add(new PushProjectIntoDataSourceScanRule());

-        prepareJobGenRules.add(new ReinferAllTypesRule());

-    }

+	public final static LinkedList<IAlgebraicRewriteRule> prepareJobGenRules = new LinkedList<IAlgebraicRewriteRule>();

+	static {

+		prepareJobGenRules.add(new ReinferAllTypesRule());

+		prepareJobGenRules.add(new IsolateHyracksOperatorsRule(

+				HeuristicOptimizer.hyraxOperatorsBelowWhichJobGenIsDisabled));

+		prepareJobGenRules.add(new ExtractCommonOperatorsRule());

+		prepareJobGenRules.add(new LocalGroupByRule());

+		prepareJobGenRules.add(new PushProjectIntoDataSourceScanRule());

+		prepareJobGenRules.add(new ReinferAllTypesRule());

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/InsertProjectBeforeWriteRule.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/InsertProjectBeforeWriteRule.java
index 90777ee..c58982e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/InsertProjectBeforeWriteRule.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/InsertProjectBeforeWriteRule.java
@@ -21,59 +21,65 @@
 
 public class InsertProjectBeforeWriteRule implements IAlgebraicRewriteRule {
 
-    @Override
-    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) {
-        return false;
-    }
+	@Override
+	public boolean rewritePost(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) {
+		return false;
+	}
 
-    /**
-     * When the input schema to WriteOperator is different from the output
-     * schema in terms of variable order, add a project operator to get the
-     * write order
-     */
-    @Override
-    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
-        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
-        if (op.getOperatorTag() != LogicalOperatorTag.WRITE) {
-            return false;
-        }
-        WriteOperator opWrite = (WriteOperator) op;
-        ArrayList<LogicalVariable> finalSchema = new ArrayList<LogicalVariable>();
-        VariableUtilities.getUsedVariables(opWrite, finalSchema);
-        ArrayList<LogicalVariable> inputSchema = new ArrayList<LogicalVariable>();
-        VariableUtilities.getLiveVariables(opWrite, inputSchema);
-        if (!isIdentical(finalSchema, inputSchema)) {
-            ProjectOperator projectOp = new ProjectOperator(finalSchema);
-            Mutable<ILogicalOperator> parentOpRef = opWrite.getInputs().get(0);
-            projectOp.getInputs().add(parentOpRef);
-            opWrite.getInputs().clear();
-            opWrite.getInputs().add(new MutableObject<ILogicalOperator>(projectOp));
-            projectOp.setPhysicalOperator(new StreamProjectPOperator());
-            projectOp.setExecutionMode(ExecutionMode.PARTITIONED);
+	/**
+	 * When the input schema to WriteOperator is different from the output
+	 * schema in terms of variable order, add a project operator to get the
+	 * write order
+	 */
+	@Override
+	public boolean rewritePre(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+		if (op.getOperatorTag() != LogicalOperatorTag.WRITE) {
+			return false;
+		}
+		WriteOperator opWrite = (WriteOperator) op;
+		ArrayList<LogicalVariable> finalSchema = new ArrayList<LogicalVariable>();
+		VariableUtilities.getUsedVariables(opWrite, finalSchema);
+		ArrayList<LogicalVariable> inputSchema = new ArrayList<LogicalVariable>();
+		VariableUtilities.getLiveVariables(opWrite, inputSchema);
+		if (!isIdentical(finalSchema, inputSchema)) {
+			ProjectOperator projectOp = new ProjectOperator(finalSchema);
+			Mutable<ILogicalOperator> parentOpRef = opWrite.getInputs().get(0);
+			projectOp.getInputs().add(parentOpRef);
+			opWrite.getInputs().clear();
+			opWrite.getInputs().add(
+					new MutableObject<ILogicalOperator>(projectOp));
+			projectOp.setPhysicalOperator(new StreamProjectPOperator());
+			projectOp.setExecutionMode(ExecutionMode.PARTITIONED);
 
-            AbstractLogicalOperator op2 = (AbstractLogicalOperator) parentOpRef.getValue();
-            if (op2.getOperatorTag() == LogicalOperatorTag.PROJECT) {
-                ProjectOperator pi2 = (ProjectOperator) op2;
-                parentOpRef.setValue(pi2.getInputs().get(0).getValue());
-            }
-            context.computeAndSetTypeEnvironmentForOperator(projectOp);
-            return true;
-        } else
-            return false;
+			AbstractLogicalOperator op2 = (AbstractLogicalOperator) parentOpRef
+					.getValue();
+			if (op2.getOperatorTag() == LogicalOperatorTag.PROJECT) {
+				ProjectOperator pi2 = (ProjectOperator) op2;
+				parentOpRef.setValue(pi2.getInputs().get(0).getValue());
+			}
+			context.computeAndSetTypeEnvironmentForOperator(projectOp);
+			return true;
+		} else
+			return false;
 
-    }
+	}
 
-    private boolean isIdentical(List<LogicalVariable> finalSchema, List<LogicalVariable> inputSchema) {
-        int finalSchemaSize = finalSchema.size();
-        int inputSchemaSize = inputSchema.size();
-        if (finalSchemaSize != inputSchemaSize)
-            throw new IllegalStateException("final output schema variables missing!");
-        for (int i = 0; i < finalSchemaSize; i++) {
-            LogicalVariable var1 = finalSchema.get(i);
-            LogicalVariable var2 = inputSchema.get(i);
-            if (!var1.equals(var2))
-                return false;
-        }
-        return true;
-    }
+	private boolean isIdentical(List<LogicalVariable> finalSchema,
+			List<LogicalVariable> inputSchema) {
+		int finalSchemaSize = finalSchema.size();
+		int inputSchemaSize = inputSchema.size();
+		if (finalSchemaSize != inputSchemaSize)
+			throw new IllegalStateException(
+					"final output schema variables missing!");
+		for (int i = 0; i < finalSchemaSize; i++) {
+			LogicalVariable var1 = finalSchema.get(i);
+			LogicalVariable var2 = inputSchema.get(i);
+			if (!var1.equals(var2))
+				return false;
+		}
+		return true;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/IntroduceEarlyProjectRule.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/IntroduceEarlyProjectRule.java
index 96815ff..2bebe81 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/IntroduceEarlyProjectRule.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/IntroduceEarlyProjectRule.java
@@ -20,53 +20,58 @@
 
 public class IntroduceEarlyProjectRule implements IAlgebraicRewriteRule {
 
-    @Override
-    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
-        return false;
-    }
+	@Override
+	public boolean rewritePre(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		return false;
+	}
 
-    @Override
-    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
-        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
-        if (op.getOperatorTag() != LogicalOperatorTag.PROJECT) {
-            return false;
-        }
-        AbstractLogicalOperator middleOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
-        List<LogicalVariable> deliveredVars = new ArrayList<LogicalVariable>();
-        List<LogicalVariable> usedVars = new ArrayList<LogicalVariable>();
-        List<LogicalVariable> producedVars = new ArrayList<LogicalVariable>();
+	@Override
+	public boolean rewritePost(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+		if (op.getOperatorTag() != LogicalOperatorTag.PROJECT) {
+			return false;
+		}
+		AbstractLogicalOperator middleOp = (AbstractLogicalOperator) op
+				.getInputs().get(0).getValue();
+		List<LogicalVariable> deliveredVars = new ArrayList<LogicalVariable>();
+		List<LogicalVariable> usedVars = new ArrayList<LogicalVariable>();
+		List<LogicalVariable> producedVars = new ArrayList<LogicalVariable>();
 
-        VariableUtilities.getUsedVariables(op, deliveredVars);
-        VariableUtilities.getUsedVariables(middleOp, usedVars);
-        VariableUtilities.getProducedVariables(middleOp, producedVars);
+		VariableUtilities.getUsedVariables(op, deliveredVars);
+		VariableUtilities.getUsedVariables(middleOp, usedVars);
+		VariableUtilities.getProducedVariables(middleOp, producedVars);
 
-        Set<LogicalVariable> requiredVariables = new HashSet<LogicalVariable>();
-        requiredVariables.addAll(deliveredVars);
-        requiredVariables.addAll(usedVars);
-        requiredVariables.removeAll(producedVars);
+		Set<LogicalVariable> requiredVariables = new HashSet<LogicalVariable>();
+		requiredVariables.addAll(deliveredVars);
+		requiredVariables.addAll(usedVars);
+		requiredVariables.removeAll(producedVars);
 
-        if (middleOp.getInputs().size() <= 0 || middleOp.getInputs().size() > 1)
-            return false;
+		if (middleOp.getInputs().size() <= 0 || middleOp.getInputs().size() > 1)
+			return false;
 
-        AbstractLogicalOperator targetOp = (AbstractLogicalOperator) middleOp.getInputs().get(0).getValue();
-        if (targetOp.getOperatorTag() != LogicalOperatorTag.DATASOURCESCAN)
-            return false;
+		AbstractLogicalOperator targetOp = (AbstractLogicalOperator) middleOp
+				.getInputs().get(0).getValue();
+		if (targetOp.getOperatorTag() != LogicalOperatorTag.DATASOURCESCAN)
+			return false;
 
-        Set<LogicalVariable> deliveredEarlyVars = new HashSet<LogicalVariable>();
-        VariableUtilities.getLiveVariables(targetOp, deliveredEarlyVars);
+		Set<LogicalVariable> deliveredEarlyVars = new HashSet<LogicalVariable>();
+		VariableUtilities.getLiveVariables(targetOp, deliveredEarlyVars);
 
-        deliveredEarlyVars.removeAll(requiredVariables);
-        if (deliveredEarlyVars.size() > 0) {
-            ArrayList<LogicalVariable> requiredVars = new ArrayList<LogicalVariable>();
-            requiredVars.addAll(requiredVariables);
-            ILogicalOperator earlyProjectOp = new ProjectOperator(requiredVars);
-            Mutable<ILogicalOperator> earlyProjectOpRef = new MutableObject<ILogicalOperator>(earlyProjectOp);
-            Mutable<ILogicalOperator> targetRef = middleOp.getInputs().get(0);
-            middleOp.getInputs().set(0, earlyProjectOpRef);
-            earlyProjectOp.getInputs().add(targetRef);
-            context.computeAndSetTypeEnvironmentForOperator(earlyProjectOp);
-            return true;
-        }
-        return false;
-    }
+		deliveredEarlyVars.removeAll(requiredVariables);
+		if (deliveredEarlyVars.size() > 0) {
+			ArrayList<LogicalVariable> requiredVars = new ArrayList<LogicalVariable>();
+			requiredVars.addAll(requiredVariables);
+			ILogicalOperator earlyProjectOp = new ProjectOperator(requiredVars);
+			Mutable<ILogicalOperator> earlyProjectOpRef = new MutableObject<ILogicalOperator>(
+					earlyProjectOp);
+			Mutable<ILogicalOperator> targetRef = middleOp.getInputs().get(0);
+			middleOp.getInputs().set(0, earlyProjectOpRef);
+			earlyProjectOp.getInputs().add(targetRef);
+			context.computeAndSetTypeEnvironmentForOperator(earlyProjectOp);
+			return true;
+		}
+		return false;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/LocalGroupByRule.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/LocalGroupByRule.java
index 90ca008..72cbe21 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/LocalGroupByRule.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/LocalGroupByRule.java
@@ -17,50 +17,55 @@
 
 public class LocalGroupByRule implements IAlgebraicRewriteRule {
 
-    @Override
-    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
-        return false;
-    }
+	@Override
+	public boolean rewritePre(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		return false;
+	}
 
-    @Override
-    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
-            throws AlgebricksException {
-        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
-        if (op.getOperatorTag() != LogicalOperatorTag.GROUP) {
-            return false;
-        }
-        Boolean localGby = (Boolean) op.getAnnotations().get(HiveOperatorAnnotations.LOCAL_GROUP_BY);
-        if (localGby != null && localGby.equals(Boolean.TRUE)) {
-            Boolean hashGby = (Boolean) op.getAnnotations().get(OperatorAnnotations.USE_HASH_GROUP_BY);
-            Boolean externalGby = (Boolean) op.getAnnotations().get(OperatorAnnotations.USE_EXTERNAL_GROUP_BY);
-            if ((hashGby != null && (hashGby.equals(Boolean.TRUE)) || (externalGby != null && externalGby
-                    .equals(Boolean.TRUE)))) {
-                reviseExchange(op);
-            } else {
-                ILogicalOperator child = op.getInputs().get(0).getValue();
-                AbstractLogicalOperator childOp = (AbstractLogicalOperator) child;
-                while (child.getInputs().size() > 0) {
-                    if (childOp.getOperatorTag() == LogicalOperatorTag.ORDER)
-                        break;
-                    else {
-                        child = child.getInputs().get(0).getValue();
-                        childOp = (AbstractLogicalOperator) child;
-                    }
-                }
-                if (childOp.getOperatorTag() == LogicalOperatorTag.ORDER)
-                    reviseExchange(childOp);
-            }
-            return true;
-        }
-        return false;
-    }
+	@Override
+	public boolean rewritePost(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+		if (op.getOperatorTag() != LogicalOperatorTag.GROUP) {
+			return false;
+		}
+		Boolean localGby = (Boolean) op.getAnnotations().get(
+				HiveOperatorAnnotations.LOCAL_GROUP_BY);
+		if (localGby != null && localGby.equals(Boolean.TRUE)) {
+			Boolean hashGby = (Boolean) op.getAnnotations().get(
+					OperatorAnnotations.USE_HASH_GROUP_BY);
+			Boolean externalGby = (Boolean) op.getAnnotations().get(
+					OperatorAnnotations.USE_EXTERNAL_GROUP_BY);
+			if ((hashGby != null && (hashGby.equals(Boolean.TRUE)) || (externalGby != null && externalGby
+					.equals(Boolean.TRUE)))) {
+				reviseExchange(op);
+			} else {
+				ILogicalOperator child = op.getInputs().get(0).getValue();
+				AbstractLogicalOperator childOp = (AbstractLogicalOperator) child;
+				while (child.getInputs().size() > 0) {
+					if (childOp.getOperatorTag() == LogicalOperatorTag.ORDER)
+						break;
+					else {
+						child = child.getInputs().get(0).getValue();
+						childOp = (AbstractLogicalOperator) child;
+					}
+				}
+				if (childOp.getOperatorTag() == LogicalOperatorTag.ORDER)
+					reviseExchange(childOp);
+			}
+			return true;
+		}
+		return false;
+	}
 
-    private void reviseExchange(AbstractLogicalOperator op) {
-        ExchangeOperator exchange = (ExchangeOperator) op.getInputs().get(0).getValue();
-        IPhysicalOperator physicalOp = exchange.getPhysicalOperator();
-        if (physicalOp.getOperatorTag() == PhysicalOperatorTag.HASH_PARTITION_EXCHANGE) {
-            exchange.setPhysicalOperator(new OneToOneExchangePOperator());
-        }
-    }
+	private void reviseExchange(AbstractLogicalOperator op) {
+		ExchangeOperator exchange = (ExchangeOperator) op.getInputs().get(0)
+				.getValue();
+		IPhysicalOperator physicalOp = exchange.getPhysicalOperator();
+		if (physicalOp.getOperatorTag() == PhysicalOperatorTag.HASH_PARTITION_EXCHANGE) {
+			exchange.setPhysicalOperator(new OneToOneExchangePOperator());
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/RemoveRedundantSelectRule.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/RemoveRedundantSelectRule.java
index 44ff12d..9958ba8 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/RemoveRedundantSelectRule.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/optimizer/rules/RemoveRedundantSelectRule.java
@@ -13,32 +13,34 @@
 
 public class RemoveRedundantSelectRule implements IAlgebraicRewriteRule {
 
-    @Override
-    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
-        return false;
-    }
+	@Override
+	public boolean rewritePre(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		return false;
+	}
 
-    @Override
-    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
-            throws AlgebricksException {
-        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
-        if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
-            return false;
-        }
-        AbstractLogicalOperator inputOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
-        if (inputOp.getOperatorTag() != LogicalOperatorTag.SELECT) {
-            return false;
-        }
-        SelectOperator selectOp = (SelectOperator) op;
-        SelectOperator inputSelectOp = (SelectOperator) inputOp;
-        ILogicalExpression expr1 = selectOp.getCondition().getValue();
-        ILogicalExpression expr2 = inputSelectOp.getCondition().getValue();
+	@Override
+	public boolean rewritePost(Mutable<ILogicalOperator> opRef,
+			IOptimizationContext context) throws AlgebricksException {
+		AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+		if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
+			return false;
+		}
+		AbstractLogicalOperator inputOp = (AbstractLogicalOperator) op
+				.getInputs().get(0).getValue();
+		if (inputOp.getOperatorTag() != LogicalOperatorTag.SELECT) {
+			return false;
+		}
+		SelectOperator selectOp = (SelectOperator) op;
+		SelectOperator inputSelectOp = (SelectOperator) inputOp;
+		ILogicalExpression expr1 = selectOp.getCondition().getValue();
+		ILogicalExpression expr2 = inputSelectOp.getCondition().getValue();
 
-        if (expr1.equals(expr2)) {
-            selectOp.getInputs().set(0, inputSelectOp.getInputs().get(0));
-            return true;
-        }
-        return false;
-    }
+		if (expr1.equals(expr2)) {
+			selectOp.getInputs().set(0, inputSelectOp.getInputs().get(0));
+			return true;
+		}
+		return false;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/config/ConfUtil.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/config/ConfUtil.java
index 10596b6..35d3b11 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/config/ConfUtil.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/config/ConfUtil.java
@@ -21,118 +21,123 @@
 

 public class ConfUtil {

 

-    private static JobConf job;

-    private static HiveConf hconf;

-    private static String[] NCs;

-    private static Map<String, List<String>> ncMapping;

-    private static IHyracksClientConnection hcc = null;

-    private static ClusterTopology topology = null;

+	private static JobConf job;

+	private static HiveConf hconf;

+	private static String[] NCs;

+	private static Map<String, List<String>> ncMapping;

+	private static IHyracksClientConnection hcc = null;

+	private static ClusterTopology topology = null;

 

-    public static JobConf getJobConf(Class<? extends InputFormat> format, Path path) {

-        JobConf conf = new JobConf();

-        if (job != null)

-            conf = job;

+	public static JobConf getJobConf(Class<? extends InputFormat> format,

+			Path path) {

+		JobConf conf = new JobConf();

+		if (job != null)

+			conf = job;

 

-        String hadoopPath = System.getProperty("HADOOP_HOME", "/hadoop");

-        Path pathCore = new Path(hadoopPath + "/conf/core-site.xml");

-        conf.addResource(pathCore);

-        Path pathMapRed = new Path(hadoopPath + "/conf/mapred-site.xml");

-        conf.addResource(pathMapRed);

-        Path pathHDFS = new Path(hadoopPath + "/conf/hdfs-site.xml");

-        conf.addResource(pathHDFS);

+		String hadoopPath = System.getProperty("HADOOP_HOME", "/hadoop");

+		Path pathCore = new Path(hadoopPath + "/conf/core-site.xml");

+		conf.addResource(pathCore);

+		Path pathMapRed = new Path(hadoopPath + "/conf/mapred-site.xml");

+		conf.addResource(pathMapRed);

+		Path pathHDFS = new Path(hadoopPath + "/conf/hdfs-site.xml");

+		conf.addResource(pathHDFS);

 

-        conf.setInputFormat(format);

-        FileInputFormat.setInputPaths(conf, path);

-        return conf;

-    }

+		conf.setInputFormat(format);

+		FileInputFormat.setInputPaths(conf, path);

+		return conf;

+	}

 

-    public static JobConf getJobConf() {

-        JobConf conf = new JobConf();

-        if (job != null)

-            conf = job;

+	public static JobConf getJobConf() {

+		JobConf conf = new JobConf();

+		if (job != null)

+			conf = job;

 

-        String hadoopPath = System.getProperty("HADOOP_HOME", "/hadoop");

-        Path pathCore = new Path(hadoopPath + "/conf/core-site.xml");

-        conf.addResource(pathCore);

-        Path pathMapRed = new Path(hadoopPath + "/conf/mapred-site.xml");

-        conf.addResource(pathMapRed);

-        Path pathHDFS = new Path(hadoopPath + "/conf/hdfs-site.xml");

-        conf.addResource(pathHDFS);

+		String hadoopPath = System.getProperty("HADOOP_HOME", "/hadoop");

+		Path pathCore = new Path(hadoopPath + "/conf/core-site.xml");

+		conf.addResource(pathCore);

+		Path pathMapRed = new Path(hadoopPath + "/conf/mapred-site.xml");

+		conf.addResource(pathMapRed);

+		Path pathHDFS = new Path(hadoopPath + "/conf/hdfs-site.xml");

+		conf.addResource(pathHDFS);

 

-        return conf;

-    }

+		return conf;

+	}

 

-    public static void setJobConf(JobConf conf) {

-        job = conf;

-    }

+	public static void setJobConf(JobConf conf) {

+		job = conf;

+	}

 

-    public static void setHiveConf(HiveConf hiveConf) {

-        hconf = hiveConf;

-    }

+	public static void setHiveConf(HiveConf hiveConf) {

+		hconf = hiveConf;

+	}

 

-    public static HiveConf getHiveConf() {

-        if (hconf == null) {

-            hconf = new HiveConf(SessionState.class);

-            hconf.addResource(new Path("conf/hive-default.xml"));

-        }

-        return hconf;

-    }

+	public static HiveConf getHiveConf() {

+		if (hconf == null) {

+			hconf = new HiveConf(SessionState.class);

+			hconf.addResource(new Path("conf/hive-default.xml"));

+		}

+		return hconf;

+	}

 

-    public static String[] getNCs() throws AlgebricksException {

-        if (NCs == null) {

-            try {

-                loadClusterConfig();

-            } catch (Exception e) {

-                throw new AlgebricksException(e);

-            }

-        }

-        return NCs;

-    }

+	public static String[] getNCs() throws AlgebricksException {

+		if (NCs == null) {

+			try {

+				loadClusterConfig();

+			} catch (Exception e) {

+				throw new AlgebricksException(e);

+			}

+		}

+		return NCs;

+	}

 

-    public static Map<String, List<String>> getNCMapping() throws AlgebricksException {

-        if (ncMapping == null) {

-            try {

-                loadClusterConfig();

-            } catch (Exception e) {

-                throw new AlgebricksException(e);

-            }

-        }

-        return ncMapping;

-    }

+	public static Map<String, List<String>> getNCMapping()

+			throws AlgebricksException {

+		if (ncMapping == null) {

+			try {

+				loadClusterConfig();

+			} catch (Exception e) {

+				throw new AlgebricksException(e);

+			}

+		}

+		return ncMapping;

+	}

 

-    private static void loadClusterConfig() {

-        try {

-            getHiveConf();

-            String ipAddress = hconf.get("hive.hyracks.host");

-            int port = Integer.parseInt(hconf.get("hive.hyracks.port"));

-            int mpl = Integer.parseInt(hconf.get("hive.hyracks.parrallelism"));

-            hcc = new HyracksConnection(ipAddress, port);

-            topology = hcc.getClusterTopology();

-            Map<String, NodeControllerInfo> ncNameToNcInfos = hcc.getNodeControllerInfos();

-            NCs = new String[ncNameToNcInfos.size() * mpl];

-            ncMapping = new HashMap<String, List<String>>();

-            int i = 0;

-            for (Map.Entry<String, NodeControllerInfo> entry : ncNameToNcInfos.entrySet()) {

-                String ipAddr = InetAddress.getByAddress(entry.getValue().getNetworkAddress().getIpAddress())

-                        .getHostAddress();

-                List<String> matchedNCs = ncMapping.get(ipAddr);

-                if (matchedNCs == null) {

-                    matchedNCs = new ArrayList<String>();

-                    ncMapping.put(ipAddr, matchedNCs);

-                }

-                matchedNCs.add(entry.getKey());

-                for (int j = i * mpl; j < i * mpl + mpl; j++)

-                    NCs[j] = entry.getKey();

-                i++;

-            }

-        } catch (Exception e) {

-            throw new IllegalStateException(e);

-        }

-    }

+	private static void loadClusterConfig() {

+		try {

+			getHiveConf();

+			String ipAddress = hconf.get("hive.hyracks.host");

+			int port = Integer.parseInt(hconf.get("hive.hyracks.port"));

+			int mpl = Integer.parseInt(hconf.get("hive.hyracks.parrallelism"));

+			hcc = new HyracksConnection(ipAddress, port);

+			topology = hcc.getClusterTopology();

+			Map<String, NodeControllerInfo> ncNameToNcInfos = hcc

+					.getNodeControllerInfos();

+			NCs = new String[ncNameToNcInfos.size() * mpl];

+			ncMapping = new HashMap<String, List<String>>();

+			int i = 0;

+			for (Map.Entry<String, NodeControllerInfo> entry : ncNameToNcInfos

+					.entrySet()) {

+				String ipAddr = InetAddress.getByAddress(

+						entry.getValue().getNetworkAddress().getIpAddress())

+						.getHostAddress();

+				List<String> matchedNCs = ncMapping.get(ipAddr);

+				if (matchedNCs == null) {

+					matchedNCs = new ArrayList<String>();

+					ncMapping.put(ipAddr, matchedNCs);

+				}

+				matchedNCs.add(entry.getKey());

+				for (int j = i * mpl; j < i * mpl + mpl; j++)

+					NCs[j] = entry.getKey();

+				i++;

+			}

+		} catch (Exception e) {

+			throw new IllegalStateException(e);

+		}

+	}

 

-    public static ClusterTopology getClusterTopology() {

-        if (topology == null)

-            loadClusterConfig();

-        return topology;

-    }

+	public static ClusterTopology getClusterTopology() {

+		if (topology == null)

+			loadClusterConfig();

+		return topology;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AbstractExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AbstractExpressionEvaluator.java
index ad02239..8f6d9ca 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AbstractExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AbstractExpressionEvaluator.java
@@ -22,148 +22,153 @@
 

 public abstract class AbstractExpressionEvaluator implements ICopyEvaluator {

 

-    private List<ICopyEvaluator> children;

+	private List<ICopyEvaluator> children;

 

-    private ExprNodeEvaluator evaluator;

+	private ExprNodeEvaluator evaluator;

 

-    private IDataOutputProvider out;

+	private IDataOutputProvider out;

 

-    private ObjectInspector inspector;

+	private ObjectInspector inspector;

 

-    /**

-     * output object inspector

-     */

-    private ObjectInspector outputInspector;

+	/**

+	 * output object inspector

+	 */

+	private ObjectInspector outputInspector;

 

-    /**

-     * cached row object

-     */

-    private LazyObject<? extends ObjectInspector> cachedRowObject;

+	/**

+	 * cached row object

+	 */

+	private LazyObject<? extends ObjectInspector> cachedRowObject;

 

-    /**

-     * serializer/derialzer for lazy object

-     */

-    private SerDe lazySer;

+	/**

+	 * serializer/derialzer for lazy object

+	 */

+	private SerDe lazySer;

 

-    /**

-     * data output

-     */

-    DataOutput dataOutput;

+	/**

+	 * data output

+	 */

+	DataOutput dataOutput;

 

-    public AbstractExpressionEvaluator(ExprNodeEvaluator hiveEvaluator, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        evaluator = hiveEvaluator;

-        out = output;

-        inspector = oi;

-        dataOutput = out.getDataOutput();

-    }

+	public AbstractExpressionEvaluator(ExprNodeEvaluator hiveEvaluator,

+			ObjectInspector oi, IDataOutputProvider output)

+			throws AlgebricksException {

+		evaluator = hiveEvaluator;

+		out = output;

+		inspector = oi;

+		dataOutput = out.getDataOutput();

+	}

 

-    protected ObjectInspector getRowInspector() {

-        return null;

-    }

+	protected ObjectInspector getRowInspector() {

+		return null;

+	}

 

-    protected IDataOutputProvider getIDataOutputProvider() {

-        return out;

-    }

+	protected IDataOutputProvider getIDataOutputProvider() {

+		return out;

+	}

 

-    protected ExprNodeEvaluator getHiveEvaluator() {

-        return evaluator;

-    }

+	protected ExprNodeEvaluator getHiveEvaluator() {

+		return evaluator;

+	}

 

-    public ObjectInspector getObjectInspector() {

-        return inspector;

-    }

+	public ObjectInspector getObjectInspector() {

+		return inspector;

+	}

 

-    @Override

-    public void evaluate(IFrameTupleReference r) throws AlgebricksException {

-        // initialize hive evaluator

-        try {

-            if (outputInspector == null)

-                outputInspector = evaluator.initialize(inspector);

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e.getMessage());

-        }

+	@Override

+	public void evaluate(IFrameTupleReference r) throws AlgebricksException {

+		// initialize hive evaluator

+		try {

+			if (outputInspector == null)

+				outputInspector = evaluator.initialize(inspector);

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e.getMessage());

+		}

 

-        readIntoCache(r);

-        try {

-            Object result = evaluator.evaluate(cachedRowObject);

+		readIntoCache(r);

+		try {

+			Object result = evaluator.evaluate(cachedRowObject);

 

-            // if (result == null) {

-            // result = evaluator.evaluate(cachedRowObject);

-            //

-            // // check if result is null

-            //

-            // String errorMsg = "serialize null object in  \n output " +

-            // outputInspector.toString() + " \n input "

-            // + inspector.toString() + "\n ";

-            // errorMsg += "";

-            // List<Object> columns = ((StructObjectInspector)

-            // inspector).getStructFieldsDataAsList(cachedRowObject);

-            // for (Object column : columns) {

-            // errorMsg += column.toString() + " ";

-            // }

-            // errorMsg += "\n";

-            // Log.info(errorMsg);

-            // System.out.println(errorMsg);

-            // // result = new BooleanWritable(true);

-            // throw new IllegalStateException(errorMsg);

-            // }

+			// if (result == null) {

+			// result = evaluator.evaluate(cachedRowObject);

+			//

+			// // check if result is null

+			//

+			// String errorMsg = "serialize null object in  \n output " +

+			// outputInspector.toString() + " \n input "

+			// + inspector.toString() + "\n ";

+			// errorMsg += "";

+			// List<Object> columns = ((StructObjectInspector)

+			// inspector).getStructFieldsDataAsList(cachedRowObject);

+			// for (Object column : columns) {

+			// errorMsg += column.toString() + " ";

+			// }

+			// errorMsg += "\n";

+			// Log.info(errorMsg);

+			// System.out.println(errorMsg);

+			// // result = new BooleanWritable(true);

+			// throw new IllegalStateException(errorMsg);

+			// }

 

-            serializeResult(result);

-        } catch (HiveException e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e.getMessage());

-        } catch (IOException e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e.getMessage());

-        }

-    }

+			serializeResult(result);

+		} catch (HiveException e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e.getMessage());

+		} catch (IOException e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e.getMessage());

+		}

+	}

 

-    /**

-     * serialize the result

-     * 

-     * @param result

-     *            the evaluation result

-     * @throws IOException

-     * @throws AlgebricksException

-     */

-    private void serializeResult(Object result) throws IOException, AlgebricksException {

-        if (lazySer == null)

-            lazySer = new LazySerDe();

+	/**

+	 * serialize the result

+	 * 

+	 * @param result

+	 *            the evaluation result

+	 * @throws IOException

+	 * @throws AlgebricksException

+	 */

+	private void serializeResult(Object result) throws IOException,

+			AlgebricksException {

+		if (lazySer == null)

+			lazySer = new LazySerDe();

 

-        try {

-            BytesWritable outputWritable = (BytesWritable) lazySer.serialize(result, outputInspector);

-            dataOutput.write(outputWritable.getBytes(), 0, outputWritable.getLength());

-        } catch (SerDeException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+		try {

+			BytesWritable outputWritable = (BytesWritable) lazySer.serialize(

+					result, outputInspector);

+			dataOutput.write(outputWritable.getBytes(), 0,

+					outputWritable.getLength());

+		} catch (SerDeException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    /**

-     * bind the tuple reference to the cached row object

-     * 

-     * @param r

-     */

-    private void readIntoCache(IFrameTupleReference r) {

-        if (cachedRowObject == null)

-            cachedRowObject = (LazyObject<? extends ObjectInspector>) LazyFactory.createLazyObject(inspector);

-        cachedRowObject.init(r);

-    }

+	/**

+	 * bind the tuple reference to the cached row object

+	 * 

+	 * @param r

+	 */

+	private void readIntoCache(IFrameTupleReference r) {

+		if (cachedRowObject == null)

+			cachedRowObject = (LazyObject<? extends ObjectInspector>) LazyFactory

+					.createLazyObject(inspector);

+		cachedRowObject.init(r);

+	}

 

-    /**

-     * set a list of children of this evaluator

-     * 

-     * @param children

-     */

-    public void setChildren(List<ICopyEvaluator> children) {

-        this.children = children;

-    }

+	/**

+	 * set a list of children of this evaluator

+	 * 

+	 * @param children

+	 */

+	public void setChildren(List<ICopyEvaluator> children) {

+		this.children = children;

+	}

 

-    public void addChild(ICopyEvaluator child) {

-        if (children == null)

-            children = new ArrayList<ICopyEvaluator>();

-        children.add(child);

-    }

+	public void addChild(ICopyEvaluator child) {

+		if (children == null)

+			children = new ArrayList<ICopyEvaluator>();

+		children.add(child);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregationFunctionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregationFunctionEvaluator.java
index e500376..271b5e4 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregationFunctionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregationFunctionEvaluator.java
@@ -24,201 +24,208 @@
 

 public class AggregationFunctionEvaluator implements ICopyAggregateFunction {

 

-    /**

-     * the mode of aggregation function

-     */

-    private GenericUDAFEvaluator.Mode mode;

+	/**

+	 * the mode of aggregation function

+	 */

+	private GenericUDAFEvaluator.Mode mode;

 

-    /**

-     * an array of evaluators

-     */

-    private ExprNodeEvaluator[] evaluators;

+	/**

+	 * an array of evaluators

+	 */

+	private ExprNodeEvaluator[] evaluators;

 

-    /**

-     * udaf evaluator partial

-     */

-    private GenericUDAFEvaluator udafPartial;

+	/**

+	 * udaf evaluator partial

+	 */

+	private GenericUDAFEvaluator udafPartial;

 

-    /**

-     * udaf evaluator complete

-     */

-    private GenericUDAFEvaluator udafComplete;

+	/**

+	 * udaf evaluator complete

+	 */

+	private GenericUDAFEvaluator udafComplete;

 

-    /**

-     * cached parameter objects

-     */

-    private Object[] cachedParameters;

+	/**

+	 * cached parameter objects

+	 */

+	private Object[] cachedParameters;

 

-    /**

-     * cached row objects

-     */

-    private LazyObject<? extends ObjectInspector> cachedRowObject;

+	/**

+	 * cached row objects

+	 */

+	private LazyObject<? extends ObjectInspector> cachedRowObject;

 

-    /**

-     * the output channel

-     */

-    private DataOutput out;

+	/**

+	 * the output channel

+	 */

+	private DataOutput out;

 

-    /**

-     * aggregation buffer

-     */

-    private AggregationBuffer aggBuffer;

+	/**

+	 * aggregation buffer

+	 */

+	private AggregationBuffer aggBuffer;

 

-    /**

-     * we only use lazy serde to do serialization

-     */

-    private SerDe lazySer;

+	/**

+	 * we only use lazy serde to do serialization

+	 */

+	private SerDe lazySer;

 

-    /**

-     * the output object inspector for this aggregation function

-     */

-    private ObjectInspector outputInspector;

+	/**

+	 * the output object inspector for this aggregation function

+	 */

+	private ObjectInspector outputInspector;

 

-    /**

-     * the output object inspector for this aggregation function

-     */

-    private ObjectInspector outputInspectorPartial;

+	/**

+	 * the output object inspector for this aggregation function

+	 */

+	private ObjectInspector outputInspectorPartial;

 

-    /**

-     * parameter inspectors

-     */

-    private ObjectInspector[] parameterInspectors;

+	/**

+	 * parameter inspectors

+	 */

+	private ObjectInspector[] parameterInspectors;

 

-    /**

-     * output make sure the aggregation functio has least object creation

-     * 

-     * @param desc

-     * @param oi

-     * @param output

-     */

-    public AggregationFunctionEvaluator(List<ExprNodeDesc> inputs, List<TypeInfo> inputTypes, String genericUDAFName,

-            GenericUDAFEvaluator.Mode aggMode, boolean distinct, ObjectInspector oi, DataOutput output,

-            ExprNodeEvaluator[] evals, ObjectInspector[] pInspectors, Object[] parameterCache, SerDe serde,

-            LazyObject<? extends ObjectInspector> row, GenericUDAFEvaluator udafunctionPartial,

-            GenericUDAFEvaluator udafunctionComplete, ObjectInspector outputOi, ObjectInspector outputOiPartial) {

-        // shared object across threads

-        this.out = output;

-        this.mode = aggMode;

-        this.parameterInspectors = pInspectors;

+	/**

+	 * output make sure the aggregation functio has least object creation

+	 * 

+	 * @param desc

+	 * @param oi

+	 * @param output

+	 */

+	public AggregationFunctionEvaluator(List<ExprNodeDesc> inputs,

+			List<TypeInfo> inputTypes, String genericUDAFName,

+			GenericUDAFEvaluator.Mode aggMode, boolean distinct,

+			ObjectInspector oi, DataOutput output, ExprNodeEvaluator[] evals,

+			ObjectInspector[] pInspectors, Object[] parameterCache,

+			SerDe serde, LazyObject<? extends ObjectInspector> row,

+			GenericUDAFEvaluator udafunctionPartial,

+			GenericUDAFEvaluator udafunctionComplete, ObjectInspector outputOi,

+			ObjectInspector outputOiPartial) {

+		// shared object across threads

+		this.out = output;

+		this.mode = aggMode;

+		this.parameterInspectors = pInspectors;

 

-        // thread local objects

-        this.evaluators = evals;

-        this.cachedParameters = parameterCache;

-        this.cachedRowObject = row;

-        this.lazySer = serde;

-        this.udafPartial = udafunctionPartial;

-        this.udafComplete = udafunctionComplete;

-        this.outputInspector = outputOi;

-        this.outputInspectorPartial = outputOiPartial;

-    }

+		// thread local objects

+		this.evaluators = evals;

+		this.cachedParameters = parameterCache;

+		this.cachedRowObject = row;

+		this.lazySer = serde;

+		this.udafPartial = udafunctionPartial;

+		this.udafComplete = udafunctionComplete;

+		this.outputInspector = outputOi;

+		this.outputInspectorPartial = outputOiPartial;

+	}

 

-    @Override

-    public void init() throws AlgebricksException {

-        try {

-            aggBuffer = udafPartial.getNewAggregationBuffer();

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	@Override

+	public void init() throws AlgebricksException {

+		try {

+			aggBuffer = udafPartial.getNewAggregationBuffer();

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    @Override

-    public void step(IFrameTupleReference tuple) throws AlgebricksException {

-        readIntoCache(tuple);

-        processRow();

-    }

+	@Override

+	public void step(IFrameTupleReference tuple) throws AlgebricksException {

+		readIntoCache(tuple);

+		processRow();

+	}

 

-    private void processRow() throws AlgebricksException {

-        try {

-            // get values by evaluating them

-            for (int i = 0; i < cachedParameters.length; i++) {

-                cachedParameters[i] = evaluators[i].evaluate(cachedRowObject);

-            }

-            processAggregate();

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	private void processRow() throws AlgebricksException {

+		try {

+			// get values by evaluating them

+			for (int i = 0; i < cachedParameters.length; i++) {

+				cachedParameters[i] = evaluators[i].evaluate(cachedRowObject);

+			}

+			processAggregate();

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    private void processAggregate() throws HiveException {

-        /**

-         * accumulate the aggregation function

-         */

-        switch (mode) {

-            case PARTIAL1:

-            case COMPLETE:

-                udafPartial.iterate(aggBuffer, cachedParameters);

-                break;

-            case PARTIAL2:

-            case FINAL:

-                if (udafPartial instanceof GenericUDAFCount.GenericUDAFCountEvaluator) {

-                    Object parameter = ((PrimitiveObjectInspector) parameterInspectors[0])

-                            .getPrimitiveWritableObject(cachedParameters[0]);

-                    udafPartial.merge(aggBuffer, parameter);

-                } else

-                    udafPartial.merge(aggBuffer, cachedParameters[0]);

-                break;

-            default:

-                break;

-        }

-    }

+	private void processAggregate() throws HiveException {

+		/**

+		 * accumulate the aggregation function

+		 */

+		switch (mode) {

+		case PARTIAL1:

+		case COMPLETE:

+			udafPartial.iterate(aggBuffer, cachedParameters);

+			break;

+		case PARTIAL2:

+		case FINAL:

+			if (udafPartial instanceof GenericUDAFCount.GenericUDAFCountEvaluator) {

+				Object parameter = ((PrimitiveObjectInspector) parameterInspectors[0])

+						.getPrimitiveWritableObject(cachedParameters[0]);

+				udafPartial.merge(aggBuffer, parameter);

+			} else

+				udafPartial.merge(aggBuffer, cachedParameters[0]);

+			break;

+		default:

+			break;

+		}

+	}

 

-    /**

-     * serialize the result

-     * 

-     * @param result

-     *            the evaluation result

-     * @throws IOException

-     * @throws AlgebricksException

-     */

-    private void serializeResult(Object result, ObjectInspector oi) throws IOException, AlgebricksException {

-        try {

-            BytesWritable outputWritable = (BytesWritable) lazySer.serialize(result, oi);

-            out.write(outputWritable.getBytes(), 0, outputWritable.getLength());

-        } catch (SerDeException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	/**

+	 * serialize the result

+	 * 

+	 * @param result

+	 *            the evaluation result

+	 * @throws IOException

+	 * @throws AlgebricksException

+	 */

+	private void serializeResult(Object result, ObjectInspector oi)

+			throws IOException, AlgebricksException {

+		try {

+			BytesWritable outputWritable = (BytesWritable) lazySer.serialize(

+					result, oi);

+			out.write(outputWritable.getBytes(), 0, outputWritable.getLength());

+		} catch (SerDeException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    /**

-     * bind the tuple reference to the cached row object

-     * 

-     * @param r

-     */

-    private void readIntoCache(IFrameTupleReference r) {

-        cachedRowObject.init(r);

-    }

+	/**

+	 * bind the tuple reference to the cached row object

+	 * 

+	 * @param r

+	 */

+	private void readIntoCache(IFrameTupleReference r) {

+		cachedRowObject.init(r);

+	}

 

-    @Override

-    public void finish() throws AlgebricksException {

-        // aggregator

-        try {

-            Object result = null;

-            result = udafPartial.terminatePartial(aggBuffer);

-            if (mode == GenericUDAFEvaluator.Mode.COMPLETE || mode == GenericUDAFEvaluator.Mode.FINAL) {

-                result = udafComplete.terminate(aggBuffer);

-                serializeResult(result, outputInspector);

-            } else {

-                serializeResult(result, outputInspectorPartial);

-            }

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        } catch (IOException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	@Override

+	public void finish() throws AlgebricksException {

+		// aggregator

+		try {

+			Object result = null;

+			result = udafPartial.terminatePartial(aggBuffer);

+			if (mode == GenericUDAFEvaluator.Mode.COMPLETE

+					|| mode == GenericUDAFEvaluator.Mode.FINAL) {

+				result = udafComplete.terminate(aggBuffer);

+				serializeResult(result, outputInspector);

+			} else {

+				serializeResult(result, outputInspectorPartial);

+			}

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		} catch (IOException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    @Override

-    public void finishPartial() throws AlgebricksException {

-        // aggregator.

-        try {

-            Object result = null;

-            // get aggregations

-            result = udafPartial.terminatePartial(aggBuffer);

-            serializeResult(result, outputInspectorPartial);

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        } catch (IOException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	@Override

+	public void finishPartial() throws AlgebricksException {

+		// aggregator.

+		try {

+			Object result = null;

+			// get aggregations

+			result = udafPartial.terminatePartial(aggBuffer);

+			serializeResult(result, outputInspectorPartial);

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		} catch (IOException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregatuibFunctionSerializableEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregatuibFunctionSerializableEvaluator.java
index 1933253..032437b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregatuibFunctionSerializableEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/AggregatuibFunctionSerializableEvaluator.java
@@ -21,228 +21,239 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopySerializableAggregateFunction;
 import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 
-public class AggregatuibFunctionSerializableEvaluator implements ICopySerializableAggregateFunction {
+public class AggregatuibFunctionSerializableEvaluator implements
+		ICopySerializableAggregateFunction {
 
-    /**
-     * the mode of aggregation function
-     */
-    private GenericUDAFEvaluator.Mode mode;
+	/**
+	 * the mode of aggregation function
+	 */
+	private GenericUDAFEvaluator.Mode mode;
 
-    /**
-     * an array of evaluators
-     */
-    private ExprNodeEvaluator[] evaluators;
+	/**
+	 * an array of evaluators
+	 */
+	private ExprNodeEvaluator[] evaluators;
 
-    /**
-     * udaf evaluator partial
-     */
-    private GenericUDAFEvaluator udafPartial;
+	/**
+	 * udaf evaluator partial
+	 */
+	private GenericUDAFEvaluator udafPartial;
 
-    /**
-     * udaf evaluator complete
-     */
-    private GenericUDAFEvaluator udafComplete;
+	/**
+	 * udaf evaluator complete
+	 */
+	private GenericUDAFEvaluator udafComplete;
 
-    /**
-     * cached parameter objects
-     */
-    private Object[] cachedParameters;
+	/**
+	 * cached parameter objects
+	 */
+	private Object[] cachedParameters;
 
-    /**
-     * cached row objects
-     */
-    private LazyObject<? extends ObjectInspector> cachedRowObject;
+	/**
+	 * cached row objects
+	 */
+	private LazyObject<? extends ObjectInspector> cachedRowObject;
 
-    /**
-     * aggregation buffer
-     */
-    private SerializableBuffer aggBuffer;
+	/**
+	 * aggregation buffer
+	 */
+	private SerializableBuffer aggBuffer;
 
-    /**
-     * we only use lazy serde to do serialization
-     */
-    private SerDe lazySer;
+	/**
+	 * we only use lazy serde to do serialization
+	 */
+	private SerDe lazySer;
 
-    /**
-     * the output object inspector for this aggregation function
-     */
-    private ObjectInspector outputInspector;
+	/**
+	 * the output object inspector for this aggregation function
+	 */
+	private ObjectInspector outputInspector;
 
-    /**
-     * the output object inspector for this aggregation function
-     */
-    private ObjectInspector outputInspectorPartial;
+	/**
+	 * the output object inspector for this aggregation function
+	 */
+	private ObjectInspector outputInspectorPartial;
 
-    /**
-     * parameter inspectors
-     */
-    private ObjectInspector[] parameterInspectors;
+	/**
+	 * parameter inspectors
+	 */
+	private ObjectInspector[] parameterInspectors;
 
-    /**
-     * output make sure the aggregation functio has least object creation
-     * 
-     * @param desc
-     * @param oi
-     * @param output
-     */
-    public AggregatuibFunctionSerializableEvaluator(List<ExprNodeDesc> inputs, List<TypeInfo> inputTypes,
-            String genericUDAFName, GenericUDAFEvaluator.Mode aggMode, boolean distinct, ObjectInspector oi,
-            ExprNodeEvaluator[] evals, ObjectInspector[] pInspectors, Object[] parameterCache, SerDe serde,
-            LazyObject<? extends ObjectInspector> row, GenericUDAFEvaluator udafunctionPartial,
-            GenericUDAFEvaluator udafunctionComplete, ObjectInspector outputOi, ObjectInspector outputOiPartial)
-            throws AlgebricksException {
-        // shared object across threads
-        this.mode = aggMode;
-        this.parameterInspectors = pInspectors;
+	/**
+	 * output make sure the aggregation functio has least object creation
+	 * 
+	 * @param desc
+	 * @param oi
+	 * @param output
+	 */
+	public AggregatuibFunctionSerializableEvaluator(List<ExprNodeDesc> inputs,
+			List<TypeInfo> inputTypes, String genericUDAFName,
+			GenericUDAFEvaluator.Mode aggMode, boolean distinct,
+			ObjectInspector oi, ExprNodeEvaluator[] evals,
+			ObjectInspector[] pInspectors, Object[] parameterCache,
+			SerDe serde, LazyObject<? extends ObjectInspector> row,
+			GenericUDAFEvaluator udafunctionPartial,
+			GenericUDAFEvaluator udafunctionComplete, ObjectInspector outputOi,
+			ObjectInspector outputOiPartial) throws AlgebricksException {
+		// shared object across threads
+		this.mode = aggMode;
+		this.parameterInspectors = pInspectors;
 
-        // thread local objects
-        this.evaluators = evals;
-        this.cachedParameters = parameterCache;
-        this.cachedRowObject = row;
-        this.lazySer = serde;
-        this.udafPartial = udafunctionPartial;
-        this.udafComplete = udafunctionComplete;
-        this.outputInspector = outputOi;
-        this.outputInspectorPartial = outputOiPartial;
+		// thread local objects
+		this.evaluators = evals;
+		this.cachedParameters = parameterCache;
+		this.cachedRowObject = row;
+		this.lazySer = serde;
+		this.udafPartial = udafunctionPartial;
+		this.udafComplete = udafunctionComplete;
+		this.outputInspector = outputOi;
+		this.outputInspectorPartial = outputOiPartial;
 
-        try {
-            aggBuffer = (SerializableBuffer) udafPartial.getNewAggregationBuffer();
-        } catch (HiveException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+		try {
+			aggBuffer = (SerializableBuffer) udafPartial
+					.getNewAggregationBuffer();
+		} catch (HiveException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    @Override
-    public void init(DataOutput output) throws AlgebricksException {
-        try {
-            udafPartial.reset(aggBuffer);
-            outputAggBuffer(aggBuffer, output);
-        } catch (HiveException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	@Override
+	public void init(DataOutput output) throws AlgebricksException {
+		try {
+			udafPartial.reset(aggBuffer);
+			outputAggBuffer(aggBuffer, output);
+		} catch (HiveException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    @Override
-    public void step(IFrameTupleReference tuple, byte[] data, int start, int len) throws AlgebricksException {
-        deSerializeAggBuffer(aggBuffer, data, start, len);
-        readIntoCache(tuple);
-        processRow();
-        serializeAggBuffer(aggBuffer, data, start, len);
-    }
+	@Override
+	public void step(IFrameTupleReference tuple, byte[] data, int start, int len)
+			throws AlgebricksException {
+		deSerializeAggBuffer(aggBuffer, data, start, len);
+		readIntoCache(tuple);
+		processRow();
+		serializeAggBuffer(aggBuffer, data, start, len);
+	}
 
-    private void processRow() throws AlgebricksException {
-        try {
-            // get values by evaluating them
-            for (int i = 0; i < cachedParameters.length; i++) {
-                cachedParameters[i] = evaluators[i].evaluate(cachedRowObject);
-            }
-            processAggregate();
-        } catch (HiveException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	private void processRow() throws AlgebricksException {
+		try {
+			// get values by evaluating them
+			for (int i = 0; i < cachedParameters.length; i++) {
+				cachedParameters[i] = evaluators[i].evaluate(cachedRowObject);
+			}
+			processAggregate();
+		} catch (HiveException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    private void processAggregate() throws HiveException {
-        /**
-         * accumulate the aggregation function
-         */
-        switch (mode) {
-            case PARTIAL1:
-            case COMPLETE:
-                udafPartial.iterate(aggBuffer, cachedParameters);
-                break;
-            case PARTIAL2:
-            case FINAL:
-                if (udafPartial instanceof GenericUDAFCount.GenericUDAFCountEvaluator) {
-                    Object parameter = ((PrimitiveObjectInspector) parameterInspectors[0])
-                            .getPrimitiveWritableObject(cachedParameters[0]);
-                    udafPartial.merge(aggBuffer, parameter);
-                } else
-                    udafPartial.merge(aggBuffer, cachedParameters[0]);
-                break;
-            default:
-                break;
-        }
-    }
+	private void processAggregate() throws HiveException {
+		/**
+		 * accumulate the aggregation function
+		 */
+		switch (mode) {
+		case PARTIAL1:
+		case COMPLETE:
+			udafPartial.iterate(aggBuffer, cachedParameters);
+			break;
+		case PARTIAL2:
+		case FINAL:
+			if (udafPartial instanceof GenericUDAFCount.GenericUDAFCountEvaluator) {
+				Object parameter = ((PrimitiveObjectInspector) parameterInspectors[0])
+						.getPrimitiveWritableObject(cachedParameters[0]);
+				udafPartial.merge(aggBuffer, parameter);
+			} else
+				udafPartial.merge(aggBuffer, cachedParameters[0]);
+			break;
+		default:
+			break;
+		}
+	}
 
-    /**
-     * serialize the result
-     * 
-     * @param result
-     *            the evaluation result
-     * @throws IOException
-     * @throws AlgebricksException
-     */
-    private void serializeResult(Object result, ObjectInspector oi, DataOutput out) throws IOException,
-            AlgebricksException {
-        try {
-            BytesWritable outputWritable = (BytesWritable) lazySer.serialize(result, oi);
-            out.write(outputWritable.getBytes(), 0, outputWritable.getLength());
-        } catch (SerDeException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	/**
+	 * serialize the result
+	 * 
+	 * @param result
+	 *            the evaluation result
+	 * @throws IOException
+	 * @throws AlgebricksException
+	 */
+	private void serializeResult(Object result, ObjectInspector oi,
+			DataOutput out) throws IOException, AlgebricksException {
+		try {
+			BytesWritable outputWritable = (BytesWritable) lazySer.serialize(
+					result, oi);
+			out.write(outputWritable.getBytes(), 0, outputWritable.getLength());
+		} catch (SerDeException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    /**
-     * bind the tuple reference to the cached row object
-     * 
-     * @param r
-     */
-    private void readIntoCache(IFrameTupleReference r) {
-        cachedRowObject.init(r);
-    }
+	/**
+	 * bind the tuple reference to the cached row object
+	 * 
+	 * @param r
+	 */
+	private void readIntoCache(IFrameTupleReference r) {
+		cachedRowObject.init(r);
+	}
 
-    @Override
-    public void finish(byte[] data, int start, int len, DataOutput output) throws AlgebricksException {
-        deSerializeAggBuffer(aggBuffer, data, start, len);
-        // aggregator
-        try {
-            Object result = null;
-            result = udafPartial.terminatePartial(aggBuffer);
-            if (mode == GenericUDAFEvaluator.Mode.COMPLETE || mode == GenericUDAFEvaluator.Mode.FINAL) {
-                result = udafComplete.terminate(aggBuffer);
-                serializeResult(result, outputInspector, output);
-            } else {
-                serializeResult(result, outputInspectorPartial, output);
-            }
-        } catch (HiveException e) {
-            throw new AlgebricksException(e);
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	@Override
+	public void finish(byte[] data, int start, int len, DataOutput output)
+			throws AlgebricksException {
+		deSerializeAggBuffer(aggBuffer, data, start, len);
+		// aggregator
+		try {
+			Object result = null;
+			result = udafPartial.terminatePartial(aggBuffer);
+			if (mode == GenericUDAFEvaluator.Mode.COMPLETE
+					|| mode == GenericUDAFEvaluator.Mode.FINAL) {
+				result = udafComplete.terminate(aggBuffer);
+				serializeResult(result, outputInspector, output);
+			} else {
+				serializeResult(result, outputInspectorPartial, output);
+			}
+		} catch (HiveException e) {
+			throw new AlgebricksException(e);
+		} catch (IOException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    @Override
-    public void finishPartial(byte[] data, int start, int len, DataOutput output) throws AlgebricksException {
-        deSerializeAggBuffer(aggBuffer, data, start, len);
-        // aggregator.
-        try {
-            Object result = null;
-            // get aggregations
-            result = udafPartial.terminatePartial(aggBuffer);
-            serializeResult(result, outputInspectorPartial, output);
-        } catch (HiveException e) {
-            throw new AlgebricksException(e);
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	@Override
+	public void finishPartial(byte[] data, int start, int len, DataOutput output)
+			throws AlgebricksException {
+		deSerializeAggBuffer(aggBuffer, data, start, len);
+		// aggregator.
+		try {
+			Object result = null;
+			// get aggregations
+			result = udafPartial.terminatePartial(aggBuffer);
+			serializeResult(result, outputInspectorPartial, output);
+		} catch (HiveException e) {
+			throw new AlgebricksException(e);
+		} catch (IOException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 
-    private void serializeAggBuffer(SerializableBuffer buffer, byte[] data, int start, int len)
-            throws AlgebricksException {
-        buffer.serializeAggBuffer(data, start, len);
-    }
+	private void serializeAggBuffer(SerializableBuffer buffer, byte[] data,
+			int start, int len) throws AlgebricksException {
+		buffer.serializeAggBuffer(data, start, len);
+	}
 
-    private void deSerializeAggBuffer(SerializableBuffer buffer, byte[] data, int start, int len)
-            throws AlgebricksException {
-        buffer.deSerializeAggBuffer(data, start, len);
-    }
+	private void deSerializeAggBuffer(SerializableBuffer buffer, byte[] data,
+			int start, int len) throws AlgebricksException {
+		buffer.deSerializeAggBuffer(data, start, len);
+	}
 
-    private void outputAggBuffer(SerializableBuffer buffer, DataOutput out) throws AlgebricksException {
-        try {
-            buffer.serializeAggBuffer(out);
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-    }
+	private void outputAggBuffer(SerializableBuffer buffer, DataOutput out)
+			throws AlgebricksException {
+		try {
+			buffer.serializeAggBuffer(out);
+		} catch (IOException e) {
+			throw new AlgebricksException(e);
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/BufferSerDeUtil.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/BufferSerDeUtil.java
index 96065e5..d73be93 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/BufferSerDeUtil.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/BufferSerDeUtil.java
@@ -2,66 +2,72 @@
 
 public class BufferSerDeUtil {
 
-    public static double getDouble(byte[] bytes, int offset) {
-        return Double.longBitsToDouble(getLong(bytes, offset));
-    }
+	public static double getDouble(byte[] bytes, int offset) {
+		return Double.longBitsToDouble(getLong(bytes, offset));
+	}
 
-    public static float getFloat(byte[] bytes, int offset) {
-        return Float.intBitsToFloat(getInt(bytes, offset));
-    }
+	public static float getFloat(byte[] bytes, int offset) {
+		return Float.intBitsToFloat(getInt(bytes, offset));
+	}
 
-    public static boolean getBoolean(byte[] bytes, int offset) {
-        if (bytes[offset] == 0)
-            return false;
-        else
-            return true;
-    }
+	public static boolean getBoolean(byte[] bytes, int offset) {
+		if (bytes[offset] == 0)
+			return false;
+		else
+			return true;
+	}
 
-    public static int getInt(byte[] bytes, int offset) {
-        return ((bytes[offset] & 0xff) << 24) + ((bytes[offset + 1] & 0xff) << 16) + ((bytes[offset + 2] & 0xff) << 8)
-                + ((bytes[offset + 3] & 0xff) << 0);
-    }
+	public static int getInt(byte[] bytes, int offset) {
+		return ((bytes[offset] & 0xff) << 24)
+				+ ((bytes[offset + 1] & 0xff) << 16)
+				+ ((bytes[offset + 2] & 0xff) << 8)
+				+ ((bytes[offset + 3] & 0xff) << 0);
+	}
 
-    public static long getLong(byte[] bytes, int offset) {
-        return (((long) (bytes[offset] & 0xff)) << 56) + (((long) (bytes[offset + 1] & 0xff)) << 48)
-                + (((long) (bytes[offset + 2] & 0xff)) << 40) + (((long) (bytes[offset + 3] & 0xff)) << 32)
-                + (((long) (bytes[offset + 4] & 0xff)) << 24) + (((long) (bytes[offset + 5] & 0xff)) << 16)
-                + (((long) (bytes[offset + 6] & 0xff)) << 8) + (((long) (bytes[offset + 7] & 0xff)) << 0);
-    }
+	public static long getLong(byte[] bytes, int offset) {
+		return (((long) (bytes[offset] & 0xff)) << 56)
+				+ (((long) (bytes[offset + 1] & 0xff)) << 48)
+				+ (((long) (bytes[offset + 2] & 0xff)) << 40)
+				+ (((long) (bytes[offset + 3] & 0xff)) << 32)
+				+ (((long) (bytes[offset + 4] & 0xff)) << 24)
+				+ (((long) (bytes[offset + 5] & 0xff)) << 16)
+				+ (((long) (bytes[offset + 6] & 0xff)) << 8)
+				+ (((long) (bytes[offset + 7] & 0xff)) << 0);
+	}
 
-    public static void writeBoolean(boolean value, byte[] bytes, int offset) {
-        if (value)
-            bytes[offset] = (byte) 1;
-        else
-            bytes[offset] = (byte) 0;
-    }
+	public static void writeBoolean(boolean value, byte[] bytes, int offset) {
+		if (value)
+			bytes[offset] = (byte) 1;
+		else
+			bytes[offset] = (byte) 0;
+	}
 
-    public static void writeInt(int value, byte[] bytes, int offset) {
-        bytes[offset++] = (byte) (value >> 24);
-        bytes[offset++] = (byte) (value >> 16);
-        bytes[offset++] = (byte) (value >> 8);
-        bytes[offset++] = (byte) (value);
-    }
+	public static void writeInt(int value, byte[] bytes, int offset) {
+		bytes[offset++] = (byte) (value >> 24);
+		bytes[offset++] = (byte) (value >> 16);
+		bytes[offset++] = (byte) (value >> 8);
+		bytes[offset++] = (byte) (value);
+	}
 
-    public static void writeLong(long value, byte[] bytes, int offset) {
-        bytes[offset++] = (byte) (value >> 56);
-        bytes[offset++] = (byte) (value >> 48);
-        bytes[offset++] = (byte) (value >> 40);
-        bytes[offset++] = (byte) (value >> 32);
-        bytes[offset++] = (byte) (value >> 24);
-        bytes[offset++] = (byte) (value >> 16);
-        bytes[offset++] = (byte) (value >> 8);
-        bytes[offset++] = (byte) (value);
-    }
+	public static void writeLong(long value, byte[] bytes, int offset) {
+		bytes[offset++] = (byte) (value >> 56);
+		bytes[offset++] = (byte) (value >> 48);
+		bytes[offset++] = (byte) (value >> 40);
+		bytes[offset++] = (byte) (value >> 32);
+		bytes[offset++] = (byte) (value >> 24);
+		bytes[offset++] = (byte) (value >> 16);
+		bytes[offset++] = (byte) (value >> 8);
+		bytes[offset++] = (byte) (value);
+	}
 
-    public static void writeDouble(double value, byte[] bytes, int offset) {
-        long lValue = Double.doubleToLongBits(value);
-        writeLong(lValue, bytes, offset);
-    }
+	public static void writeDouble(double value, byte[] bytes, int offset) {
+		long lValue = Double.doubleToLongBits(value);
+		writeLong(lValue, bytes, offset);
+	}
 
-    public static void writeFloat(float value, byte[] bytes, int offset) {
-        int iValue = Float.floatToIntBits(value);
-        writeInt(iValue, bytes, offset);
-    }
+	public static void writeFloat(float value, byte[] bytes, int offset) {
+		int iValue = Float.floatToIntBits(value);
+		writeInt(iValue, bytes, offset);
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ColumnExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ColumnExpressionEvaluator.java
index 5647f6a..3296e19 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ColumnExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ColumnExpressionEvaluator.java
@@ -9,9 +9,10 @@
 

 public class ColumnExpressionEvaluator extends AbstractExpressionEvaluator {

 

-    public ColumnExpressionEvaluator(ExprNodeColumnDesc expr, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        super(new ExprNodeColumnEvaluator(expr), oi, output);

-    }

+	public ColumnExpressionEvaluator(ExprNodeColumnDesc expr,

+			ObjectInspector oi, IDataOutputProvider output)

+			throws AlgebricksException {

+		super(new ExprNodeColumnEvaluator(expr), oi, output);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ConstantExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ConstantExpressionEvaluator.java
index d8796ea..62928e6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ConstantExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ConstantExpressionEvaluator.java
@@ -9,8 +9,9 @@
 

 public class ConstantExpressionEvaluator extends AbstractExpressionEvaluator {

 

-    public ConstantExpressionEvaluator(ExprNodeConstantDesc expr, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        super(new ExprNodeConstantEvaluator(expr), oi, output);

-    }

+	public ConstantExpressionEvaluator(ExprNodeConstantDesc expr,

+			ObjectInspector oi, IDataOutputProvider output)

+			throws AlgebricksException {

+		super(new ExprNodeConstantEvaluator(expr), oi, output);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ExpressionTranslator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ExpressionTranslator.java
index c40ef73..2180910 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ExpressionTranslator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/ExpressionTranslator.java
@@ -41,173 +41,193 @@
 

 public class ExpressionTranslator {

 

-    public static Object getHiveExpression(ILogicalExpression expr, IVariableTypeEnvironment env) throws Exception {

-        if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {

-            /**

-             * function expression

-             */

-            AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;

-            IFunctionInfo funcInfo = funcExpr.getFunctionInfo();

-            FunctionIdentifier fid = funcInfo.getFunctionIdentifier();

+	public static Object getHiveExpression(ILogicalExpression expr,

+			IVariableTypeEnvironment env) throws Exception {

+		if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {

+			/**

+			 * function expression

+			 */

+			AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;

+			IFunctionInfo funcInfo = funcExpr.getFunctionInfo();

+			FunctionIdentifier fid = funcInfo.getFunctionIdentifier();

 

-            if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

-                Object info = ((HiveFunctionInfo) funcInfo).getInfo();

-                ExprNodeFieldDesc desc = (ExprNodeFieldDesc) info;

-                return new ExprNodeFieldDesc(desc.getTypeInfo(), desc.getDesc(), desc.getFieldName(), desc.getIsList());

-            }

+			if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

+				Object info = ((HiveFunctionInfo) funcInfo).getInfo();

+				ExprNodeFieldDesc desc = (ExprNodeFieldDesc) info;

+				return new ExprNodeFieldDesc(desc.getTypeInfo(),

+						desc.getDesc(), desc.getFieldName(), desc.getIsList());

+			}

 

-            if (fid.getName().equals(ExpressionConstant.NULL)) {

-                return new ExprNodeNullDesc();

-            }

+			if (fid.getName().equals(ExpressionConstant.NULL)) {

+				return new ExprNodeNullDesc();

+			}

 

-            /**

-             * argument expressions: translate argument expressions recursively

-             * first, this logic is shared in scalar, aggregation and unnesting

-             * function

-             */

-            List<Mutable<ILogicalExpression>> arguments = funcExpr.getArguments();

-            List<ExprNodeDesc> parameters = new ArrayList<ExprNodeDesc>();

-            for (Mutable<ILogicalExpression> argument : arguments) {

-                /**

-                 * parameters could not be aggregate function desc

-                 */

-                ExprNodeDesc parameter = (ExprNodeDesc) getHiveExpression(argument.getValue(), env);

-                parameters.add(parameter);

-            }

+			/**

+			 * argument expressions: translate argument expressions recursively

+			 * first, this logic is shared in scalar, aggregation and unnesting

+			 * function

+			 */

+			List<Mutable<ILogicalExpression>> arguments = funcExpr

+					.getArguments();

+			List<ExprNodeDesc> parameters = new ArrayList<ExprNodeDesc>();

+			for (Mutable<ILogicalExpression> argument : arguments) {

+				/**

+				 * parameters could not be aggregate function desc

+				 */

+				ExprNodeDesc parameter = (ExprNodeDesc) getHiveExpression(

+						argument.getValue(), env);

+				parameters.add(parameter);

+			}

 

-            /**

-             * get expression

-             */

-            if (funcExpr instanceof ScalarFunctionCallExpression) {

-                String udfName = HiveAlgebricksBuiltInFunctionMap.INSTANCE.getHiveFunctionName(fid);

-                GenericUDF udf;

-                if (udfName != null) {

-                    /**

-                     * get corresponding function info for built-in functions

-                     */

-                    FunctionInfo fInfo = FunctionRegistry.getFunctionInfo(udfName);

-                    udf = fInfo.getGenericUDF();

+			/**

+			 * get expression

+			 */

+			if (funcExpr instanceof ScalarFunctionCallExpression) {

+				String udfName = HiveAlgebricksBuiltInFunctionMap.INSTANCE

+						.getHiveFunctionName(fid);

+				GenericUDF udf;

+				if (udfName != null) {

+					/**

+					 * get corresponding function info for built-in functions

+					 */

+					FunctionInfo fInfo = FunctionRegistry

+							.getFunctionInfo(udfName);

+					udf = fInfo.getGenericUDF();

 

-                    int inputSize = parameters.size();

-                    List<ExprNodeDesc> currentDescs = new ArrayList<ExprNodeDesc>();

+					int inputSize = parameters.size();

+					List<ExprNodeDesc> currentDescs = new ArrayList<ExprNodeDesc>();

 

-                    // generate expression tree if necessary

-                    while (inputSize > 2) {

-                        int pairs = inputSize / 2;

-                        for (int i = 0; i < pairs; i++) {

-                            List<ExprNodeDesc> descs = new ArrayList<ExprNodeDesc>();

-                            descs.add(parameters.get(2 * i));

-                            descs.add(parameters.get(2 * i + 1));

-                            ExprNodeDesc desc = ExprNodeGenericFuncDesc.newInstance(udf, descs);

-                            currentDescs.add(desc);

-                        }

+					// generate expression tree if necessary

+					while (inputSize > 2) {

+						int pairs = inputSize / 2;

+						for (int i = 0; i < pairs; i++) {

+							List<ExprNodeDesc> descs = new ArrayList<ExprNodeDesc>();

+							descs.add(parameters.get(2 * i));

+							descs.add(parameters.get(2 * i + 1));

+							ExprNodeDesc desc = ExprNodeGenericFuncDesc

+									.newInstance(udf, descs);

+							currentDescs.add(desc);

+						}

 

-                        if (inputSize % 2 != 0) {

-                            // List<ExprNodeDesc> descs = new

-                            // ArrayList<ExprNodeDesc>();

-                            // ExprNodeDesc lastExpr =

-                            // currentDescs.remove(currentDescs.size() - 1);

-                            // descs.add(lastExpr);

-                            currentDescs.add(parameters.get(inputSize - 1));

-                            // ExprNodeDesc desc =

-                            // ExprNodeGenericFuncDesc.newInstance(udf, descs);

-                            // currentDescs.add(desc);

-                        }

-                        inputSize = currentDescs.size();

-                        parameters.clear();

-                        parameters.addAll(currentDescs);

-                        currentDescs.clear();

-                    }

+						if (inputSize % 2 != 0) {

+							// List<ExprNodeDesc> descs = new

+							// ArrayList<ExprNodeDesc>();

+							// ExprNodeDesc lastExpr =

+							// currentDescs.remove(currentDescs.size() - 1);

+							// descs.add(lastExpr);

+							currentDescs.add(parameters.get(inputSize - 1));

+							// ExprNodeDesc desc =

+							// ExprNodeGenericFuncDesc.newInstance(udf, descs);

+							// currentDescs.add(desc);

+						}

+						inputSize = currentDescs.size();

+						parameters.clear();

+						parameters.addAll(currentDescs);

+						currentDescs.clear();

+					}

 

-                } else {

-                    Object secondInfo = ((HiveFunctionInfo) funcInfo).getInfo();

-                    if (secondInfo != null) {

+				} else {

+					Object secondInfo = ((HiveFunctionInfo) funcInfo).getInfo();

+					if (secondInfo != null) {

 

-                        /**

-                         * for GenericUDFBridge: we should not call get type of

-                         * this hive expression, because parameters may have

-                         * been changed!

-                         */

-                        ExprNodeGenericFuncDesc hiveExpr = (ExprNodeGenericFuncDesc) ((HiveFunctionInfo) funcInfo)

-                                .getInfo();

-                        udf = hiveExpr.getGenericUDF();

-                    } else {

-                        /**

-                         * for other generic UDF

-                         */

-                        Class<?> udfClass;

-                        try {

-                            udfClass = Class.forName(fid.getName());

-                            udf = (GenericUDF) udfClass.newInstance();

-                        } catch (Exception e) {

-                            e.printStackTrace();

-                            throw new AlgebricksException(e.getMessage());

-                        }

-                    }

-                }

-                /**

-                 * get hive generic function expression

-                 */

-                ExprNodeDesc desc = ExprNodeGenericFuncDesc.newInstance(udf, parameters);

-                return desc;

-            } else if (funcExpr instanceof AggregateFunctionCallExpression) {

-                /**

-                 * hive aggregation info

-                 */

-                AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo())

-                        .getInfo();

-                /**

-                 * set parameters

-                 */

-                aggregateDesc.setParameters((ArrayList<ExprNodeDesc>) parameters);

+						/**

+						 * for GenericUDFBridge: we should not call get type of

+						 * this hive expression, because parameters may have

+						 * been changed!

+						 */

+						ExprNodeGenericFuncDesc hiveExpr = (ExprNodeGenericFuncDesc) ((HiveFunctionInfo) funcInfo)

+								.getInfo();

+						udf = hiveExpr.getGenericUDF();

+					} else {

+						/**

+						 * for other generic UDF

+						 */

+						Class<?> udfClass;

+						try {

+							udfClass = Class.forName(fid.getName());

+							udf = (GenericUDF) udfClass.newInstance();

+						} catch (Exception e) {

+							e.printStackTrace();

+							throw new AlgebricksException(e.getMessage());

+						}

+					}

+				}

+				/**

+				 * get hive generic function expression

+				 */

+				ExprNodeDesc desc = ExprNodeGenericFuncDesc.newInstance(udf,

+						parameters);

+				return desc;

+			} else if (funcExpr instanceof AggregateFunctionCallExpression) {

+				/**

+				 * hive aggregation info

+				 */

+				AggregationDesc aggregateDesc = (AggregationDesc) ((HiveFunctionInfo) funcExpr

+						.getFunctionInfo()).getInfo();

+				/**

+				 * set parameters

+				 */

+				aggregateDesc

+						.setParameters((ArrayList<ExprNodeDesc>) parameters);

 

-                List<TypeInfo> originalParameterTypeInfos = new ArrayList<TypeInfo>();

-                for (ExprNodeDesc parameter : parameters) {

-                    if (parameter.getTypeInfo() instanceof StructTypeInfo) {

-                        originalParameterTypeInfos.add(TypeInfoFactory.doubleTypeInfo);

-                    } else

-                        originalParameterTypeInfos.add(parameter.getTypeInfo());

-                }

+				List<TypeInfo> originalParameterTypeInfos = new ArrayList<TypeInfo>();

+				for (ExprNodeDesc parameter : parameters) {

+					if (parameter.getTypeInfo() instanceof StructTypeInfo) {

+						originalParameterTypeInfos

+								.add(TypeInfoFactory.doubleTypeInfo);

+					} else

+						originalParameterTypeInfos.add(parameter.getTypeInfo());

+				}

 

-                GenericUDAFEvaluator eval = FunctionRegistry.getGenericUDAFEvaluator(

-                        aggregateDesc.getGenericUDAFName(), originalParameterTypeInfos, aggregateDesc.getDistinct(),

-                        false);

+				GenericUDAFEvaluator eval = FunctionRegistry

+						.getGenericUDAFEvaluator(

+								aggregateDesc.getGenericUDAFName(),

+								originalParameterTypeInfos,

+								aggregateDesc.getDistinct(), false);

 

-                AggregationDesc newAggregateDesc = new AggregationDesc(aggregateDesc.getGenericUDAFName(), eval,

-                        aggregateDesc.getParameters(), aggregateDesc.getDistinct(), aggregateDesc.getMode());

-                return newAggregateDesc;

-            } else if (funcExpr instanceof UnnestingFunctionCallExpression) {

-                /**

-                 * type inference for UDTF function

-                 */

-                UDTFDesc hiveDesc = (UDTFDesc) ((HiveFunctionInfo) funcExpr.getFunctionInfo()).getInfo();

-                String funcName = hiveDesc.getUDTFName();

-                FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcName);

-                GenericUDTF udtf = fi.getGenericUDTF();

-                UDTFDesc desc = new UDTFDesc(udtf);

-                return desc;

-            } else {

-                throw new IllegalStateException("unrecognized function expression " + expr.getClass().getName());

-            }

-        } else if ((expr.getExpressionTag() == LogicalExpressionTag.VARIABLE)) {

-            /**

-             * get type for variable in the environment

-             */

-            VariableReferenceExpression varExpr = (VariableReferenceExpression) expr;

-            LogicalVariable var = varExpr.getVariableReference();

-            TypeInfo typeInfo = (TypeInfo) env.getVarType(var);

-            ExprNodeDesc desc = new ExprNodeColumnDesc(typeInfo, var.toString(), "", false);

-            return desc;

-        } else if ((expr.getExpressionTag() == LogicalExpressionTag.CONSTANT)) {

-            /**

-             * get expression for constant in the environment

-             */

-            ConstantExpression varExpr = (ConstantExpression) expr;

-            Object value = ((HivesterixConstantValue) varExpr.getValue()).getObject();

-            ExprNodeDesc desc = new ExprNodeConstantDesc(value);

-            return desc;

-        } else {

-            throw new IllegalStateException("illegal expressions " + expr.getClass().getName());

-        }

-    }

+				AggregationDesc newAggregateDesc = new AggregationDesc(

+						aggregateDesc.getGenericUDAFName(), eval,

+						aggregateDesc.getParameters(),

+						aggregateDesc.getDistinct(), aggregateDesc.getMode());

+				return newAggregateDesc;

+			} else if (funcExpr instanceof UnnestingFunctionCallExpression) {

+				/**

+				 * type inference for UDTF function

+				 */

+				UDTFDesc hiveDesc = (UDTFDesc) ((HiveFunctionInfo) funcExpr

+						.getFunctionInfo()).getInfo();

+				String funcName = hiveDesc.getUDTFName();

+				FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcName);

+				GenericUDTF udtf = fi.getGenericUDTF();

+				UDTFDesc desc = new UDTFDesc(udtf);

+				return desc;

+			} else {

+				throw new IllegalStateException(

+						"unrecognized function expression "

+								+ expr.getClass().getName());

+			}

+		} else if ((expr.getExpressionTag() == LogicalExpressionTag.VARIABLE)) {

+			/**

+			 * get type for variable in the environment

+			 */

+			VariableReferenceExpression varExpr = (VariableReferenceExpression) expr;

+			LogicalVariable var = varExpr.getVariableReference();

+			TypeInfo typeInfo = (TypeInfo) env.getVarType(var);

+			ExprNodeDesc desc = new ExprNodeColumnDesc(typeInfo,

+					var.toString(), "", false);

+			return desc;

+		} else if ((expr.getExpressionTag() == LogicalExpressionTag.CONSTANT)) {

+			/**

+			 * get expression for constant in the environment

+			 */

+			ConstantExpression varExpr = (ConstantExpression) expr;

+			Object value = ((HivesterixConstantValue) varExpr.getValue())

+					.getObject();

+			ExprNodeDesc desc = new ExprNodeConstantDesc(value);

+			return desc;

+		} else {

+			throw new IllegalStateException("illegal expressions "

+					+ expr.getClass().getName());

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FieldExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FieldExpressionEvaluator.java
index 35560b6..5f6a5dc 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FieldExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FieldExpressionEvaluator.java
@@ -9,9 +9,9 @@
 

 public class FieldExpressionEvaluator extends AbstractExpressionEvaluator {

 

-    public FieldExpressionEvaluator(ExprNodeFieldDesc expr, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        super(new ExprNodeFieldEvaluator(expr), oi, output);

-    }

+	public FieldExpressionEvaluator(ExprNodeFieldDesc expr, ObjectInspector oi,

+			IDataOutputProvider output) throws AlgebricksException {

+		super(new ExprNodeFieldEvaluator(expr), oi, output);

+	}

 

 }
\ No newline at end of file
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FunctionExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FunctionExpressionEvaluator.java
index 7ffec7a..c3f3c93 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FunctionExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/FunctionExpressionEvaluator.java
@@ -9,9 +9,10 @@
 

 public class FunctionExpressionEvaluator extends AbstractExpressionEvaluator {

 

-    public FunctionExpressionEvaluator(ExprNodeGenericFuncDesc expr, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        super(new ExprNodeGenericFuncEvaluator(expr), oi, output);

-    }

+	public FunctionExpressionEvaluator(ExprNodeGenericFuncDesc expr,

+			ObjectInspector oi, IDataOutputProvider output)

+			throws AlgebricksException {

+		super(new ExprNodeGenericFuncEvaluator(expr), oi, output);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/NullExpressionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/NullExpressionEvaluator.java
index ca60385..cbe5561 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/NullExpressionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/NullExpressionEvaluator.java
@@ -9,8 +9,8 @@
 

 public class NullExpressionEvaluator extends AbstractExpressionEvaluator {

 

-    public NullExpressionEvaluator(ExprNodeNullDesc expr, ObjectInspector oi, IDataOutputProvider output)

-            throws AlgebricksException {

-        super(new ExprNodeNullEvaluator(expr), oi, output);

-    }

+	public NullExpressionEvaluator(ExprNodeNullDesc expr, ObjectInspector oi,

+			IDataOutputProvider output) throws AlgebricksException {

+		super(new ExprNodeNullEvaluator(expr), oi, output);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/SerializableBuffer.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/SerializableBuffer.java
index 676989e..328b384 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/SerializableBuffer.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/SerializableBuffer.java
@@ -7,10 +7,10 @@
 
 public interface SerializableBuffer extends AggregationBuffer {
 
-    public void deSerializeAggBuffer(byte[] data, int start, int len);
+	public void deSerializeAggBuffer(byte[] data, int start, int len);
 
-    public void serializeAggBuffer(byte[] data, int start, int len);
+	public void serializeAggBuffer(byte[] data, int start, int len);
 
-    public void serializeAggBuffer(DataOutput output) throws IOException;
+	public void serializeAggBuffer(DataOutput output) throws IOException;
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/UDTFFunctionEvaluator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/UDTFFunctionEvaluator.java
index 284d3d2..de0141b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/UDTFFunctionEvaluator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/evaluator/UDTFFunctionEvaluator.java
@@ -23,121 +23,125 @@
 

 public class UDTFFunctionEvaluator implements ICopyUnnestingFunction, Collector {

 

-    /**

-     * udtf function

-     */

-    private UDTFDesc func;

+	/**

+	 * udtf function

+	 */

+	private UDTFDesc func;

 

-    /**

-     * input object inspector

-     */

-    private ObjectInspector inputInspector;

+	/**

+	 * input object inspector

+	 */

+	private ObjectInspector inputInspector;

 

-    /**

-     * output object inspector

-     */

-    private ObjectInspector outputInspector;

+	/**

+	 * output object inspector

+	 */

+	private ObjectInspector outputInspector;

 

-    /**

-     * object inspector for udtf

-     */

-    private ObjectInspector[] udtfInputOIs;

+	/**

+	 * object inspector for udtf

+	 */

+	private ObjectInspector[] udtfInputOIs;

 

-    /**

-     * generic udtf

-     */

-    private GenericUDTF udtf;

+	/**

+	 * generic udtf

+	 */

+	private GenericUDTF udtf;

 

-    /**

-     * data output

-     */

-    private DataOutput out;

+	/**

+	 * data output

+	 */

+	private DataOutput out;

 

-    /**

-     * the input row object

-     */

-    private LazyColumnar cachedRowObject;

+	/**

+	 * the input row object

+	 */

+	private LazyColumnar cachedRowObject;

 

-    /**

-     * cached row object (input)

-     */

-    private Object[] cachedInputObjects;

+	/**

+	 * cached row object (input)

+	 */

+	private Object[] cachedInputObjects;

 

-    /**

-     * serialization/deserialization

-     */

-    private SerDe lazySerDe;

+	/**

+	 * serialization/deserialization

+	 */

+	private SerDe lazySerDe;

 

-    /**

-     * columns feed into UDTF

-     */

-    private int[] columns;

+	/**

+	 * columns feed into UDTF

+	 */

+	private int[] columns;

 

-    public UDTFFunctionEvaluator(UDTFDesc desc, Schema schema, int[] cols, DataOutput output) {

-        this.func = desc;

-        this.inputInspector = schema.toObjectInspector();

-        udtf = func.getGenericUDTF();

-        out = output;

-        columns = cols;

-    }

+	public UDTFFunctionEvaluator(UDTFDesc desc, Schema schema, int[] cols,

+			DataOutput output) {

+		this.func = desc;

+		this.inputInspector = schema.toObjectInspector();

+		udtf = func.getGenericUDTF();

+		out = output;

+		columns = cols;

+	}

 

-    @Override

-    public void init(IFrameTupleReference tuple) throws AlgebricksException {

-        cachedInputObjects = new LazyObject[columns.length];

-        try {

-            cachedRowObject = (LazyColumnar) LazyFactory.createLazyObject(inputInspector);

-            outputInspector = udtf.initialize(udtfInputOIs);

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        }

-        udtf.setCollector(this);

-        lazySerDe = new LazySerDe();

-        readIntoCache(tuple);

-    }

+	@Override

+	public void init(IFrameTupleReference tuple) throws AlgebricksException {

+		cachedInputObjects = new LazyObject[columns.length];

+		try {

+			cachedRowObject = (LazyColumnar) LazyFactory

+					.createLazyObject(inputInspector);

+			outputInspector = udtf.initialize(udtfInputOIs);

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		}

+		udtf.setCollector(this);

+		lazySerDe = new LazySerDe();

+		readIntoCache(tuple);

+	}

 

-    @Override

-    public boolean step() throws AlgebricksException {

-        try {

-            udtf.process(cachedInputObjects);

-            return true;

-        } catch (HiveException e) {

-            throw new AlgebricksException(e);

-        }

-    }

+	@Override

+	public boolean step() throws AlgebricksException {

+		try {

+			udtf.process(cachedInputObjects);

+			return true;

+		} catch (HiveException e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    /**

-     * bind the tuple reference to the cached row object

-     * 

-     * @param r

-     */

-    private void readIntoCache(IFrameTupleReference r) {

-        cachedRowObject.init(r);

-        for (int i = 0; i < cachedInputObjects.length; i++) {

-            cachedInputObjects[i] = cachedRowObject.getField(columns[i]);

-        }

-    }

+	/**

+	 * bind the tuple reference to the cached row object

+	 * 

+	 * @param r

+	 */

+	private void readIntoCache(IFrameTupleReference r) {

+		cachedRowObject.init(r);

+		for (int i = 0; i < cachedInputObjects.length; i++) {

+			cachedInputObjects[i] = cachedRowObject.getField(columns[i]);

+		}

+	}

 

-    /**

-     * serialize the result

-     * 

-     * @param result

-     *            the evaluation result

-     * @throws IOException

-     * @throws AlgebricksException

-     */

-    private void serializeResult(Object result) throws SerDeException, IOException {

-        BytesWritable outputWritable = (BytesWritable) lazySerDe.serialize(result, outputInspector);

-        out.write(outputWritable.getBytes(), 0, outputWritable.getLength());

-    }

+	/**

+	 * serialize the result

+	 * 

+	 * @param result

+	 *            the evaluation result

+	 * @throws IOException

+	 * @throws AlgebricksException

+	 */

+	private void serializeResult(Object result) throws SerDeException,

+			IOException {

+		BytesWritable outputWritable = (BytesWritable) lazySerDe.serialize(

+				result, outputInspector);

+		out.write(outputWritable.getBytes(), 0, outputWritable.getLength());

+	}

 

-    @Override

-    public void collect(Object input) throws HiveException {

-        try {

-            serializeResult(input);

-        } catch (IOException e) {

-            throw new HiveException(e);

-        } catch (SerDeException e) {

-            throw new HiveException(e);

-        }

-    }

+	@Override

+	public void collect(Object input) throws HiveException {

+		try {

+			serializeResult(input);

+		} catch (IOException e) {

+			throw new HiveException(e);

+		} catch (SerDeException e) {

+			throw new HiveException(e);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
index 2f16573..57213ba 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/HyracksExecutionEngine.java
@@ -70,488 +70,528 @@
 

 public class HyracksExecutionEngine implements IExecutionEngine {

 

-    private static final Log LOG = LogFactory.getLog(HyracksExecutionEngine.class.getName());

+	private static final Log LOG = LogFactory

+			.getLog(HyracksExecutionEngine.class.getName());

 

-    // private static final String[] locConstraints = {}

+	// private static final String[] locConstraints = {}

 

-    private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_LOGICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();

-    private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_PHYSICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();

-    static {

-        SequentialFixpointRuleController seqCtrlNoDfs = new SequentialFixpointRuleController(false);

-        SequentialFixpointRuleController seqCtrlFullDfs = new SequentialFixpointRuleController(true);

-        SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true);

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlFullDfs,

-                HiveRuleCollections.NORMALIZATION));

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,

-                HiveRuleCollections.COND_PUSHDOWN_AND_JOIN_INFERENCE));

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlFullDfs,

-                HiveRuleCollections.LOAD_FIELDS));

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,

-                HiveRuleCollections.OP_PUSHDOWN));

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,

-                HiveRuleCollections.DATA_EXCHANGE));

-        DEFAULT_LOGICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs,

-                HiveRuleCollections.CONSOLIDATION));

+	private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_LOGICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();

+	private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> DEFAULT_PHYSICAL_REWRITES = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>();

+	static {

+		SequentialFixpointRuleController seqCtrlNoDfs = new SequentialFixpointRuleController(

+				false);

+		SequentialFixpointRuleController seqCtrlFullDfs = new SequentialFixpointRuleController(

+				true);

+		SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(

+				true);

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqCtrlFullDfs, HiveRuleCollections.NORMALIZATION));

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqCtrlNoDfs,

+						HiveRuleCollections.COND_PUSHDOWN_AND_JOIN_INFERENCE));

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqCtrlFullDfs, HiveRuleCollections.LOAD_FIELDS));

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqCtrlNoDfs, HiveRuleCollections.OP_PUSHDOWN));

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqOnceCtrl, HiveRuleCollections.DATA_EXCHANGE));

+		DEFAULT_LOGICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqCtrlNoDfs, HiveRuleCollections.CONSOLIDATION));

 

-        DEFAULT_PHYSICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,

-                HiveRuleCollections.PHYSICAL_PLAN_REWRITES));

-        DEFAULT_PHYSICAL_REWRITES.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl,

-                HiveRuleCollections.prepareJobGenRules));

-    }

+		DEFAULT_PHYSICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqOnceCtrl, HiveRuleCollections.PHYSICAL_PLAN_REWRITES));

+		DEFAULT_PHYSICAL_REWRITES

+				.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(

+						seqOnceCtrl, HiveRuleCollections.prepareJobGenRules));

+	}

 

-    /**

-     * static configurations for compiler

-     */

-    private HeuristicCompilerFactoryBuilder builder;

+	/**

+	 * static configurations for compiler

+	 */

+	private HeuristicCompilerFactoryBuilder builder;

 

-    /**

-     * compiler

-     */

-    private ICompiler compiler;

+	/**

+	 * compiler

+	 */

+	private ICompiler compiler;

 

-    /**

-     * physical optimization config

-     */

-    private PhysicalOptimizationConfig physicalOptimizationConfig;

+	/**

+	 * physical optimization config

+	 */

+	private PhysicalOptimizationConfig physicalOptimizationConfig;

 

-    /**

-     * final ending operators

-     */

-    private List<Operator> leaveOps = new ArrayList<Operator>();

+	/**

+	 * final ending operators

+	 */

+	private List<Operator> leaveOps = new ArrayList<Operator>();

 

-    /**

-     * tasks that are already visited

-     */

-    private Map<Task<? extends Serializable>, Boolean> tasksVisited = new HashMap<Task<? extends Serializable>, Boolean>();

+	/**

+	 * tasks that are already visited

+	 */

+	private Map<Task<? extends Serializable>, Boolean> tasksVisited = new HashMap<Task<? extends Serializable>, Boolean>();

 

-    /**

-     * hyracks job spec

-     */

-    private JobSpecification jobSpec;

+	/**

+	 * hyracks job spec

+	 */

+	private JobSpecification jobSpec;

 

-    /**

-     * hive configuration

-     */

-    private HiveConf conf;

+	/**

+	 * hive configuration

+	 */

+	private HiveConf conf;

 

-    /**

-     * plan printer

-     */

-    private PrintWriter planPrinter;

+	/**

+	 * plan printer

+	 */

+	private PrintWriter planPrinter;

 

-    public HyracksExecutionEngine(HiveConf conf) {

-        this.conf = conf;

-        init(conf);

-    }

+	public HyracksExecutionEngine(HiveConf conf) {

+		this.conf = conf;

+		init(conf);

+	}

 

-    public HyracksExecutionEngine(HiveConf conf, PrintWriter planPrinter) {

-        this.conf = conf;

-        this.planPrinter = planPrinter;

-        init(conf);

-    }

+	public HyracksExecutionEngine(HiveConf conf, PrintWriter planPrinter) {

+		this.conf = conf;

+		this.planPrinter = planPrinter;

+		init(conf);

+	}

 

-    private void init(HiveConf conf) {

-        builder = new HeuristicCompilerFactoryBuilder(DefaultOptimizationContextFactory.INSTANCE);

-        builder.setLogicalRewrites(DEFAULT_LOGICAL_REWRITES);

-        builder.setPhysicalRewrites(DEFAULT_PHYSICAL_REWRITES);

-        builder.setIMergeAggregationExpressionFactory(HiveMergeAggregationExpressionFactory.INSTANCE);

-        builder.setExpressionTypeComputer(HiveExpressionTypeComputer.INSTANCE);

-        builder.setNullableTypeComputer(HiveNullableTypeComputer.INSTANCE);

+	private void init(HiveConf conf) {

+		builder = new HeuristicCompilerFactoryBuilder(

+				DefaultOptimizationContextFactory.INSTANCE);

+		builder.setLogicalRewrites(DEFAULT_LOGICAL_REWRITES);

+		builder.setPhysicalRewrites(DEFAULT_PHYSICAL_REWRITES);

+		builder.setIMergeAggregationExpressionFactory(HiveMergeAggregationExpressionFactory.INSTANCE);

+		builder.setExpressionTypeComputer(HiveExpressionTypeComputer.INSTANCE);

+		builder.setNullableTypeComputer(HiveNullableTypeComputer.INSTANCE);

 

-        long memSizeExternalGby = conf.getLong("hive.algebricks.groupby.external.memory", 268435456);

-        long memSizeExternalSort = conf.getLong("hive.algebricks.sort.memory", 536870912);

-        int frameSize = conf.getInt("hive.algebricks.framesize", 32768);

+		long memSizeExternalGby = conf.getLong(

+				"hive.algebricks.groupby.external.memory", 268435456);

+		long memSizeExternalSort = conf.getLong("hive.algebricks.sort.memory",

+				536870912);

+		int frameSize = conf.getInt("hive.algebricks.framesize", 32768);

 

-        physicalOptimizationConfig = new PhysicalOptimizationConfig();

-        int frameLimitExtGby = (int) (memSizeExternalGby / frameSize);

-        physicalOptimizationConfig.setMaxFramesExternalGroupBy(frameLimitExtGby);

-        int frameLimitExtSort = (int) (memSizeExternalSort / frameSize);

-        physicalOptimizationConfig.setMaxFramesExternalSort(frameLimitExtSort);

-        builder.setPhysicalOptimizationConfig(physicalOptimizationConfig);

-    }

+		physicalOptimizationConfig = new PhysicalOptimizationConfig();

+		int frameLimitExtGby = (int) (memSizeExternalGby / frameSize);

+		physicalOptimizationConfig

+				.setMaxFramesExternalGroupBy(frameLimitExtGby);

+		int frameLimitExtSort = (int) (memSizeExternalSort / frameSize);

+		physicalOptimizationConfig.setMaxFramesExternalSort(frameLimitExtSort);

+		builder.setPhysicalOptimizationConfig(physicalOptimizationConfig);

+	}

 

-    @Override

-    public int compileJob(List<Task<? extends Serializable>> rootTasks) {

-        // clean up

-        leaveOps.clear();

-        tasksVisited.clear();

-        jobSpec = null;

+	@Override

+	public int compileJob(List<Task<? extends Serializable>> rootTasks) {

+		// clean up

+		leaveOps.clear();

+		tasksVisited.clear();

+		jobSpec = null;

 

-        HashMap<String, PartitionDesc> aliasToPath = new HashMap<String, PartitionDesc>();

-        List<Operator> rootOps = generateRootOperatorDAG(rootTasks, aliasToPath);

+		HashMap<String, PartitionDesc> aliasToPath = new HashMap<String, PartitionDesc>();

+		List<Operator> rootOps = generateRootOperatorDAG(rootTasks, aliasToPath);

 

-        // get all leave Ops

-        getLeaves(rootOps, leaveOps);

+		// get all leave Ops

+		getLeaves(rootOps, leaveOps);

 

-        HiveAlgebricksTranslator translator = new HiveAlgebricksTranslator();

-        try {

-            translator.translate(rootOps, null, aliasToPath);

+		HiveAlgebricksTranslator translator = new HiveAlgebricksTranslator();

+		try {

+			translator.translate(rootOps, null, aliasToPath);

 

-            ILogicalPlan plan = translator.genLogicalPlan();

+			ILogicalPlan plan = translator.genLogicalPlan();

 

-            if (plan.getRoots() != null && plan.getRoots().size() > 0 && plan.getRoots().get(0).getValue() != null) {

-                translator.printOperators();

-                System.out.println("translate complete");

-                ILogicalPlanAndMetadata planAndMetadata = new HiveLogicalPlanAndMetaData(plan,

-                        translator.getMetadataProvider());

+			if (plan.getRoots() != null && plan.getRoots().size() > 0

+					&& plan.getRoots().get(0).getValue() != null) {

+				translator.printOperators();

+				System.out.println("translate complete");

+				ILogicalPlanAndMetadata planAndMetadata = new HiveLogicalPlanAndMetaData(

+						plan, translator.getMetadataProvider());

 

-                ICompilerFactory compilerFactory = builder.create();

-                compiler = compilerFactory.createCompiler(planAndMetadata.getPlan(),

-                        planAndMetadata.getMetadataProvider(), translator.getVariableCounter());

+				ICompilerFactory compilerFactory = builder.create();

+				compiler = compilerFactory.createCompiler(

+						planAndMetadata.getPlan(),

+						planAndMetadata.getMetadataProvider(),

+						translator.getVariableCounter());

 

-                // run optimization and re-writing rules for Hive plan

-                compiler.optimize();

+				// run optimization and re-writing rules for Hive plan

+				compiler.optimize();

 

-                // print optimized plan

-                LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();

-                StringBuilder buffer = new StringBuilder();

-                PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);

-                String planStr = buffer.toString();

-                System.out.println(planStr);

+				// print optimized plan

+				LogicalOperatorPrettyPrintVisitor pvisitor = new LogicalOperatorPrettyPrintVisitor();

+				StringBuilder buffer = new StringBuilder();

+				PlanPrettyPrinter.printPlan(plan, buffer, pvisitor, 0);

+				String planStr = buffer.toString();

+				System.out.println(planStr);

 

-                if (planPrinter != null)

-                    planPrinter.print(planStr);

-            }

-        } catch (Exception e) {

-            e.printStackTrace();

-            return 1;

-        }

+				if (planPrinter != null)

+					planPrinter.print(planStr);

+			}

+		} catch (Exception e) {

+			e.printStackTrace();

+			return 1;

+		}

 

-        return 0;

-    }

+		return 0;

+	}

 

-    private void codeGen() throws AlgebricksException {

-        // number of cpu cores in the cluster

-        builder.setClusterLocations(new AlgebricksAbsolutePartitionConstraint(ConfUtil.getNCs()));

-        //builder.setClusterTopology(ConfUtil.getClusterTopology());

-        builder.setBinaryBooleanInspectorFactory(HiveBinaryBooleanInspectorFactory.INSTANCE);

-        builder.setBinaryIntegerInspectorFactory(HiveBinaryIntegerInspectorFactory.INSTANCE);

-        builder.setComparatorFactoryProvider(HiveBinaryComparatorFactoryProvider.INSTANCE);

-        builder.setExpressionRuntimeProvider(HiveExpressionRuntimeProvider.INSTANCE);

-        builder.setHashFunctionFactoryProvider(HiveBinaryHashFunctionFactoryProvider.INSTANCE);

-        builder.setPrinterProvider(HivePrinterFactoryProvider.INSTANCE);

-        builder.setSerializerDeserializerProvider(HiveSerializerDeserializerProvider.INSTANCE);

-        builder.setNullWriterFactory(HiveNullWriterFactory.INSTANCE);

-        builder.setNormalizedKeyComputerFactoryProvider(HiveNormalizedKeyComputerFactoryProvider.INSTANCE);

-        builder.setPartialAggregationTypeComputer(HivePartialAggregationTypeComputer.INSTANCE);

-        builder.setTypeTraitProvider(HiveTypeTraitProvider.INSTANCE);

+	private void codeGen() throws AlgebricksException {

+		// number of cpu cores in the cluster

+		builder.setClusterLocations(new AlgebricksAbsolutePartitionConstraint(

+				ConfUtil.getNCs()));

+		// builder.setClusterTopology(ConfUtil.getClusterTopology());

+		builder.setBinaryBooleanInspectorFactory(HiveBinaryBooleanInspectorFactory.INSTANCE);

+		builder.setBinaryIntegerInspectorFactory(HiveBinaryIntegerInspectorFactory.INSTANCE);

+		builder.setComparatorFactoryProvider(HiveBinaryComparatorFactoryProvider.INSTANCE);

+		builder.setExpressionRuntimeProvider(HiveExpressionRuntimeProvider.INSTANCE);

+		builder.setHashFunctionFactoryProvider(HiveBinaryHashFunctionFactoryProvider.INSTANCE);

+		builder.setPrinterProvider(HivePrinterFactoryProvider.INSTANCE);

+		builder.setSerializerDeserializerProvider(HiveSerializerDeserializerProvider.INSTANCE);

+		builder.setNullWriterFactory(HiveNullWriterFactory.INSTANCE);

+		builder.setNormalizedKeyComputerFactoryProvider(HiveNormalizedKeyComputerFactoryProvider.INSTANCE);

+		builder.setPartialAggregationTypeComputer(HivePartialAggregationTypeComputer.INSTANCE);

+		builder.setTypeTraitProvider(HiveTypeTraitProvider.INSTANCE);

 

-        jobSpec = compiler.createJob(null);

+		jobSpec = compiler.createJob(null);

 

-        // set the policy

-        String policyStr = conf.get("hive.hyracks.connectorpolicy");

-        if (policyStr == null)

-            policyStr = "PIPELINING";

-        Policy policyValue = Policy.valueOf(policyStr);

-        jobSpec.setConnectorPolicyAssignmentPolicy(new HiveConnectorPolicyAssignmentPolicy(policyValue));

+		// set the policy

+		String policyStr = conf.get("hive.hyracks.connectorpolicy");

+		if (policyStr == null)

+			policyStr = "PIPELINING";

+		Policy policyValue = Policy.valueOf(policyStr);

+		jobSpec.setConnectorPolicyAssignmentPolicy(new HiveConnectorPolicyAssignmentPolicy(

+				policyValue));

 

-        // execute the job

-        System.out.println(jobSpec.toString());

-    }

+		// execute the job

+		System.out.println(jobSpec.toString());

+	}

 

-    @Override

-    public int executeJob() {

-        try {

-            codeGen();

-            executeHyraxJob(jobSpec);

-        } catch (Exception e) {

-            e.printStackTrace();

-            return 1;

-        }

-        return 0;

-    }

+	@Override

+	public int executeJob() {

+		try {

+			codeGen();

+			executeHyraxJob(jobSpec);

+		} catch (Exception e) {

+			e.printStackTrace();

+			return 1;

+		}

+		return 0;

+	}

 

-    private List<Operator> generateRootOperatorDAG(List<Task<? extends Serializable>> rootTasks,

-            HashMap<String, PartitionDesc> aliasToPath) {

+	private List<Operator> generateRootOperatorDAG(

+			List<Task<? extends Serializable>> rootTasks,

+			HashMap<String, PartitionDesc> aliasToPath) {

 

-        List<Operator> rootOps = new ArrayList<Operator>();

-        List<Task<? extends Serializable>> toDelete = new ArrayList<Task<? extends Serializable>>();

-        tasksVisited.clear();

+		List<Operator> rootOps = new ArrayList<Operator>();

+		List<Task<? extends Serializable>> toDelete = new ArrayList<Task<? extends Serializable>>();

+		tasksVisited.clear();

 

-        for (int i = rootTasks.size() - 1; i >= 0; i--) {

-            /**

-             * list of map-reduce tasks

-             */

-            Task<? extends Serializable> task = rootTasks.get(i);

-            // System.out.println("!" + task.getName());

+		for (int i = rootTasks.size() - 1; i >= 0; i--) {

+			/**

+			 * list of map-reduce tasks

+			 */

+			Task<? extends Serializable> task = rootTasks.get(i);

+			// System.out.println("!" + task.getName());

 

-            if (task instanceof MapRedTask) {

-                List<Operator> mapRootOps = articulateMapReduceOperators(task, rootOps, aliasToPath, rootTasks);

-                if (i == 0)

-                    rootOps.addAll(mapRootOps);

-                else {

-                    List<Operator> leaves = new ArrayList<Operator>();

-                    getLeaves(rootOps, leaves);

+			if (task instanceof MapRedTask) {

+				List<Operator> mapRootOps = articulateMapReduceOperators(task,

+						rootOps, aliasToPath, rootTasks);

+				if (i == 0)

+					rootOps.addAll(mapRootOps);

+				else {

+					List<Operator> leaves = new ArrayList<Operator>();

+					getLeaves(rootOps, leaves);

 

-                    List<Operator> mapChildren = new ArrayList<Operator>();

-                    for (Operator childMap : mapRootOps) {

-                        if (childMap instanceof TableScanOperator) {

-                            TableScanDesc topDesc = (TableScanDesc) childMap.getConf();

-                            if (topDesc == null)

-                                mapChildren.add(childMap);

-                            else {

-                                rootOps.add(childMap);

-                            }

-                        } else

-                            mapChildren.add(childMap);

-                    }

+					List<Operator> mapChildren = new ArrayList<Operator>();

+					for (Operator childMap : mapRootOps) {

+						if (childMap instanceof TableScanOperator) {

+							TableScanDesc topDesc = (TableScanDesc) childMap

+									.getConf();

+							if (topDesc == null)

+								mapChildren.add(childMap);

+							else {

+								rootOps.add(childMap);

+							}

+						} else

+							mapChildren.add(childMap);

+					}

 

-                    if (mapChildren.size() > 0) {

-                        for (Operator leaf : leaves)

-                            leaf.setChildOperators(mapChildren);

-                        for (Operator child : mapChildren)

-                            child.setParentOperators(leaves);

-                    }

-                }

+					if (mapChildren.size() > 0) {

+						for (Operator leaf : leaves)

+							leaf.setChildOperators(mapChildren);

+						for (Operator child : mapChildren)

+							child.setParentOperators(leaves);

+					}

+				}

 

-                MapredWork mr = (MapredWork) task.getWork();

-                HashMap<String, PartitionDesc> map = mr.getAliasToPartnInfo();

+				MapredWork mr = (MapredWork) task.getWork();

+				HashMap<String, PartitionDesc> map = mr.getAliasToPartnInfo();

 

-                addAliasToPartition(aliasToPath, map);

-                toDelete.add(task);

-            }

-        }

+				addAliasToPartition(aliasToPath, map);

+				toDelete.add(task);

+			}

+		}

 

-        for (Task<? extends Serializable> task : toDelete)

-            rootTasks.remove(task);

+		for (Task<? extends Serializable> task : toDelete)

+			rootTasks.remove(task);

 

-        return rootOps;

-    }

+		return rootOps;

+	}

 

-    private void addAliasToPartition(HashMap<String, PartitionDesc> aliasToPath, HashMap<String, PartitionDesc> map) {

-        Iterator<String> keys = map.keySet().iterator();

-        while (keys.hasNext()) {

-            String key = keys.next();

-            PartitionDesc part = map.get(key);

-            String[] names = key.split(":");

-            for (String name : names) {

-                aliasToPath.put(name, part);

-            }

-        }

-    }

+	private void addAliasToPartition(

+			HashMap<String, PartitionDesc> aliasToPath,

+			HashMap<String, PartitionDesc> map) {

+		Iterator<String> keys = map.keySet().iterator();

+		while (keys.hasNext()) {

+			String key = keys.next();

+			PartitionDesc part = map.get(key);

+			String[] names = key.split(":");

+			for (String name : names) {

+				aliasToPath.put(name, part);

+			}

+		}

+	}

 

-    private List<Operator> articulateMapReduceOperators(Task task, List<Operator> rootOps,

-            HashMap<String, PartitionDesc> aliasToPath, List<Task<? extends Serializable>> rootTasks) {

-        // System.out.println("!"+task.getName());

-        if (!(task instanceof MapRedTask)) {

-            if (!(task instanceof ConditionalTask)) {

-                rootTasks.add(task);

-                return null;

-            } else {

-                // remove map-reduce branches in condition task

-                ConditionalTask condition = (ConditionalTask) task;

-                List<Task<? extends Serializable>> branches = condition.getListTasks();

-                boolean existMR = false;

-                for (int i = branches.size() - 1; i >= 0; i--) {

-                    Task branch = branches.get(i);

-                    if (branch instanceof MapRedTask) {

-                        return articulateMapReduceOperators(branch, rootOps, aliasToPath, rootTasks);

-                    }

-                }

-                rootTasks.add(task);

-                return null;

-            }

-        }

+	private List<Operator> articulateMapReduceOperators(Task task,

+			List<Operator> rootOps, HashMap<String, PartitionDesc> aliasToPath,

+			List<Task<? extends Serializable>> rootTasks) {

+		// System.out.println("!"+task.getName());

+		if (!(task instanceof MapRedTask)) {

+			if (!(task instanceof ConditionalTask)) {

+				rootTasks.add(task);

+				return null;

+			} else {

+				// remove map-reduce branches in condition task

+				ConditionalTask condition = (ConditionalTask) task;

+				List<Task<? extends Serializable>> branches = condition

+						.getListTasks();

+				boolean existMR = false;

+				for (int i = branches.size() - 1; i >= 0; i--) {

+					Task branch = branches.get(i);

+					if (branch instanceof MapRedTask) {

+						return articulateMapReduceOperators(branch, rootOps,

+								aliasToPath, rootTasks);

+					}

+				}

+				rootTasks.add(task);

+				return null;

+			}

+		}

 

-        MapredWork mr = (MapredWork) task.getWork();

-        HashMap<String, PartitionDesc> map = mr.getAliasToPartnInfo();

+		MapredWork mr = (MapredWork) task.getWork();

+		HashMap<String, PartitionDesc> map = mr.getAliasToPartnInfo();

 

-        // put all aliasToParitionDesc mapping into the map

-        addAliasToPartition(aliasToPath, map);

+		// put all aliasToParitionDesc mapping into the map

+		addAliasToPartition(aliasToPath, map);

 

-        MapRedTask mrtask = (MapRedTask) task;

-        MapredWork work = (MapredWork) mrtask.getWork();

-        HashMap<String, Operator<? extends Serializable>> operators = work.getAliasToWork();

+		MapRedTask mrtask = (MapRedTask) task;

+		MapredWork work = (MapredWork) mrtask.getWork();

+		HashMap<String, Operator<? extends Serializable>> operators = work

+				.getAliasToWork();

 

-        Set entries = operators.entrySet();

-        Iterator<Entry<String, Operator>> iterator = entries.iterator();

-        List<Operator> mapRootOps = new ArrayList<Operator>();

+		Set entries = operators.entrySet();

+		Iterator<Entry<String, Operator>> iterator = entries.iterator();

+		List<Operator> mapRootOps = new ArrayList<Operator>();

 

-        // get map root operators

-        while (iterator.hasNext()) {

-            Operator next = iterator.next().getValue();

-            if (!mapRootOps.contains(next)) {

-                // clear that only for the case of union

-                mapRootOps.add(next);

-            }

-        }

+		// get map root operators

+		while (iterator.hasNext()) {

+			Operator next = iterator.next().getValue();

+			if (!mapRootOps.contains(next)) {

+				// clear that only for the case of union

+				mapRootOps.add(next);

+			}

+		}

 

-        // get map local work

-        MapredLocalWork localWork = work.getMapLocalWork();

-        if (localWork != null) {

-            HashMap<String, Operator<? extends Serializable>> localOperators = localWork.getAliasToWork();

+		// get map local work

+		MapredLocalWork localWork = work.getMapLocalWork();

+		if (localWork != null) {

+			HashMap<String, Operator<? extends Serializable>> localOperators = localWork

+					.getAliasToWork();

 

-            Set localEntries = localOperators.entrySet();

-            Iterator<Entry<String, Operator>> localIterator = localEntries.iterator();

-            while (localIterator.hasNext()) {

-                mapRootOps.add(localIterator.next().getValue());

-            }

+			Set localEntries = localOperators.entrySet();

+			Iterator<Entry<String, Operator>> localIterator = localEntries

+					.iterator();

+			while (localIterator.hasNext()) {

+				mapRootOps.add(localIterator.next().getValue());

+			}

 

-            HashMap<String, FetchWork> localFetch = localWork.getAliasToFetchWork();

-            Set localFetchEntries = localFetch.entrySet();

-            Iterator<Entry<String, FetchWork>> localFetchIterator = localFetchEntries.iterator();

-            while (localFetchIterator.hasNext()) {

-                Entry<String, FetchWork> fetchMap = localFetchIterator.next();

-                FetchWork fetch = fetchMap.getValue();

-                String alias = fetchMap.getKey();

-                List<PartitionDesc> dirPart = fetch.getPartDesc();

+			HashMap<String, FetchWork> localFetch = localWork

+					.getAliasToFetchWork();

+			Set localFetchEntries = localFetch.entrySet();

+			Iterator<Entry<String, FetchWork>> localFetchIterator = localFetchEntries

+					.iterator();

+			while (localFetchIterator.hasNext()) {

+				Entry<String, FetchWork> fetchMap = localFetchIterator.next();

+				FetchWork fetch = fetchMap.getValue();

+				String alias = fetchMap.getKey();

+				List<PartitionDesc> dirPart = fetch.getPartDesc();

 

-                // temporary hack: put the first partitionDesc into the map

-                aliasToPath.put(alias, dirPart.get(0));

-            }

-        }

+				// temporary hack: put the first partitionDesc into the map

+				aliasToPath.put(alias, dirPart.get(0));

+			}

+		}

 

-        Boolean visited = tasksVisited.get(task);

-        if (visited != null && visited.booleanValue() == true) {

-            return mapRootOps;

-        }

+		Boolean visited = tasksVisited.get(task);

+		if (visited != null && visited.booleanValue() == true) {

+			return mapRootOps;

+		}

 

-        // do that only for union operator

-        for (Operator op : mapRootOps)

-            if (op.getParentOperators() != null)

-                op.getParentOperators().clear();

+		// do that only for union operator

+		for (Operator op : mapRootOps)

+			if (op.getParentOperators() != null)

+				op.getParentOperators().clear();

 

-        List<Operator> mapLeaves = new ArrayList<Operator>();

-        downToLeaves(mapRootOps, mapLeaves);

-        List<Operator> reduceOps = new ArrayList<Operator>();

+		List<Operator> mapLeaves = new ArrayList<Operator>();

+		downToLeaves(mapRootOps, mapLeaves);

+		List<Operator> reduceOps = new ArrayList<Operator>();

 

-        if (work.getReducer() != null)

-            reduceOps.add(work.getReducer());

+		if (work.getReducer() != null)

+			reduceOps.add(work.getReducer());

 

-        for (Operator mapLeaf : mapLeaves) {

-            mapLeaf.setChildOperators(reduceOps);

-        }

+		for (Operator mapLeaf : mapLeaves) {

+			mapLeaf.setChildOperators(reduceOps);

+		}

 

-        for (Operator reduceOp : reduceOps) {

-            if (reduceOp != null)

-                reduceOp.setParentOperators(mapLeaves);

-        }

+		for (Operator reduceOp : reduceOps) {

+			if (reduceOp != null)

+				reduceOp.setParentOperators(mapLeaves);

+		}

 

-        List<Operator> leafs = new ArrayList<Operator>();

-        if (reduceOps.size() > 0) {

-            downToLeaves(reduceOps, leafs);

-        } else {

-            leafs = mapLeaves;

-        }

+		List<Operator> leafs = new ArrayList<Operator>();

+		if (reduceOps.size() > 0) {

+			downToLeaves(reduceOps, leafs);

+		} else {

+			leafs = mapLeaves;

+		}

 

-        List<Operator> mapChildren = new ArrayList<Operator>();

-        if (task.getChildTasks() != null && task.getChildTasks().size() > 0) {

-            System.out.println("have child tasks!!");

-            for (Object child : task.getChildTasks()) {

-                System.out.println(child.getClass().getName());

-                List<Operator> childMapOps = articulateMapReduceOperators((Task) child, rootOps, aliasToPath, rootTasks);

-                if (childMapOps == null)

-                    continue;

+		List<Operator> mapChildren = new ArrayList<Operator>();

+		if (task.getChildTasks() != null && task.getChildTasks().size() > 0) {

+			System.out.println("have child tasks!!");

+			for (Object child : task.getChildTasks()) {

+				System.out.println(child.getClass().getName());

+				List<Operator> childMapOps = articulateMapReduceOperators(

+						(Task) child, rootOps, aliasToPath, rootTasks);

+				if (childMapOps == null)

+					continue;

 

-                for (Operator childMap : childMapOps) {

-                    if (childMap instanceof TableScanOperator) {

-                        TableScanDesc topDesc = (TableScanDesc) childMap.getConf();

-                        if (topDesc == null)

-                            mapChildren.add(childMap);

-                        else {

-                            rootOps.add(childMap);

-                        }

-                    } else {

-                        // if not table scan, add the child

-                        mapChildren.add(childMap);

-                    }

-                }

-            }

+				for (Operator childMap : childMapOps) {

+					if (childMap instanceof TableScanOperator) {

+						TableScanDesc topDesc = (TableScanDesc) childMap

+								.getConf();

+						if (topDesc == null)

+							mapChildren.add(childMap);

+						else {

+							rootOps.add(childMap);

+						}

+					} else {

+						// if not table scan, add the child

+						mapChildren.add(childMap);

+					}

+				}

+			}

 

-            if (mapChildren.size() > 0) {

-                int i = 0;

-                for (Operator leaf : leafs) {

-                    if (leaf.getChildOperators() == null || leaf.getChildOperators().size() == 0)

-                        leaf.setChildOperators(new ArrayList<Operator>());

-                    leaf.getChildOperators().add(mapChildren.get(i));

-                    i++;

-                }

-                i = 0;

-                for (Operator child : mapChildren) {

-                    if (child.getParentOperators() == null || child.getParentOperators().size() == 0)

-                        child.setParentOperators(new ArrayList<Operator>());

-                    child.getParentOperators().add(leafs.get(i));

-                    i++;

-                }

-            }

-        }

+			if (mapChildren.size() > 0) {

+				int i = 0;

+				for (Operator leaf : leafs) {

+					if (leaf.getChildOperators() == null

+							|| leaf.getChildOperators().size() == 0)

+						leaf.setChildOperators(new ArrayList<Operator>());

+					leaf.getChildOperators().add(mapChildren.get(i));

+					i++;

+				}

+				i = 0;

+				for (Operator child : mapChildren) {

+					if (child.getParentOperators() == null

+							|| child.getParentOperators().size() == 0)

+						child.setParentOperators(new ArrayList<Operator>());

+					child.getParentOperators().add(leafs.get(i));

+					i++;

+				}

+			}

+		}

 

-        // mark this task as visited

-        this.tasksVisited.put(task, true);

-        return mapRootOps;

-    }

+		// mark this task as visited

+		this.tasksVisited.put(task, true);

+		return mapRootOps;

+	}

 

-    /**

-     * down to leaf nodes

-     * 

-     * @param ops

-     * @param leaves

-     */

-    private void downToLeaves(List<Operator> ops, List<Operator> leaves) {

+	/**

+	 * down to leaf nodes

+	 * 

+	 * @param ops

+	 * @param leaves

+	 */

+	private void downToLeaves(List<Operator> ops, List<Operator> leaves) {

 

-        // Operator currentOp;

-        for (Operator op : ops) {

-            if (op != null && op.getChildOperators() != null && op.getChildOperators().size() > 0) {

-                downToLeaves(op.getChildOperators(), leaves);

-            } else {

-                if (op != null && leaves.indexOf(op) < 0)

-                    leaves.add(op);

-            }

-        }

-    }

+		// Operator currentOp;

+		for (Operator op : ops) {

+			if (op != null && op.getChildOperators() != null

+					&& op.getChildOperators().size() > 0) {

+				downToLeaves(op.getChildOperators(), leaves);

+			} else {

+				if (op != null && leaves.indexOf(op) < 0)

+					leaves.add(op);

+			}

+		}

+	}

 

-    private void getLeaves(List<Operator> roots, List<Operator> currentLeaves) {

-        for (Operator op : roots) {

-            List<Operator> children = op.getChildOperators();

-            if (children == null || children.size() <= 0) {

-                currentLeaves.add(op);

-            } else {

-                getLeaves(children, currentLeaves);

-            }

-        }

-    }

+	private void getLeaves(List<Operator> roots, List<Operator> currentLeaves) {

+		for (Operator op : roots) {

+			List<Operator> children = op.getChildOperators();

+			if (children == null || children.size() <= 0) {

+				currentLeaves.add(op);

+			} else {

+				getLeaves(children, currentLeaves);

+			}

+		}

+	}

 

-    private void executeHyraxJob(JobSpecification job) throws Exception {

-        String ipAddress = conf.get("hive.hyracks.host");

-        int port = Integer.parseInt(conf.get("hive.hyracks.port"));

-        String applicationName = conf.get("hive.hyracks.app");

-        System.out.println("connect to " + ipAddress + " " + port);

+	private void executeHyraxJob(JobSpecification job) throws Exception {

+		String ipAddress = conf.get("hive.hyracks.host");

+		int port = Integer.parseInt(conf.get("hive.hyracks.port"));

+		String applicationName = conf.get("hive.hyracks.app");

+		System.out.println("connect to " + ipAddress + " " + port);

 

-        IHyracksClientConnection hcc = new HyracksConnection(ipAddress, port);

+		IHyracksClientConnection hcc = new HyracksConnection(ipAddress, port);

 

-        System.out.println("get connected");

-        long start = System.currentTimeMillis();

-        JobId jobId = hcc.startJob(applicationName, job);

-        hcc.waitForCompletion(jobId);

+		System.out.println("get connected");

+		long start = System.currentTimeMillis();

+		JobId jobId = hcc.startJob(applicationName, job);

+		hcc.waitForCompletion(jobId);

 

-        System.out.println("job finished: " + jobId.toString());

-        // call all leave nodes to end

-        for (Operator leaf : leaveOps) {

-            jobClose(leaf);

-        }

+		System.out.println("job finished: " + jobId.toString());

+		// call all leave nodes to end

+		for (Operator leaf : leaveOps) {

+			jobClose(leaf);

+		}

 

-        long end = System.currentTimeMillis();

-        System.err.println(start + " " + end + " " + (end - start));

-    }

+		long end = System.currentTimeMillis();

+		System.err.println(start + " " + end + " " + (end - start));

+	}

 

-    /**

-     * mv to final directory on hdfs (not real final)

-     * 

-     * @param leaf

-     * @throws Exception

-     */

-    private void jobClose(Operator leaf) throws Exception {

-        FileSinkOperator fsOp = (FileSinkOperator) leaf;

-        FileSinkDesc desc = fsOp.getConf();

-        boolean isNativeTable = !desc.getTableInfo().isNonNative();

-        if ((conf != null) && isNativeTable) {

-            String specPath = desc.getDirName();

-            DynamicPartitionCtx dpCtx = desc.getDynPartCtx();

-            // for 0.7.0

-            fsOp.mvFileToFinalPath(specPath, conf, true, LOG, dpCtx);

-            // for 0.8.0

-            // Utilities.mvFileToFinalPath(specPath, conf, true, LOG, dpCtx,

-            // desc);

-        }

-    }

+	/**

+	 * mv to final directory on hdfs (not real final)

+	 * 

+	 * @param leaf

+	 * @throws Exception

+	 */

+	private void jobClose(Operator leaf) throws Exception {

+		FileSinkOperator fsOp = (FileSinkOperator) leaf;

+		FileSinkDesc desc = fsOp.getConf();

+		boolean isNativeTable = !desc.getTableInfo().isNonNative();

+		if ((conf != null) && isNativeTable) {

+			String specPath = desc.getDirName();

+			DynamicPartitionCtx dpCtx = desc.getDynPartCtx();

+			// for 0.7.0

+			fsOp.mvFileToFinalPath(specPath, conf, true, LOG, dpCtx);

+			// for 0.8.0

+			// Utilities.mvFileToFinalPath(specPath, conf, true, LOG, dpCtx,

+			// desc);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/IExecutionEngine.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/IExecutionEngine.java
index c64a39b..8f4c471 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/IExecutionEngine.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/exec/IExecutionEngine.java
@@ -7,19 +7,19 @@
 

 public interface IExecutionEngine {

 

-    /**

-     * compile the job

-     * 

-     * @param rootTasks

-     *            : Hive MapReduce plan

-     * @return 0 pass, 1 fail

-     */

-    public int compileJob(List<Task<? extends Serializable>> rootTasks);

+	/**

+	 * compile the job

+	 * 

+	 * @param rootTasks

+	 *            : Hive MapReduce plan

+	 * @return 0 pass, 1 fail

+	 */

+	public int compileJob(List<Task<? extends Serializable>> rootTasks);

 

-    /**

-     * execute the job with latest compiled plan

-     * 

-     * @return

-     */

-    public int executeJob();

+	/**

+	 * execute the job with latest compiled plan

+	 * 

+	 * @return

+	 */

+	public int executeJob();

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryAscComparatorFactory.java
index f3b76e4..9c2d463 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryAscComparatorFactory.java
@@ -3,32 +3,34 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveByteBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveByteBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveByteBinaryAscComparatorFactory INSTANCE = new HiveByteBinaryAscComparatorFactory();

+	public static HiveByteBinaryAscComparatorFactory INSTANCE = new HiveByteBinaryAscComparatorFactory();

 

-    private HiveByteBinaryAscComparatorFactory() {

-    }

+	private HiveByteBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private byte left;

-            private byte right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private byte left;

+			private byte right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = b1[s1];

-                right = b2[s2];

-                if (left > right)

-                    return 1;

-                else if (left == right)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = b1[s1];

+				right = b2[s2];

+				if (left > right)

+					return 1;

+				else if (left == right)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryDescComparatorFactory.java
index 8d452dc..ee71655 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveByteBinaryDescComparatorFactory.java
@@ -3,31 +3,33 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveByteBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveByteBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveByteBinaryDescComparatorFactory INSTANCE = new HiveByteBinaryDescComparatorFactory();

+	public static HiveByteBinaryDescComparatorFactory INSTANCE = new HiveByteBinaryDescComparatorFactory();

 

-    private HiveByteBinaryDescComparatorFactory() {

-    }

+	private HiveByteBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private byte left;

-            private byte right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private byte left;

+			private byte right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = b1[s1];

-                right = b2[s2];

-                if (left > right)

-                    return -1;

-                else if (left == right)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = b1[s1];

+				right = b2[s2];

+				if (left > right)

+					return -1;

+				else if (left == right)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryAscComparatorFactory.java
index 0b5350a..739e417 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryAscComparatorFactory.java
@@ -4,32 +4,36 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveDoubleBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveDoubleBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveDoubleBinaryAscComparatorFactory INSTANCE = new HiveDoubleBinaryAscComparatorFactory();

+	public static HiveDoubleBinaryAscComparatorFactory INSTANCE = new HiveDoubleBinaryAscComparatorFactory();

 

-    private HiveDoubleBinaryAscComparatorFactory() {

-    }

+	private HiveDoubleBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private double left;

-            private double right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private double left;

+			private double right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b1, s1));

-                right = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b2, s2));

-                if (left > right)

-                    return 1;

-                else if (left == right)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = Double.longBitsToDouble(LazyUtils

+						.byteArrayToLong(b1, s1));

+				right = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b2,

+						s2));

+				if (left > right)

+					return 1;

+				else if (left == right)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryDescComparatorFactory.java
index 2405956..0424c9f 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveDoubleBinaryDescComparatorFactory.java
@@ -4,32 +4,36 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveDoubleBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveDoubleBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveDoubleBinaryDescComparatorFactory INSTANCE = new HiveDoubleBinaryDescComparatorFactory();

+	public static HiveDoubleBinaryDescComparatorFactory INSTANCE = new HiveDoubleBinaryDescComparatorFactory();

 

-    private HiveDoubleBinaryDescComparatorFactory() {

-    }

+	private HiveDoubleBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private double left;

-            private double right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private double left;

+			private double right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b1, s1));

-                right = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b2, s2));

-                if (left > right)

-                    return -1;

-                else if (left == right)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = Double.longBitsToDouble(LazyUtils

+						.byteArrayToLong(b1, s1));

+				right = Double.longBitsToDouble(LazyUtils.byteArrayToLong(b2,

+						s2));

+				if (left > right)

+					return -1;

+				else if (left == right)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryAscComparatorFactory.java
index 05a43e6..08542a7 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryAscComparatorFactory.java
@@ -4,32 +4,34 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveFloatBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveFloatBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveFloatBinaryAscComparatorFactory INSTANCE = new HiveFloatBinaryAscComparatorFactory();

+	public static HiveFloatBinaryAscComparatorFactory INSTANCE = new HiveFloatBinaryAscComparatorFactory();

 

-    private HiveFloatBinaryAscComparatorFactory() {

-    }

+	private HiveFloatBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private float left;

-            private float right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private float left;

+			private float right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b1, s1));

-                right = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b2, s2));

-                if (left > right)

-                    return 1;

-                else if (left == right)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b1, s1));

+				right = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b2, s2));

+				if (left > right)

+					return 1;

+				else if (left == right)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryDescComparatorFactory.java
index 2c44f97..513512e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveFloatBinaryDescComparatorFactory.java
@@ -4,32 +4,34 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveFloatBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveFloatBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveFloatBinaryDescComparatorFactory INSTANCE = new HiveFloatBinaryDescComparatorFactory();

+	public static HiveFloatBinaryDescComparatorFactory INSTANCE = new HiveFloatBinaryDescComparatorFactory();

 

-    private HiveFloatBinaryDescComparatorFactory() {

-    }

+	private HiveFloatBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private float left;

-            private float right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private float left;

+			private float right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b1, s1));

-                right = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b2, s2));

-                if (left > right)

-                    return -1;

-                else if (left == right)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b1, s1));

+				right = Float.intBitsToFloat(LazyUtils.byteArrayToInt(b2, s2));

+				if (left > right)

+					return -1;

+				else if (left == right)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryAscComparatorFactory.java
index 0127791..947f30f 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryAscComparatorFactory.java
@@ -5,36 +5,40 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveIntegerBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveIntegerBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static final HiveIntegerBinaryAscComparatorFactory INSTANCE = new HiveIntegerBinaryAscComparatorFactory();

+	public static final HiveIntegerBinaryAscComparatorFactory INSTANCE = new HiveIntegerBinaryAscComparatorFactory();

 

-    private HiveIntegerBinaryAscComparatorFactory() {

-    }

+	private HiveIntegerBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VInt left = new VInt();

-            private VInt right = new VInt();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VInt left = new VInt();

+			private VInt right = new VInt();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVInt(b1, s1, left);

-                LazyUtils.readVInt(b2, s2, right);

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVInt(b1, s1, left);

+				LazyUtils.readVInt(b2, s2, right);

 

-                if (left.length != l1 || right.length != l2)

-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "

-                            + left.length + "," + right.length + " expected " + l1 + "," + l2);

+				if (left.length != l1 || right.length != l2)

+					throw new IllegalArgumentException(

+							"length mismatch in int comparator function actual: "

+									+ left.length + "," + right.length

+									+ " expected " + l1 + "," + l2);

 

-                if (left.value > right.value)

-                    return 1;

-                else if (left.value == right.value)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+				if (left.value > right.value)

+					return 1;

+				else if (left.value == right.value)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryDescComparatorFactory.java
index 5116337..7614aa1 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveIntegerBinaryDescComparatorFactory.java
@@ -5,34 +5,37 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveIntegerBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveIntegerBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static final HiveIntegerBinaryDescComparatorFactory INSTANCE = new HiveIntegerBinaryDescComparatorFactory();

+	public static final HiveIntegerBinaryDescComparatorFactory INSTANCE = new HiveIntegerBinaryDescComparatorFactory();

 

-    private HiveIntegerBinaryDescComparatorFactory() {

-    }

+	private HiveIntegerBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VInt left = new VInt();

-            private VInt right = new VInt();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VInt left = new VInt();

+			private VInt right = new VInt();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVInt(b1, s1, left);

-                LazyUtils.readVInt(b2, s2, right);

-                if (left.length != l1 || right.length != l2)

-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "

-                            + left.length + " expected " + l1);

-                if (left.value > right.value)

-                    return -1;

-                else if (left.value == right.value)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVInt(b1, s1, left);

+				LazyUtils.readVInt(b2, s2, right);

+				if (left.length != l1 || right.length != l2)

+					throw new IllegalArgumentException(

+							"length mismatch in int comparator function actual: "

+									+ left.length + " expected " + l1);

+				if (left.value > right.value)

+					return -1;

+				else if (left.value == right.value)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryAscComparatorFactory.java
index fa416a9..f5f3473 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryAscComparatorFactory.java
@@ -5,34 +5,37 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveLongBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveLongBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static final HiveLongBinaryAscComparatorFactory INSTANCE = new HiveLongBinaryAscComparatorFactory();

+	public static final HiveLongBinaryAscComparatorFactory INSTANCE = new HiveLongBinaryAscComparatorFactory();

 

-    private HiveLongBinaryAscComparatorFactory() {

-    }

+	private HiveLongBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VLong left = new VLong();

-            private VLong right = new VLong();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VLong left = new VLong();

+			private VLong right = new VLong();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVLong(b1, s1, left);

-                LazyUtils.readVLong(b2, s2, right);

-                if (left.length != l1 || right.length != l2)

-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "

-                            + left.length + " expected " + l1);

-                if (left.value > right.value)

-                    return 1;

-                else if (left.value == right.value)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVLong(b1, s1, left);

+				LazyUtils.readVLong(b2, s2, right);

+				if (left.length != l1 || right.length != l2)

+					throw new IllegalArgumentException(

+							"length mismatch in int comparator function actual: "

+									+ left.length + " expected " + l1);

+				if (left.value > right.value)

+					return 1;

+				else if (left.value == right.value)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryDescComparatorFactory.java
index e72dc62..b878b22 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveLongBinaryDescComparatorFactory.java
@@ -5,34 +5,37 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveLongBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveLongBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static final HiveLongBinaryDescComparatorFactory INSTANCE = new HiveLongBinaryDescComparatorFactory();

+	public static final HiveLongBinaryDescComparatorFactory INSTANCE = new HiveLongBinaryDescComparatorFactory();

 

-    private HiveLongBinaryDescComparatorFactory() {

-    }

+	private HiveLongBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VLong left = new VLong();

-            private VLong right = new VLong();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VLong left = new VLong();

+			private VLong right = new VLong();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVLong(b1, s1, left);

-                LazyUtils.readVLong(b2, s2, right);

-                if (left.length != l1 || right.length != l2)

-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "

-                            + left.length + " expected " + l1);

-                if (left.value > right.value)

-                    return -1;

-                else if (left.value == right.value)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVLong(b1, s1, left);

+				LazyUtils.readVLong(b2, s2, right);

+				if (left.length != l1 || right.length != l2)

+					throw new IllegalArgumentException(

+							"length mismatch in int comparator function actual: "

+									+ left.length + " expected " + l1);

+				if (left.value > right.value)

+					return -1;

+				else if (left.value == right.value)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryAscComparatorFactory.java
index a3745fa..8d55cdb 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryAscComparatorFactory.java
@@ -4,32 +4,34 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveShortBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveShortBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveShortBinaryAscComparatorFactory INSTANCE = new HiveShortBinaryAscComparatorFactory();

+	public static HiveShortBinaryAscComparatorFactory INSTANCE = new HiveShortBinaryAscComparatorFactory();

 

-    private HiveShortBinaryAscComparatorFactory() {

-    }

+	private HiveShortBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private short left;

-            private short right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private short left;

+			private short right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = LazyUtils.byteArrayToShort(b1, s1);

-                right = LazyUtils.byteArrayToShort(b2, s2);

-                if (left > right)

-                    return 1;

-                else if (left == right)

-                    return 0;

-                else

-                    return -1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = LazyUtils.byteArrayToShort(b1, s1);

+				right = LazyUtils.byteArrayToShort(b2, s2);

+				if (left > right)

+					return 1;

+				else if (left == right)

+					return 0;

+				else

+					return -1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryDescComparatorFactory.java
index 44d3f43..4e8dde6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveShortBinaryDescComparatorFactory.java
@@ -4,32 +4,34 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveShortBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveShortBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveShortBinaryDescComparatorFactory INSTANCE = new HiveShortBinaryDescComparatorFactory();

+	public static HiveShortBinaryDescComparatorFactory INSTANCE = new HiveShortBinaryDescComparatorFactory();

 

-    private HiveShortBinaryDescComparatorFactory() {

-    }

+	private HiveShortBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private short left;

-            private short right;

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private short left;

+			private short right;

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                left = LazyUtils.byteArrayToShort(b1, s1);

-                right = LazyUtils.byteArrayToShort(b2, s2);

-                if (left > right)

-                    return -1;

-                else if (left == right)

-                    return 0;

-                else

-                    return 1;

-            }

-        };

-    }

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				left = LazyUtils.byteArrayToShort(b1, s1);

+				right = LazyUtils.byteArrayToShort(b2, s2);

+				if (left > right)

+					return -1;

+				else if (left == right)

+					return 0;

+				else

+					return 1;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryAscComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryAscComparatorFactory.java
index 6da9716..a334ecf 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryAscComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryAscComparatorFactory.java
@@ -7,34 +7,40 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveStringBinaryAscComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveStringBinaryAscComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveStringBinaryAscComparatorFactory INSTANCE = new HiveStringBinaryAscComparatorFactory();

+	public static HiveStringBinaryAscComparatorFactory INSTANCE = new HiveStringBinaryAscComparatorFactory();

 

-    private HiveStringBinaryAscComparatorFactory() {

-    }

+	private HiveStringBinaryAscComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VInt leftLen = new VInt();

-            private VInt rightLen = new VInt();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VInt leftLen = new VInt();

+			private VInt rightLen = new VInt();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVInt(b1, s1, leftLen);

-                LazyUtils.readVInt(b2, s2, rightLen);

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVInt(b1, s1, leftLen);

+				LazyUtils.readVInt(b2, s2, rightLen);

 

-                if (leftLen.value + leftLen.length != l1 || rightLen.value + rightLen.length != l2)

-                    throw new IllegalStateException("parse string: length mismatch, expected "

-                            + (leftLen.value + leftLen.length) + ", " + (rightLen.value + rightLen.length)

-                            + " but get " + l1 + ", " + l2);

+				if (leftLen.value + leftLen.length != l1

+						|| rightLen.value + rightLen.length != l2)

+					throw new IllegalStateException(

+							"parse string: length mismatch, expected "

+									+ (leftLen.value + leftLen.length) + ", "

+									+ (rightLen.value + rightLen.length)

+									+ " but get " + l1 + ", " + l2);

 

-                return Text.Comparator.compareBytes(b1, s1 + leftLen.length, l1 - leftLen.length, b2, s2

-                        + rightLen.length, l2 - rightLen.length);

-            }

-        };

-    }

+				return Text.Comparator.compareBytes(b1, s1 + leftLen.length, l1

+						- leftLen.length, b2, s2 + rightLen.length, l2

+						- rightLen.length);

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryDescComparatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryDescComparatorFactory.java
index c579711..e00b58e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryDescComparatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/comparator/HiveStringBinaryDescComparatorFactory.java
@@ -7,33 +7,39 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveStringBinaryDescComparatorFactory implements IBinaryComparatorFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveStringBinaryDescComparatorFactory implements

+		IBinaryComparatorFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveStringBinaryDescComparatorFactory INSTANCE = new HiveStringBinaryDescComparatorFactory();

+	public static HiveStringBinaryDescComparatorFactory INSTANCE = new HiveStringBinaryDescComparatorFactory();

 

-    private HiveStringBinaryDescComparatorFactory() {

-    }

+	private HiveStringBinaryDescComparatorFactory() {

+	}

 

-    @Override

-    public IBinaryComparator createBinaryComparator() {

-        return new IBinaryComparator() {

-            private VInt leftLen = new VInt();

-            private VInt rightLen = new VInt();

+	@Override

+	public IBinaryComparator createBinaryComparator() {

+		return new IBinaryComparator() {

+			private VInt leftLen = new VInt();

+			private VInt rightLen = new VInt();

 

-            @Override

-            public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {

-                LazyUtils.readVInt(b1, s1, leftLen);

-                LazyUtils.readVInt(b2, s2, rightLen);

+			@Override

+			public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,

+					int l2) {

+				LazyUtils.readVInt(b1, s1, leftLen);

+				LazyUtils.readVInt(b2, s2, rightLen);

 

-                if (leftLen.value + leftLen.length != l1 || rightLen.value + rightLen.length != l2)

-                    throw new IllegalStateException("parse string: length mismatch, expected "

-                            + (leftLen.value + leftLen.length) + ", " + (rightLen.value + rightLen.length)

-                            + " but get " + l1 + ", " + l2);

+				if (leftLen.value + leftLen.length != l1

+						|| rightLen.value + rightLen.length != l2)

+					throw new IllegalStateException(

+							"parse string: length mismatch, expected "

+									+ (leftLen.value + leftLen.length) + ", "

+									+ (rightLen.value + rightLen.length)

+									+ " but get " + l1 + ", " + l2);

 

-                return -WritableComparator.compareBytes(b1, s1 + leftLen.length, l1 - leftLen.length, b2, s2

-                        + rightLen.length, l2 - rightLen.length);

-            }

-        };

-    }

+				return -WritableComparator.compareBytes(b1,

+						s1 + leftLen.length, l1 - leftLen.length, b2, s2

+								+ rightLen.length, l2 - rightLen.length);

+			}

+		};

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionFactory.java
index 365379a..c6078ca 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionFactory.java
@@ -32,337 +32,350 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyAggregateFunctionFactory;

 import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;

 

-public class AggregationFunctionFactory implements ICopyAggregateFunctionFactory {

+public class AggregationFunctionFactory implements

+		ICopyAggregateFunctionFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    /**

-     * list of parameters' serialization

-     */

-    private List<String> parametersSerialization = new ArrayList<String>();

+	/**

+	 * list of parameters' serialization

+	 */

+	private List<String> parametersSerialization = new ArrayList<String>();

 

-    /**

-     * the name of the udf

-     */

-    private String genericUDAFName;

+	/**

+	 * the name of the udf

+	 */

+	private String genericUDAFName;

 

-    /**

-     * aggregation mode

-     */

-    private GenericUDAFEvaluator.Mode mode;

+	/**

+	 * aggregation mode

+	 */

+	private GenericUDAFEvaluator.Mode mode;

 

-    /**

-     * list of type info

-     */

-    private List<TypeInfo> types = new ArrayList<TypeInfo>();

+	/**

+	 * list of type info

+	 */

+	private List<TypeInfo> types = new ArrayList<TypeInfo>();

 

-    /**

-     * distinct or not

-     */

-    private boolean distinct;

+	/**

+	 * distinct or not

+	 */

+	private boolean distinct;

 

-    /**

-     * the schema of incoming rows

-     */

-    private Schema rowSchema;

+	/**

+	 * the schema of incoming rows

+	 */

+	private Schema rowSchema;

 

-    /**

-     * list of parameters

-     */

-    private transient List<ExprNodeDesc> parametersOrigin;

+	/**

+	 * list of parameters

+	 */

+	private transient List<ExprNodeDesc> parametersOrigin;

 

-    /**

-     * row inspector

-     */

-    private transient ObjectInspector rowInspector = null;

+	/**

+	 * row inspector

+	 */

+	private transient ObjectInspector rowInspector = null;

 

-    /**

-     * output object inspector

-     */

-    private transient ObjectInspector outputInspector = null;

+	/**

+	 * output object inspector

+	 */

+	private transient ObjectInspector outputInspector = null;

 

-    /**

-     * output object inspector

-     */

-    private transient ObjectInspector outputInspectorPartial = null;

+	/**

+	 * output object inspector

+	 */

+	private transient ObjectInspector outputInspectorPartial = null;

 

-    /**

-     * parameter inspectors

-     */

-    private transient ObjectInspector[] parameterInspectors = null;

+	/**

+	 * parameter inspectors

+	 */

+	private transient ObjectInspector[] parameterInspectors = null;

 

-    /**

-     * expression desc

-     */

-    private transient HashMap<Long, List<ExprNodeDesc>> parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();

+	/**

+	 * expression desc

+	 */

+	private transient HashMap<Long, List<ExprNodeDesc>> parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();

 

-    /**

-     * evaluators

-     */

-    private transient HashMap<Long, ExprNodeEvaluator[]> evaluators = new HashMap<Long, ExprNodeEvaluator[]>();

+	/**

+	 * evaluators

+	 */

+	private transient HashMap<Long, ExprNodeEvaluator[]> evaluators = new HashMap<Long, ExprNodeEvaluator[]>();

 

-    /**

-     * cached parameter objects

-     */

-    private transient HashMap<Long, Object[]> cachedParameters = new HashMap<Long, Object[]>();

+	/**

+	 * cached parameter objects

+	 */

+	private transient HashMap<Long, Object[]> cachedParameters = new HashMap<Long, Object[]>();

 

-    /**

-     * cached row object: one per thread

-     */

-    private transient HashMap<Long, LazyObject<? extends ObjectInspector>> cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();

+	/**

+	 * cached row object: one per thread

+	 */

+	private transient HashMap<Long, LazyObject<? extends ObjectInspector>> cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();

 

-    /**

-     * we only use lazy serde to do serialization

-     */

-    private transient HashMap<Long, SerDe> serDe = new HashMap<Long, SerDe>();

+	/**

+	 * we only use lazy serde to do serialization

+	 */

+	private transient HashMap<Long, SerDe> serDe = new HashMap<Long, SerDe>();

 

-    /**

-     * udaf evaluators

-     */

-    private transient HashMap<Long, GenericUDAFEvaluator> udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();

+	/**

+	 * udaf evaluators

+	 */

+	private transient HashMap<Long, GenericUDAFEvaluator> udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();

 

-    /**

-     * udaf evaluators

-     */

-    private transient HashMap<Long, GenericUDAFEvaluator> udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();

+	/**

+	 * udaf evaluators

+	 */

+	private transient HashMap<Long, GenericUDAFEvaluator> udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();

 

-    /**

-     * aggregation function desc

-     */

-    private transient AggregationDesc aggregator;

+	/**

+	 * aggregation function desc

+	 */

+	private transient AggregationDesc aggregator;

 

-    /**

-     * 

-     * @param aggregator

-     *            Algebricks function call expression

-     * @param oi

-     *            schema

-     */

-    public AggregationFunctionFactory(AggregateFunctionCallExpression expression, Schema oi,

-            IVariableTypeEnvironment env) throws AlgebricksException {

+	/**

+	 * 

+	 * @param aggregator

+	 *            Algebricks function call expression

+	 * @param oi

+	 *            schema

+	 */

+	public AggregationFunctionFactory(

+			AggregateFunctionCallExpression expression, Schema oi,

+			IVariableTypeEnvironment env) throws AlgebricksException {

 

-        try {

-            aggregator = (AggregationDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e.getMessage());

-        }

-        init(aggregator.getParameters(), aggregator.getGenericUDAFName(), aggregator.getMode(),

-                aggregator.getDistinct(), oi);

-    }

+		try {

+			aggregator = (AggregationDesc) ExpressionTranslator

+					.getHiveExpression(expression, env);

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e.getMessage());

+		}

+		init(aggregator.getParameters(), aggregator.getGenericUDAFName(),

+				aggregator.getMode(), aggregator.getDistinct(), oi);

+	}

 

-    /**

-     * constructor of aggregation function factory

-     * 

-     * @param inputs

-     * @param name

-     * @param udafMode

-     * @param distinct

-     * @param oi

-     */

-    private void init(List<ExprNodeDesc> inputs, String name, GenericUDAFEvaluator.Mode udafMode, boolean distinct,

-            Schema oi) {

-        parametersOrigin = inputs;

-        genericUDAFName = name;

-        mode = udafMode;

-        this.distinct = distinct;

-        rowSchema = oi;

+	/**

+	 * constructor of aggregation function factory

+	 * 

+	 * @param inputs

+	 * @param name

+	 * @param udafMode

+	 * @param distinct

+	 * @param oi

+	 */

+	private void init(List<ExprNodeDesc> inputs, String name,

+			GenericUDAFEvaluator.Mode udafMode, boolean distinct, Schema oi) {

+		parametersOrigin = inputs;

+		genericUDAFName = name;

+		mode = udafMode;

+		this.distinct = distinct;

+		rowSchema = oi;

 

-        for (ExprNodeDesc input : inputs) {

-            TypeInfo type = input.getTypeInfo();

-            if (type instanceof StructTypeInfo) {

-                types.add(TypeInfoFactory.doubleTypeInfo);

-            } else

-                types.add(type);

+		for (ExprNodeDesc input : inputs) {

+			TypeInfo type = input.getTypeInfo();

+			if (type instanceof StructTypeInfo) {

+				types.add(TypeInfoFactory.doubleTypeInfo);

+			} else

+				types.add(type);

 

-            String s = Utilities.serializeExpression(input);

-            parametersSerialization.add(s);

-        }

-    }

+			String s = Utilities.serializeExpression(input);

+			parametersSerialization.add(s);

+		}

+	}

 

-    @Override

-    public synchronized ICopyAggregateFunction createAggregateFunction(IDataOutputProvider provider)

-            throws AlgebricksException {

-        if (parametersOrigin == null) {

-            Configuration config = new Configuration();

-            config.setClassLoader(this.getClass().getClassLoader());

-            /**

-             * in case of class.forname(...) call in hive code

-             */

-            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

+	@Override

+	public synchronized ICopyAggregateFunction createAggregateFunction(

+			IDataOutputProvider provider) throws AlgebricksException {

+		if (parametersOrigin == null) {

+			Configuration config = new Configuration();

+			config.setClassLoader(this.getClass().getClassLoader());

+			/**

+			 * in case of class.forname(...) call in hive code

+			 */

+			Thread.currentThread().setContextClassLoader(

+					this.getClass().getClassLoader());

 

-            parametersOrigin = new ArrayList<ExprNodeDesc>();

-            for (String serialization : parametersSerialization) {

-                parametersOrigin.add(Utilities.deserializeExpression(serialization, config));

-            }

-        }

+			parametersOrigin = new ArrayList<ExprNodeDesc>();

+			for (String serialization : parametersSerialization) {

+				parametersOrigin.add(Utilities.deserializeExpression(

+						serialization, config));

+			}

+		}

 

-        /**

-         * exprs

-         */

-        if (parameterExprs == null)

-            parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();

+		/**

+		 * exprs

+		 */

+		if (parameterExprs == null)

+			parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();

 

-        /**

-         * evaluators

-         */

-        if (evaluators == null)

-            evaluators = new HashMap<Long, ExprNodeEvaluator[]>();

+		/**

+		 * evaluators

+		 */

+		if (evaluators == null)

+			evaluators = new HashMap<Long, ExprNodeEvaluator[]>();

 

-        /**

-         * cached parameter objects

-         */

-        if (cachedParameters == null)

-            cachedParameters = new HashMap<Long, Object[]>();

+		/**

+		 * cached parameter objects

+		 */

+		if (cachedParameters == null)

+			cachedParameters = new HashMap<Long, Object[]>();

 

-        /**

-         * cached row object: one per thread

-         */

-        if (cachedRowObjects == null)

-            cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();

+		/**

+		 * cached row object: one per thread

+		 */

+		if (cachedRowObjects == null)

+			cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();

 

-        /**

-         * we only use lazy serde to do serialization

-         */

-        if (serDe == null)

-            serDe = new HashMap<Long, SerDe>();

+		/**

+		 * we only use lazy serde to do serialization

+		 */

+		if (serDe == null)

+			serDe = new HashMap<Long, SerDe>();

 

-        /**

-         * UDAF functions

-         */

-        if (udafsComplete == null)

-            udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();

+		/**

+		 * UDAF functions

+		 */

+		if (udafsComplete == null)

+			udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();

 

-        /**

-         * UDAF functions

-         */

-        if (udafsPartial == null)

-            udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();

+		/**

+		 * UDAF functions

+		 */

+		if (udafsPartial == null)

+			udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();

 

-        if (parameterInspectors == null)

-            parameterInspectors = new ObjectInspector[parametersOrigin.size()];

+		if (parameterInspectors == null)

+			parameterInspectors = new ObjectInspector[parametersOrigin.size()];

 

-        if (rowInspector == null)

-            rowInspector = rowSchema.toObjectInspector();

+		if (rowInspector == null)

+			rowInspector = rowSchema.toObjectInspector();

 

-        // get current thread id

-        long threadId = Thread.currentThread().getId();

+		// get current thread id

+		long threadId = Thread.currentThread().getId();

 

-        /**

-         * expressions, expressions are thread local

-         */

-        List<ExprNodeDesc> parameters = parameterExprs.get(threadId);

-        if (parameters == null) {

-            parameters = new ArrayList<ExprNodeDesc>();

-            for (ExprNodeDesc parameter : parametersOrigin)

-                parameters.add(parameter.clone());

-            parameterExprs.put(threadId, parameters);

-        }

+		/**

+		 * expressions, expressions are thread local

+		 */

+		List<ExprNodeDesc> parameters = parameterExprs.get(threadId);

+		if (parameters == null) {

+			parameters = new ArrayList<ExprNodeDesc>();

+			for (ExprNodeDesc parameter : parametersOrigin)

+				parameters.add(parameter.clone());

+			parameterExprs.put(threadId, parameters);

+		}

 

-        /**

-         * cached parameter objects

-         */

-        Object[] cachedParas = cachedParameters.get(threadId);

-        if (cachedParas == null) {

-            cachedParas = new Object[parameters.size()];

-            cachedParameters.put(threadId, cachedParas);

-        }

+		/**

+		 * cached parameter objects

+		 */

+		Object[] cachedParas = cachedParameters.get(threadId);

+		if (cachedParas == null) {

+			cachedParas = new Object[parameters.size()];

+			cachedParameters.put(threadId, cachedParas);

+		}

 

-        /**

-         * cached row object: one per thread

-         */

-        LazyObject<? extends ObjectInspector> cachedRowObject = cachedRowObjects.get(threadId);

-        if (cachedRowObject == null) {

-            cachedRowObject = LazyFactory.createLazyObject(rowInspector);

-            cachedRowObjects.put(threadId, cachedRowObject);

-        }

+		/**

+		 * cached row object: one per thread

+		 */

+		LazyObject<? extends ObjectInspector> cachedRowObject = cachedRowObjects

+				.get(threadId);

+		if (cachedRowObject == null) {

+			cachedRowObject = LazyFactory.createLazyObject(rowInspector);

+			cachedRowObjects.put(threadId, cachedRowObject);

+		}

 

-        /**

-         * we only use lazy serde to do serialization

-         */

-        SerDe lazySer = serDe.get(threadId);

-        if (lazySer == null) {

-            lazySer = new LazySerDe();

-            serDe.put(threadId, lazySer);

-        }

+		/**

+		 * we only use lazy serde to do serialization

+		 */

+		SerDe lazySer = serDe.get(threadId);

+		if (lazySer == null) {

+			lazySer = new LazySerDe();

+			serDe.put(threadId, lazySer);

+		}

 

-        /**

-         * evaluators

-         */

-        ExprNodeEvaluator[] evals = evaluators.get(threadId);

-        if (evals == null) {

-            evals = new ExprNodeEvaluator[parameters.size()];

-            evaluators.put(threadId, evals);

-        }

+		/**

+		 * evaluators

+		 */

+		ExprNodeEvaluator[] evals = evaluators.get(threadId);

+		if (evals == null) {

+			evals = new ExprNodeEvaluator[parameters.size()];

+			evaluators.put(threadId, evals);

+		}

 

-        GenericUDAFEvaluator udafPartial;

-        GenericUDAFEvaluator udafComplete;

+		GenericUDAFEvaluator udafPartial;

+		GenericUDAFEvaluator udafComplete;

 

-        // initialize object inspectors

-        try {

-            /**

-             * evaluators, udf, object inpsectors are shared in one thread

-             */

-            for (int i = 0; i < evals.length; i++) {

-                if (evals[i] == null) {

-                    evals[i] = ExprNodeEvaluatorFactory.get(parameters.get(i));

-                    if (parameterInspectors[i] == null) {

-                        parameterInspectors[i] = evals[i].initialize(rowInspector);

-                    } else {

-                        evals[i].initialize(rowInspector);

-                    }

-                }

-            }

+		// initialize object inspectors

+		try {

+			/**

+			 * evaluators, udf, object inpsectors are shared in one thread

+			 */

+			for (int i = 0; i < evals.length; i++) {

+				if (evals[i] == null) {

+					evals[i] = ExprNodeEvaluatorFactory.get(parameters.get(i));

+					if (parameterInspectors[i] == null) {

+						parameterInspectors[i] = evals[i]

+								.initialize(rowInspector);

+					} else {

+						evals[i].initialize(rowInspector);

+					}

+				}

+			}

 

-            udafComplete = udafsComplete.get(threadId);

-            if (udafComplete == null) {

-                try {

-                    udafComplete = FunctionRegistry.getGenericUDAFEvaluator(genericUDAFName, types, distinct, false);

-                } catch (HiveException e) {

-                    throw new AlgebricksException(e);

-                }

-                udafsComplete.put(threadId, udafComplete);

-                udafComplete.init(mode, parameterInspectors);

-            }

+			udafComplete = udafsComplete.get(threadId);

+			if (udafComplete == null) {

+				try {

+					udafComplete = FunctionRegistry.getGenericUDAFEvaluator(

+							genericUDAFName, types, distinct, false);

+				} catch (HiveException e) {

+					throw new AlgebricksException(e);

+				}

+				udafsComplete.put(threadId, udafComplete);

+				udafComplete.init(mode, parameterInspectors);

+			}

 

-            // multiple stage group by, determined by the mode parameter

-            if (outputInspector == null)

-                outputInspector = udafComplete.init(mode, parameterInspectors);

+			// multiple stage group by, determined by the mode parameter

+			if (outputInspector == null)

+				outputInspector = udafComplete.init(mode, parameterInspectors);

 

-            // initial partial gby udaf

-            GenericUDAFEvaluator.Mode partialMode;

-            // adjust mode for external groupby

-            if (mode == GenericUDAFEvaluator.Mode.COMPLETE)

-                partialMode = GenericUDAFEvaluator.Mode.PARTIAL1;

-            else if (mode == GenericUDAFEvaluator.Mode.FINAL)

-                partialMode = GenericUDAFEvaluator.Mode.PARTIAL2;

-            else

-                partialMode = mode;

-            udafPartial = udafsPartial.get(threadId);

-            if (udafPartial == null) {

-                try {

-                    udafPartial = FunctionRegistry.getGenericUDAFEvaluator(genericUDAFName, types, distinct, false);

-                } catch (HiveException e) {

-                    throw new AlgebricksException(e);

-                }

-                udafPartial.init(partialMode, parameterInspectors);

-                udafsPartial.put(threadId, udafPartial);

-            }

+			// initial partial gby udaf

+			GenericUDAFEvaluator.Mode partialMode;

+			// adjust mode for external groupby

+			if (mode == GenericUDAFEvaluator.Mode.COMPLETE)

+				partialMode = GenericUDAFEvaluator.Mode.PARTIAL1;

+			else if (mode == GenericUDAFEvaluator.Mode.FINAL)

+				partialMode = GenericUDAFEvaluator.Mode.PARTIAL2;

+			else

+				partialMode = mode;

+			udafPartial = udafsPartial.get(threadId);

+			if (udafPartial == null) {

+				try {

+					udafPartial = FunctionRegistry.getGenericUDAFEvaluator(

+							genericUDAFName, types, distinct, false);

+				} catch (HiveException e) {

+					throw new AlgebricksException(e);

+				}

+				udafPartial.init(partialMode, parameterInspectors);

+				udafsPartial.put(threadId, udafPartial);

+			}

 

-            // multiple stage group by, determined by the mode parameter

-            if (outputInspectorPartial == null)

-                outputInspectorPartial = udafPartial.init(partialMode, parameterInspectors);

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e);

-        }

+			// multiple stage group by, determined by the mode parameter

+			if (outputInspectorPartial == null)

+				outputInspectorPartial = udafPartial.init(partialMode,

+						parameterInspectors);

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e);

+		}

 

-        return new AggregationFunctionEvaluator(parameters, types, genericUDAFName, mode, distinct, rowInspector,

-                provider.getDataOutput(), evals, parameterInspectors, cachedParas, lazySer, cachedRowObject,

-                udafPartial, udafComplete, outputInspector, outputInspectorPartial);

-    }

+		return new AggregationFunctionEvaluator(parameters, types,

+				genericUDAFName, mode, distinct, rowInspector,

+				provider.getDataOutput(), evals, parameterInspectors,

+				cachedParas, lazySer, cachedRowObject, udafPartial,

+				udafComplete, outputInspector, outputInspectorPartial);

+	}

 

-    public String toString() {

-        return "aggregation function expression evaluator factory: " + this.genericUDAFName;

-    }

+	public String toString() {

+		return "aggregation function expression evaluator factory: "

+				+ this.genericUDAFName;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionSerializableFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionSerializableFactory.java
index 7a48319..73717a3 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionSerializableFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/AggregationFunctionSerializableFactory.java
@@ -31,337 +31,351 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopySerializableAggregateFunction;
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopySerializableAggregateFunctionFactory;
 
-public class AggregationFunctionSerializableFactory implements ICopySerializableAggregateFunctionFactory {
+public class AggregationFunctionSerializableFactory implements
+		ICopySerializableAggregateFunctionFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    /**
-     * list of parameters' serialization
-     */
-    private List<String> parametersSerialization = new ArrayList<String>();
+	/**
+	 * list of parameters' serialization
+	 */
+	private List<String> parametersSerialization = new ArrayList<String>();
 
-    /**
-     * the name of the udf
-     */
-    private String genericUDAFName;
+	/**
+	 * the name of the udf
+	 */
+	private String genericUDAFName;
 
-    /**
-     * aggregation mode
-     */
-    private GenericUDAFEvaluator.Mode mode;
+	/**
+	 * aggregation mode
+	 */
+	private GenericUDAFEvaluator.Mode mode;
 
-    /**
-     * list of type info
-     */
-    private List<TypeInfo> types = new ArrayList<TypeInfo>();
+	/**
+	 * list of type info
+	 */
+	private List<TypeInfo> types = new ArrayList<TypeInfo>();
 
-    /**
-     * distinct or not
-     */
-    private boolean distinct;
+	/**
+	 * distinct or not
+	 */
+	private boolean distinct;
 
-    /**
-     * the schema of incoming rows
-     */
-    private Schema rowSchema;
+	/**
+	 * the schema of incoming rows
+	 */
+	private Schema rowSchema;
 
-    /**
-     * list of parameters
-     */
-    private transient List<ExprNodeDesc> parametersOrigin;
+	/**
+	 * list of parameters
+	 */
+	private transient List<ExprNodeDesc> parametersOrigin;
 
-    /**
-     * row inspector
-     */
-    private transient ObjectInspector rowInspector = null;
+	/**
+	 * row inspector
+	 */
+	private transient ObjectInspector rowInspector = null;
 
-    /**
-     * output object inspector
-     */
-    private transient ObjectInspector outputInspector = null;
+	/**
+	 * output object inspector
+	 */
+	private transient ObjectInspector outputInspector = null;
 
-    /**
-     * output object inspector
-     */
-    private transient ObjectInspector outputInspectorPartial = null;
+	/**
+	 * output object inspector
+	 */
+	private transient ObjectInspector outputInspectorPartial = null;
 
-    /**
-     * parameter inspectors
-     */
-    private transient ObjectInspector[] parameterInspectors = null;
+	/**
+	 * parameter inspectors
+	 */
+	private transient ObjectInspector[] parameterInspectors = null;
 
-    /**
-     * expression desc
-     */
-    private transient HashMap<Long, List<ExprNodeDesc>> parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();
+	/**
+	 * expression desc
+	 */
+	private transient HashMap<Long, List<ExprNodeDesc>> parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();
 
-    /**
-     * evaluators
-     */
-    private transient HashMap<Long, ExprNodeEvaluator[]> evaluators = new HashMap<Long, ExprNodeEvaluator[]>();
+	/**
+	 * evaluators
+	 */
+	private transient HashMap<Long, ExprNodeEvaluator[]> evaluators = new HashMap<Long, ExprNodeEvaluator[]>();
 
-    /**
-     * cached parameter objects
-     */
-    private transient HashMap<Long, Object[]> cachedParameters = new HashMap<Long, Object[]>();
+	/**
+	 * cached parameter objects
+	 */
+	private transient HashMap<Long, Object[]> cachedParameters = new HashMap<Long, Object[]>();
 
-    /**
-     * cached row object: one per thread
-     */
-    private transient HashMap<Long, LazyObject<? extends ObjectInspector>> cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();
+	/**
+	 * cached row object: one per thread
+	 */
+	private transient HashMap<Long, LazyObject<? extends ObjectInspector>> cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();
 
-    /**
-     * we only use lazy serde to do serialization
-     */
-    private transient HashMap<Long, SerDe> serDe = new HashMap<Long, SerDe>();
+	/**
+	 * we only use lazy serde to do serialization
+	 */
+	private transient HashMap<Long, SerDe> serDe = new HashMap<Long, SerDe>();
 
-    /**
-     * udaf evaluators
-     */
-    private transient HashMap<Long, GenericUDAFEvaluator> udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();
+	/**
+	 * udaf evaluators
+	 */
+	private transient HashMap<Long, GenericUDAFEvaluator> udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();
 
-    /**
-     * udaf evaluators
-     */
-    private transient HashMap<Long, GenericUDAFEvaluator> udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();
+	/**
+	 * udaf evaluators
+	 */
+	private transient HashMap<Long, GenericUDAFEvaluator> udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();
 
-    /**
-     * aggregation function desc
-     */
-    private transient AggregationDesc aggregator;
+	/**
+	 * aggregation function desc
+	 */
+	private transient AggregationDesc aggregator;
 
-    /**
-     * 
-     * @param aggregator
-     *            Algebricks function call expression
-     * @param oi
-     *            schema
-     */
-    public AggregationFunctionSerializableFactory(AggregateFunctionCallExpression expression, Schema oi,
-            IVariableTypeEnvironment env) throws AlgebricksException {
+	/**
+	 * 
+	 * @param aggregator
+	 *            Algebricks function call expression
+	 * @param oi
+	 *            schema
+	 */
+	public AggregationFunctionSerializableFactory(
+			AggregateFunctionCallExpression expression, Schema oi,
+			IVariableTypeEnvironment env) throws AlgebricksException {
 
-        try {
-            aggregator = (AggregationDesc) ExpressionTranslator.getHiveExpression(expression, env);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new AlgebricksException(e.getMessage());
-        }
-        init(aggregator.getParameters(), aggregator.getGenericUDAFName(), aggregator.getMode(),
-                aggregator.getDistinct(), oi);
-    }
+		try {
+			aggregator = (AggregationDesc) ExpressionTranslator
+					.getHiveExpression(expression, env);
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new AlgebricksException(e.getMessage());
+		}
+		init(aggregator.getParameters(), aggregator.getGenericUDAFName(),
+				aggregator.getMode(), aggregator.getDistinct(), oi);
+	}
 
-    /**
-     * constructor of aggregation function factory
-     * 
-     * @param inputs
-     * @param name
-     * @param udafMode
-     * @param distinct
-     * @param oi
-     */
-    private void init(List<ExprNodeDesc> inputs, String name, GenericUDAFEvaluator.Mode udafMode, boolean distinct,
-            Schema oi) {
-        parametersOrigin = inputs;
-        genericUDAFName = name;
-        mode = udafMode;
-        this.distinct = distinct;
-        rowSchema = oi;
+	/**
+	 * constructor of aggregation function factory
+	 * 
+	 * @param inputs
+	 * @param name
+	 * @param udafMode
+	 * @param distinct
+	 * @param oi
+	 */
+	private void init(List<ExprNodeDesc> inputs, String name,
+			GenericUDAFEvaluator.Mode udafMode, boolean distinct, Schema oi) {
+		parametersOrigin = inputs;
+		genericUDAFName = name;
+		mode = udafMode;
+		this.distinct = distinct;
+		rowSchema = oi;
 
-        for (ExprNodeDesc input : inputs) {
-            TypeInfo type = input.getTypeInfo();
-            if (type instanceof StructTypeInfo) {
-                types.add(TypeInfoFactory.doubleTypeInfo);
-            } else
-                types.add(type);
+		for (ExprNodeDesc input : inputs) {
+			TypeInfo type = input.getTypeInfo();
+			if (type instanceof StructTypeInfo) {
+				types.add(TypeInfoFactory.doubleTypeInfo);
+			} else
+				types.add(type);
 
-            String s = Utilities.serializeExpression(input);
-            parametersSerialization.add(s);
-        }
-    }
+			String s = Utilities.serializeExpression(input);
+			parametersSerialization.add(s);
+		}
+	}
 
-    @Override
-    public synchronized ICopySerializableAggregateFunction createAggregateFunction() throws AlgebricksException {
-        if (parametersOrigin == null) {
-            Configuration config = new Configuration();
-            config.setClassLoader(this.getClass().getClassLoader());
-            /**
-             * in case of class.forname(...) call in hive code
-             */
-            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+	@Override
+	public synchronized ICopySerializableAggregateFunction createAggregateFunction()
+			throws AlgebricksException {
+		if (parametersOrigin == null) {
+			Configuration config = new Configuration();
+			config.setClassLoader(this.getClass().getClassLoader());
+			/**
+			 * in case of class.forname(...) call in hive code
+			 */
+			Thread.currentThread().setContextClassLoader(
+					this.getClass().getClassLoader());
 
-            parametersOrigin = new ArrayList<ExprNodeDesc>();
-            for (String serialization : parametersSerialization) {
-                parametersOrigin.add(Utilities.deserializeExpression(serialization, config));
-            }
-        }
+			parametersOrigin = new ArrayList<ExprNodeDesc>();
+			for (String serialization : parametersSerialization) {
+				parametersOrigin.add(Utilities.deserializeExpression(
+						serialization, config));
+			}
+		}
 
-        /**
-         * exprs
-         */
-        if (parameterExprs == null)
-            parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();
+		/**
+		 * exprs
+		 */
+		if (parameterExprs == null)
+			parameterExprs = new HashMap<Long, List<ExprNodeDesc>>();
 
-        /**
-         * evaluators
-         */
-        if (evaluators == null)
-            evaluators = new HashMap<Long, ExprNodeEvaluator[]>();
+		/**
+		 * evaluators
+		 */
+		if (evaluators == null)
+			evaluators = new HashMap<Long, ExprNodeEvaluator[]>();
 
-        /**
-         * cached parameter objects
-         */
-        if (cachedParameters == null)
-            cachedParameters = new HashMap<Long, Object[]>();
+		/**
+		 * cached parameter objects
+		 */
+		if (cachedParameters == null)
+			cachedParameters = new HashMap<Long, Object[]>();
 
-        /**
-         * cached row object: one per thread
-         */
-        if (cachedRowObjects == null)
-            cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();
+		/**
+		 * cached row object: one per thread
+		 */
+		if (cachedRowObjects == null)
+			cachedRowObjects = new HashMap<Long, LazyObject<? extends ObjectInspector>>();
 
-        /**
-         * we only use lazy serde to do serialization
-         */
-        if (serDe == null)
-            serDe = new HashMap<Long, SerDe>();
+		/**
+		 * we only use lazy serde to do serialization
+		 */
+		if (serDe == null)
+			serDe = new HashMap<Long, SerDe>();
 
-        /**
-         * UDAF functions
-         */
-        if (udafsComplete == null)
-            udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();
+		/**
+		 * UDAF functions
+		 */
+		if (udafsComplete == null)
+			udafsComplete = new HashMap<Long, GenericUDAFEvaluator>();
 
-        /**
-         * UDAF functions
-         */
-        if (udafsPartial == null)
-            udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();
+		/**
+		 * UDAF functions
+		 */
+		if (udafsPartial == null)
+			udafsPartial = new HashMap<Long, GenericUDAFEvaluator>();
 
-        if (parameterInspectors == null)
-            parameterInspectors = new ObjectInspector[parametersOrigin.size()];
+		if (parameterInspectors == null)
+			parameterInspectors = new ObjectInspector[parametersOrigin.size()];
 
-        if (rowInspector == null)
-            rowInspector = rowSchema.toObjectInspector();
+		if (rowInspector == null)
+			rowInspector = rowSchema.toObjectInspector();
 
-        // get current thread id
-        long threadId = Thread.currentThread().getId();
+		// get current thread id
+		long threadId = Thread.currentThread().getId();
 
-        /**
-         * expressions, expressions are thread local
-         */
-        List<ExprNodeDesc> parameters = parameterExprs.get(threadId);
-        if (parameters == null) {
-            parameters = new ArrayList<ExprNodeDesc>();
-            for (ExprNodeDesc parameter : parametersOrigin)
-                parameters.add(parameter.clone());
-            parameterExprs.put(threadId, parameters);
-        }
+		/**
+		 * expressions, expressions are thread local
+		 */
+		List<ExprNodeDesc> parameters = parameterExprs.get(threadId);
+		if (parameters == null) {
+			parameters = new ArrayList<ExprNodeDesc>();
+			for (ExprNodeDesc parameter : parametersOrigin)
+				parameters.add(parameter.clone());
+			parameterExprs.put(threadId, parameters);
+		}
 
-        /**
-         * cached parameter objects
-         */
-        Object[] cachedParas = cachedParameters.get(threadId);
-        if (cachedParas == null) {
-            cachedParas = new Object[parameters.size()];
-            cachedParameters.put(threadId, cachedParas);
-        }
+		/**
+		 * cached parameter objects
+		 */
+		Object[] cachedParas = cachedParameters.get(threadId);
+		if (cachedParas == null) {
+			cachedParas = new Object[parameters.size()];
+			cachedParameters.put(threadId, cachedParas);
+		}
 
-        /**
-         * cached row object: one per thread
-         */
-        LazyObject<? extends ObjectInspector> cachedRowObject = cachedRowObjects.get(threadId);
-        if (cachedRowObject == null) {
-            cachedRowObject = LazyFactory.createLazyObject(rowInspector);
-            cachedRowObjects.put(threadId, cachedRowObject);
-        }
+		/**
+		 * cached row object: one per thread
+		 */
+		LazyObject<? extends ObjectInspector> cachedRowObject = cachedRowObjects
+				.get(threadId);
+		if (cachedRowObject == null) {
+			cachedRowObject = LazyFactory.createLazyObject(rowInspector);
+			cachedRowObjects.put(threadId, cachedRowObject);
+		}
 
-        /**
-         * we only use lazy serde to do serialization
-         */
-        SerDe lazySer = serDe.get(threadId);
-        if (lazySer == null) {
-            lazySer = new LazySerDe();
-            serDe.put(threadId, lazySer);
-        }
+		/**
+		 * we only use lazy serde to do serialization
+		 */
+		SerDe lazySer = serDe.get(threadId);
+		if (lazySer == null) {
+			lazySer = new LazySerDe();
+			serDe.put(threadId, lazySer);
+		}
 
-        /**
-         * evaluators
-         */
-        ExprNodeEvaluator[] evals = evaluators.get(threadId);
-        if (evals == null) {
-            evals = new ExprNodeEvaluator[parameters.size()];
-            evaluators.put(threadId, evals);
-        }
+		/**
+		 * evaluators
+		 */
+		ExprNodeEvaluator[] evals = evaluators.get(threadId);
+		if (evals == null) {
+			evals = new ExprNodeEvaluator[parameters.size()];
+			evaluators.put(threadId, evals);
+		}
 
-        GenericUDAFEvaluator udafPartial;
-        GenericUDAFEvaluator udafComplete;
+		GenericUDAFEvaluator udafPartial;
+		GenericUDAFEvaluator udafComplete;
 
-        // initialize object inspectors
-        try {
-            /**
-             * evaluators, udf, object inpsectors are shared in one thread
-             */
-            for (int i = 0; i < evals.length; i++) {
-                if (evals[i] == null) {
-                    evals[i] = ExprNodeEvaluatorFactory.get(parameters.get(i));
-                    if (parameterInspectors[i] == null) {
-                        parameterInspectors[i] = evals[i].initialize(rowInspector);
-                    } else {
-                        evals[i].initialize(rowInspector);
-                    }
-                }
-            }
+		// initialize object inspectors
+		try {
+			/**
+			 * evaluators, udf, object inpsectors are shared in one thread
+			 */
+			for (int i = 0; i < evals.length; i++) {
+				if (evals[i] == null) {
+					evals[i] = ExprNodeEvaluatorFactory.get(parameters.get(i));
+					if (parameterInspectors[i] == null) {
+						parameterInspectors[i] = evals[i]
+								.initialize(rowInspector);
+					} else {
+						evals[i].initialize(rowInspector);
+					}
+				}
+			}
 
-            udafComplete = udafsComplete.get(threadId);
-            if (udafComplete == null) {
-                try {
-                    udafComplete = FunctionRegistry.getGenericUDAFEvaluator(genericUDAFName, types, distinct, false);
-                } catch (HiveException e) {
-                    throw new AlgebricksException(e);
-                }
-                udafsComplete.put(threadId, udafComplete);
-                udafComplete.init(mode, parameterInspectors);
-            }
+			udafComplete = udafsComplete.get(threadId);
+			if (udafComplete == null) {
+				try {
+					udafComplete = FunctionRegistry.getGenericUDAFEvaluator(
+							genericUDAFName, types, distinct, false);
+				} catch (HiveException e) {
+					throw new AlgebricksException(e);
+				}
+				udafsComplete.put(threadId, udafComplete);
+				udafComplete.init(mode, parameterInspectors);
+			}
 
-            // multiple stage group by, determined by the mode parameter
-            if (outputInspector == null)
-                outputInspector = udafComplete.init(mode, parameterInspectors);
+			// multiple stage group by, determined by the mode parameter
+			if (outputInspector == null)
+				outputInspector = udafComplete.init(mode, parameterInspectors);
 
-            // initial partial gby udaf
-            GenericUDAFEvaluator.Mode partialMode;
-            // adjust mode for external groupby
-            if (mode == GenericUDAFEvaluator.Mode.COMPLETE)
-                partialMode = GenericUDAFEvaluator.Mode.PARTIAL1;
-            else if (mode == GenericUDAFEvaluator.Mode.FINAL)
-                partialMode = GenericUDAFEvaluator.Mode.PARTIAL2;
-            else
-                partialMode = mode;
-            udafPartial = udafsPartial.get(threadId);
-            if (udafPartial == null) {
-                try {
-                    udafPartial = FunctionRegistry.getGenericUDAFEvaluator(genericUDAFName, types, distinct, false);
-                } catch (HiveException e) {
-                    throw new AlgebricksException(e);
-                }
-                udafPartial.init(partialMode, parameterInspectors);
-                udafsPartial.put(threadId, udafPartial);
-            }
+			// initial partial gby udaf
+			GenericUDAFEvaluator.Mode partialMode;
+			// adjust mode for external groupby
+			if (mode == GenericUDAFEvaluator.Mode.COMPLETE)
+				partialMode = GenericUDAFEvaluator.Mode.PARTIAL1;
+			else if (mode == GenericUDAFEvaluator.Mode.FINAL)
+				partialMode = GenericUDAFEvaluator.Mode.PARTIAL2;
+			else
+				partialMode = mode;
+			udafPartial = udafsPartial.get(threadId);
+			if (udafPartial == null) {
+				try {
+					udafPartial = FunctionRegistry.getGenericUDAFEvaluator(
+							genericUDAFName, types, distinct, false);
+				} catch (HiveException e) {
+					throw new AlgebricksException(e);
+				}
+				udafPartial.init(partialMode, parameterInspectors);
+				udafsPartial.put(threadId, udafPartial);
+			}
 
-            // multiple stage group by, determined by the mode parameter
-            if (outputInspectorPartial == null)
-                outputInspectorPartial = udafPartial.init(partialMode, parameterInspectors);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new AlgebricksException(e);
-        }
+			// multiple stage group by, determined by the mode parameter
+			if (outputInspectorPartial == null)
+				outputInspectorPartial = udafPartial.init(partialMode,
+						parameterInspectors);
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new AlgebricksException(e);
+		}
 
-        return new AggregatuibFunctionSerializableEvaluator(parameters, types, genericUDAFName, mode, distinct,
-                rowInspector, evals, parameterInspectors, cachedParas, lazySer, cachedRowObject, udafPartial,
-                udafComplete, outputInspector, outputInspectorPartial);
-    }
+		return new AggregatuibFunctionSerializableEvaluator(parameters, types,
+				genericUDAFName, mode, distinct, rowInspector, evals,
+				parameterInspectors, cachedParas, lazySer, cachedRowObject,
+				udafPartial, udafComplete, outputInspector,
+				outputInspectorPartial);
+	}
 
-    public String toString() {
-        return "aggregation function expression evaluator factory: " + this.genericUDAFName;
-    }
+	public String toString() {
+		return "aggregation function expression evaluator factory: "
+				+ this.genericUDAFName;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ColumnExpressionEvaluatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ColumnExpressionEvaluatorFactory.java
index dc21be7..68bf408 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ColumnExpressionEvaluatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ColumnExpressionEvaluatorFactory.java
@@ -14,28 +14,32 @@
 

 public class ColumnExpressionEvaluatorFactory implements ICopyEvaluatorFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private ExprNodeColumnDesc expr;

+	private ExprNodeColumnDesc expr;

 

-    private Schema inputSchema;

+	private Schema inputSchema;

 

-    public ColumnExpressionEvaluatorFactory(ILogicalExpression expression, Schema schema, IVariableTypeEnvironment env)

-            throws AlgebricksException {

-        try {

-            expr = (ExprNodeColumnDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            throw new AlgebricksException(e.getMessage());

-        }

-        inputSchema = schema;

-    }

+	public ColumnExpressionEvaluatorFactory(ILogicalExpression expression,

+			Schema schema, IVariableTypeEnvironment env)

+			throws AlgebricksException {

+		try {

+			expr = (ExprNodeColumnDesc) ExpressionTranslator.getHiveExpression(

+					expression, env);

+		} catch (Exception e) {

+			throw new AlgebricksException(e.getMessage());

+		}

+		inputSchema = schema;

+	}

 

-    public ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {

-        return new ColumnExpressionEvaluator(expr, inputSchema.toObjectInspector(), output);

-    }

+	public ICopyEvaluator createEvaluator(IDataOutputProvider output)

+			throws AlgebricksException {

+		return new ColumnExpressionEvaluator(expr,

+				inputSchema.toObjectInspector(), output);

+	}

 

-    public String toString() {

-        return "column expression evaluator factory: " + expr.toString();

-    }

+	public String toString() {

+		return "column expression evaluator factory: " + expr.toString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ConstantExpressionEvaluatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ConstantExpressionEvaluatorFactory.java
index 69e2171..e0241a1 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ConstantExpressionEvaluatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ConstantExpressionEvaluatorFactory.java
@@ -12,30 +12,35 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;

 import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;

 

-public class ConstantExpressionEvaluatorFactory implements ICopyEvaluatorFactory {

+public class ConstantExpressionEvaluatorFactory implements

+		ICopyEvaluatorFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private ExprNodeConstantDesc expr;

+	private ExprNodeConstantDesc expr;

 

-    private Schema schema;

+	private Schema schema;

 

-    public ConstantExpressionEvaluatorFactory(ILogicalExpression expression, Schema inputSchema,

-            IVariableTypeEnvironment env) throws AlgebricksException {

-        try {

-            expr = (ExprNodeConstantDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            throw new AlgebricksException(e.getMessage());

-        }

-        schema = inputSchema;

-    }

+	public ConstantExpressionEvaluatorFactory(ILogicalExpression expression,

+			Schema inputSchema, IVariableTypeEnvironment env)

+			throws AlgebricksException {

+		try {

+			expr = (ExprNodeConstantDesc) ExpressionTranslator

+					.getHiveExpression(expression, env);

+		} catch (Exception e) {

+			throw new AlgebricksException(e.getMessage());

+		}

+		schema = inputSchema;

+	}

 

-    public ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {

-        return new ConstantExpressionEvaluator(expr, schema.toObjectInspector(), output);

-    }

+	public ICopyEvaluator createEvaluator(IDataOutputProvider output)

+			throws AlgebricksException {

+		return new ConstantExpressionEvaluator(expr,

+				schema.toObjectInspector(), output);

+	}

 

-    public String toString() {

-        return "constant expression evaluator factory: " + expr.toString();

-    }

+	public String toString() {

+		return "constant expression evaluator factory: " + expr.toString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/FieldExpressionEvaluatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/FieldExpressionEvaluatorFactory.java
index eddfb9b..4b5f906 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/FieldExpressionEvaluatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/FieldExpressionEvaluatorFactory.java
@@ -13,28 +13,32 @@
 import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;

 

 public class FieldExpressionEvaluatorFactory implements ICopyEvaluatorFactory {

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private ExprNodeFieldDesc expr;

+	private ExprNodeFieldDesc expr;

 

-    private Schema inputSchema;

+	private Schema inputSchema;

 

-    public FieldExpressionEvaluatorFactory(ILogicalExpression expression, Schema schema, IVariableTypeEnvironment env)

-            throws AlgebricksException {

-        try {

-            expr = (ExprNodeFieldDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            throw new AlgebricksException(e.getMessage());

-        }

-        inputSchema = schema;

-    }

+	public FieldExpressionEvaluatorFactory(ILogicalExpression expression,

+			Schema schema, IVariableTypeEnvironment env)

+			throws AlgebricksException {

+		try {

+			expr = (ExprNodeFieldDesc) ExpressionTranslator.getHiveExpression(

+					expression, env);

+		} catch (Exception e) {

+			throw new AlgebricksException(e.getMessage());

+		}

+		inputSchema = schema;

+	}

 

-    public ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {

-        return new FieldExpressionEvaluator(expr, inputSchema.toObjectInspector(), output);

-    }

+	public ICopyEvaluator createEvaluator(IDataOutputProvider output)

+			throws AlgebricksException {

+		return new FieldExpressionEvaluator(expr,

+				inputSchema.toObjectInspector(), output);

+	}

 

-    public String toString() {

-        return "field access expression evaluator factory: " + expr.toString();

-    }

+	public String toString() {

+		return "field access expression evaluator factory: " + expr.toString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/HiveExpressionRuntimeProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/HiveExpressionRuntimeProvider.java
index 842d96e..387ca72 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/HiveExpressionRuntimeProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/HiveExpressionRuntimeProvider.java
@@ -34,134 +34,159 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;

 import edu.uci.ics.hyracks.algebricks.runtime.base.IUnnestingEvaluatorFactory;

 

-public class HiveExpressionRuntimeProvider implements IExpressionRuntimeProvider {

+public class HiveExpressionRuntimeProvider implements

+		IExpressionRuntimeProvider {

 

-    public static final IExpressionRuntimeProvider INSTANCE = new HiveExpressionRuntimeProvider();

+	public static final IExpressionRuntimeProvider INSTANCE = new HiveExpressionRuntimeProvider();

 

-    @Override

-    public IAggregateEvaluatorFactory createAggregateFunctionFactory(AggregateFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new AggregateFunctionFactoryAdapter(new AggregationFunctionFactory(expr, schema, env));

-    }

+	@Override

+	public IAggregateEvaluatorFactory createAggregateFunctionFactory(

+			AggregateFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new AggregateFunctionFactoryAdapter(

+				new AggregationFunctionFactory(expr, schema, env));

+	}

 

-    @Override

-    public ICopySerializableAggregateFunctionFactory createSerializableAggregateFunctionFactory(

-            AggregateFunctionCallExpression expr, IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas,

-            JobGenContext context) throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new AggregationFunctionSerializableFactory(expr, schema, env);

-    }

+	@Override

+	public ICopySerializableAggregateFunctionFactory createSerializableAggregateFunctionFactory(

+			AggregateFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new AggregationFunctionSerializableFactory(expr, schema, env);

+	}

 

-    @Override

-    public IRunningAggregateEvaluatorFactory createRunningAggregateFunctionFactory(StatefulFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public IRunningAggregateEvaluatorFactory createRunningAggregateFunctionFactory(

+			StatefulFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public IUnnestingEvaluatorFactory createUnnestingFunctionFactory(UnnestingFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new UnnestingFunctionFactoryAdapter(new UnnestingFunctionFactory(expr, schema, env));

-    }

+	@Override

+	public IUnnestingEvaluatorFactory createUnnestingFunctionFactory(

+			UnnestingFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new UnnestingFunctionFactoryAdapter(

+				new UnnestingFunctionFactory(expr, schema, env));

+	}

 

-    public IScalarEvaluatorFactory createEvaluatorFactory(ILogicalExpression expr, IVariableTypeEnvironment env,

-            IOperatorSchema[] inputSchemas, JobGenContext context) throws AlgebricksException {

-        switch (expr.getExpressionTag()) {

-            case VARIABLE: {

-                VariableReferenceExpression v = (VariableReferenceExpression) expr;

-                return new ScalarEvaluatorFactoryAdapter(createVariableEvaluatorFactory(v, env, inputSchemas, context));

-            }

-            case CONSTANT: {

-                ConstantExpression c = (ConstantExpression) expr;

-                return new ScalarEvaluatorFactoryAdapter(createConstantEvaluatorFactory(c, env, inputSchemas, context));

-            }

-            case FUNCTION_CALL: {

-                AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) expr;

-                FunctionIdentifier fid = fun.getFunctionIdentifier();

+	public IScalarEvaluatorFactory createEvaluatorFactory(

+			ILogicalExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		switch (expr.getExpressionTag()) {

+		case VARIABLE: {

+			VariableReferenceExpression v = (VariableReferenceExpression) expr;

+			return new ScalarEvaluatorFactoryAdapter(

+					createVariableEvaluatorFactory(v, env, inputSchemas,

+							context));

+		}

+		case CONSTANT: {

+			ConstantExpression c = (ConstantExpression) expr;

+			return new ScalarEvaluatorFactoryAdapter(

+					createConstantEvaluatorFactory(c, env, inputSchemas,

+							context));

+		}

+		case FUNCTION_CALL: {

+			AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) expr;

+			FunctionIdentifier fid = fun.getFunctionIdentifier();

 

-                if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

-                    return new ScalarEvaluatorFactoryAdapter(createFieldExpressionEvaluatorFactory(fun, env,

-                            inputSchemas, context));

-                }

+			if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

+				return new ScalarEvaluatorFactoryAdapter(

+						createFieldExpressionEvaluatorFactory(fun, env,

+								inputSchemas, context));

+			}

 

-                if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

-                    return new ScalarEvaluatorFactoryAdapter(createNullExpressionEvaluatorFactory(fun, env,

-                            inputSchemas, context));

-                }

+			if (fid.getName().equals(ExpressionConstant.FIELDACCESS)) {

+				return new ScalarEvaluatorFactoryAdapter(

+						createNullExpressionEvaluatorFactory(fun, env,

+								inputSchemas, context));

+			}

 

-                if (fun.getKind() == FunctionKind.SCALAR) {

-                    ScalarFunctionCallExpression scalar = (ScalarFunctionCallExpression) fun;

-                    return new ScalarEvaluatorFactoryAdapter(createScalarFunctionEvaluatorFactory(scalar, env,

-                            inputSchemas, context));

-                } else {

-                    throw new AlgebricksException("Cannot create evaluator for function " + fun + " of kind "

-                            + fun.getKind());

-                }

-            }

-            default: {

-                throw new IllegalStateException();

-            }

-        }

-    }

+			if (fun.getKind() == FunctionKind.SCALAR) {

+				ScalarFunctionCallExpression scalar = (ScalarFunctionCallExpression) fun;

+				return new ScalarEvaluatorFactoryAdapter(

+						createScalarFunctionEvaluatorFactory(scalar, env,

+								inputSchemas, context));

+			} else {

+				throw new AlgebricksException(

+						"Cannot create evaluator for function " + fun

+								+ " of kind " + fun.getKind());

+			}

+		}

+		default: {

+			throw new IllegalStateException();

+		}

+		}

+	}

 

-    private ICopyEvaluatorFactory createVariableEvaluatorFactory(VariableReferenceExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new ColumnExpressionEvaluatorFactory(expr, schema, env);

-    }

+	private ICopyEvaluatorFactory createVariableEvaluatorFactory(

+			VariableReferenceExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new ColumnExpressionEvaluatorFactory(expr, schema, env);

+	}

 

-    private ICopyEvaluatorFactory createScalarFunctionEvaluatorFactory(AbstractFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        List<String> names = new ArrayList<String>();

-        List<TypeInfo> types = new ArrayList<TypeInfo>();

-        for (IOperatorSchema inputSchema : inputSchemas) {

-            Schema schema = this.getSchema(inputSchema, env);

-            names.addAll(schema.getNames());

-            types.addAll(schema.getTypes());

-        }

-        Schema inputSchema = new Schema(names, types);

-        return new ScalarFunctionExpressionEvaluatorFactory(expr, inputSchema, env);

-    }

+	private ICopyEvaluatorFactory createScalarFunctionEvaluatorFactory(

+			AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		List<String> names = new ArrayList<String>();

+		List<TypeInfo> types = new ArrayList<TypeInfo>();

+		for (IOperatorSchema inputSchema : inputSchemas) {

+			Schema schema = this.getSchema(inputSchema, env);

+			names.addAll(schema.getNames());

+			types.addAll(schema.getTypes());

+		}

+		Schema inputSchema = new Schema(names, types);

+		return new ScalarFunctionExpressionEvaluatorFactory(expr, inputSchema,

+				env);

+	}

 

-    private ICopyEvaluatorFactory createFieldExpressionEvaluatorFactory(AbstractFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new FieldExpressionEvaluatorFactory(expr, schema, env);

-    }

+	private ICopyEvaluatorFactory createFieldExpressionEvaluatorFactory(

+			AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new FieldExpressionEvaluatorFactory(expr, schema, env);

+	}

 

-    private ICopyEvaluatorFactory createNullExpressionEvaluatorFactory(AbstractFunctionCallExpression expr,

-            IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)

-            throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new NullExpressionEvaluatorFactory(expr, schema, env);

-    }

+	private ICopyEvaluatorFactory createNullExpressionEvaluatorFactory(

+			AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new NullExpressionEvaluatorFactory(expr, schema, env);

+	}

 

-    private ICopyEvaluatorFactory createConstantEvaluatorFactory(ConstantExpression expr, IVariableTypeEnvironment env,

-            IOperatorSchema[] inputSchemas, JobGenContext context) throws AlgebricksException {

-        Schema schema = this.getSchema(inputSchemas[0], env);

-        return new ConstantExpressionEvaluatorFactory(expr, schema, env);

-    }

+	private ICopyEvaluatorFactory createConstantEvaluatorFactory(

+			ConstantExpression expr, IVariableTypeEnvironment env,

+			IOperatorSchema[] inputSchemas, JobGenContext context)

+			throws AlgebricksException {

+		Schema schema = this.getSchema(inputSchemas[0], env);

+		return new ConstantExpressionEvaluatorFactory(expr, schema, env);

+	}

 

-    private Schema getSchema(IOperatorSchema inputSchema, IVariableTypeEnvironment env) throws AlgebricksException {

-        List<String> names = new ArrayList<String>();

-        List<TypeInfo> types = new ArrayList<TypeInfo>();

-        Iterator<LogicalVariable> variables = inputSchema.iterator();

-        while (variables.hasNext()) {

-            LogicalVariable var = variables.next();

-            names.add(var.toString());

-            types.add((TypeInfo) env.getVarType(var));

-        }

+	private Schema getSchema(IOperatorSchema inputSchema,

+			IVariableTypeEnvironment env) throws AlgebricksException {

+		List<String> names = new ArrayList<String>();

+		List<TypeInfo> types = new ArrayList<TypeInfo>();

+		Iterator<LogicalVariable> variables = inputSchema.iterator();

+		while (variables.hasNext()) {

+			LogicalVariable var = variables.next();

+			names.add(var.toString());

+			types.add((TypeInfo) env.getVarType(var));

+		}

 

-        Schema schema = new Schema(names, types);

-        return schema;

-    }

+		Schema schema = new Schema(names, types);

+		return schema;

+	}

 

 }
\ No newline at end of file
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/NullExpressionEvaluatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/NullExpressionEvaluatorFactory.java
index 075ed91..8f516e8 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/NullExpressionEvaluatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/NullExpressionEvaluatorFactory.java
@@ -14,28 +14,32 @@
 

 public class NullExpressionEvaluatorFactory implements ICopyEvaluatorFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private ExprNodeNullDesc expr;

+	private ExprNodeNullDesc expr;

 

-    private Schema schema;

+	private Schema schema;

 

-    public NullExpressionEvaluatorFactory(ILogicalExpression expression, Schema intputSchema,

-            IVariableTypeEnvironment env) throws AlgebricksException {

-        try {

-            expr = (ExprNodeNullDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            throw new AlgebricksException(e.getMessage());

-        }

-        schema = intputSchema;

-    }

+	public NullExpressionEvaluatorFactory(ILogicalExpression expression,

+			Schema intputSchema, IVariableTypeEnvironment env)

+			throws AlgebricksException {

+		try {

+			expr = (ExprNodeNullDesc) ExpressionTranslator.getHiveExpression(

+					expression, env);

+		} catch (Exception e) {

+			throw new AlgebricksException(e.getMessage());

+		}

+		schema = intputSchema;

+	}

 

-    public ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {

-        return new NullExpressionEvaluator(expr, schema.toObjectInspector(), output);

-    }

+	public ICopyEvaluator createEvaluator(IDataOutputProvider output)

+			throws AlgebricksException {

+		return new NullExpressionEvaluator(expr, schema.toObjectInspector(),

+				output);

+	}

 

-    public String toString() {

-        return "null expression evaluator factory: " + expr.toString();

-    }

+	public String toString() {

+		return "null expression evaluator factory: " + expr.toString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ScalarFunctionExpressionEvaluatorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ScalarFunctionExpressionEvaluatorFactory.java
index fe7ddfb..262758e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ScalarFunctionExpressionEvaluatorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/ScalarFunctionExpressionEvaluatorFactory.java
@@ -14,56 +14,64 @@
 import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;

 import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;

 

-public class ScalarFunctionExpressionEvaluatorFactory implements ICopyEvaluatorFactory {

+public class ScalarFunctionExpressionEvaluatorFactory implements

+		ICopyEvaluatorFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private transient ExprNodeGenericFuncDesc expr;

+	private transient ExprNodeGenericFuncDesc expr;

 

-    private String exprSerialization;

+	private String exprSerialization;

 

-    private Schema inputSchema;

+	private Schema inputSchema;

 

-    private transient Configuration config;

+	private transient Configuration config;

 

-    public ScalarFunctionExpressionEvaluatorFactory(ILogicalExpression expression, Schema schema,

-            IVariableTypeEnvironment env) throws AlgebricksException {

-        try {

-            expr = (ExprNodeGenericFuncDesc) ExpressionTranslator.getHiveExpression(expression, env);

+	public ScalarFunctionExpressionEvaluatorFactory(

+			ILogicalExpression expression, Schema schema,

+			IVariableTypeEnvironment env) throws AlgebricksException {

+		try {

+			expr = (ExprNodeGenericFuncDesc) ExpressionTranslator

+					.getHiveExpression(expression, env);

 

-            exprSerialization = Utilities.serializeExpression(expr);

+			exprSerialization = Utilities.serializeExpression(expr);

 

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new AlgebricksException(e.getMessage());

-        }

-        inputSchema = schema;

-    }

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new AlgebricksException(e.getMessage());

+		}

+		inputSchema = schema;

+	}

 

-    public synchronized ICopyEvaluator createEvaluator(IDataOutputProvider output) throws AlgebricksException {

-        if (expr == null) {

-            configClassLoader();

-            expr = (ExprNodeGenericFuncDesc) Utilities.deserializeExpression(exprSerialization, config);

-        }

+	public synchronized ICopyEvaluator createEvaluator(

+			IDataOutputProvider output) throws AlgebricksException {

+		if (expr == null) {

+			configClassLoader();

+			expr = (ExprNodeGenericFuncDesc) Utilities.deserializeExpression(

+					exprSerialization, config);

+		}

 

-        ExprNodeGenericFuncDesc funcDesc = (ExprNodeGenericFuncDesc) expr.clone();

-        return new FunctionExpressionEvaluator(funcDesc, inputSchema.toObjectInspector(), output);

-    }

+		ExprNodeGenericFuncDesc funcDesc = (ExprNodeGenericFuncDesc) expr

+				.clone();

+		return new FunctionExpressionEvaluator(funcDesc,

+				inputSchema.toObjectInspector(), output);

+	}

 

-    private void configClassLoader() {

-        config = new Configuration();

-        ClassLoader loader = this.getClass().getClassLoader();

-        config.setClassLoader(loader);

-        Thread.currentThread().setContextClassLoader(loader);

-    }

+	private void configClassLoader() {

+		config = new Configuration();

+		ClassLoader loader = this.getClass().getClassLoader();

+		config.setClassLoader(loader);

+		Thread.currentThread().setContextClassLoader(loader);

+	}

 

-    public String toString() {

-        if (expr == null){

-            configClassLoader();

-            expr = (ExprNodeGenericFuncDesc) Utilities.deserializeExpression(exprSerialization, new Configuration());

-        }

+	public String toString() {

+		if (expr == null) {

+			configClassLoader();

+			expr = (ExprNodeGenericFuncDesc) Utilities.deserializeExpression(

+					exprSerialization, new Configuration());

+		}

 

-        return "function expression evaluator factory: " + expr.getExprString();

-    }

+		return "function expression evaluator factory: " + expr.getExprString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/UnnestingFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/UnnestingFunctionFactory.java
index 4657ae1..1d77737 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/UnnestingFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/evaluator/UnnestingFunctionFactory.java
@@ -14,27 +14,31 @@
 

 public class UnnestingFunctionFactory implements ICopyUnnestingFunctionFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private UDTFDesc expr;

+	private UDTFDesc expr;

 

-    private Schema inputSchema;

+	private Schema inputSchema;

 

-    private int[] columns;

+	private int[] columns;

 

-    public UnnestingFunctionFactory(ILogicalExpression expression, Schema schema, IVariableTypeEnvironment env)

-            throws AlgebricksException {

-        try {

-            expr = (UDTFDesc) ExpressionTranslator.getHiveExpression(expression, env);

-        } catch (Exception e) {

-            throw new AlgebricksException(e.getMessage());

-        }

-        inputSchema = schema;

-    }

+	public UnnestingFunctionFactory(ILogicalExpression expression,

+			Schema schema, IVariableTypeEnvironment env)

+			throws AlgebricksException {

+		try {

+			expr = (UDTFDesc) ExpressionTranslator.getHiveExpression(

+					expression, env);

+		} catch (Exception e) {

+			throw new AlgebricksException(e.getMessage());

+		}

+		inputSchema = schema;

+	}

 

-    @Override

-    public ICopyUnnestingFunction createUnnestingFunction(IDataOutputProvider provider) throws AlgebricksException {

-        return new UDTFFunctionEvaluator(expr, inputSchema, columns, provider.getDataOutput());

-    }

+	@Override

+	public ICopyUnnestingFunction createUnnestingFunction(

+			IDataOutputProvider provider) throws AlgebricksException {

+		return new UDTFFunctionEvaluator(expr, inputSchema, columns,

+				provider.getDataOutput());

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveDoubleBinaryHashFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveDoubleBinaryHashFunctionFactory.java
index b636009..fc302e1 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveDoubleBinaryHashFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveDoubleBinaryHashFunctionFactory.java
@@ -4,26 +4,28 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveDoubleBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveDoubleBinaryHashFunctionFactory implements

+		IBinaryHashFunctionFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveDoubleBinaryHashFunctionFactory INSTANCE = new HiveDoubleBinaryHashFunctionFactory();

+	public static HiveDoubleBinaryHashFunctionFactory INSTANCE = new HiveDoubleBinaryHashFunctionFactory();

 

-    private HiveDoubleBinaryHashFunctionFactory() {

-    }

+	private HiveDoubleBinaryHashFunctionFactory() {

+	}

 

-    @Override

-    public IBinaryHashFunction createBinaryHashFunction() {

-        // TODO Auto-generated method stub

-        return new IBinaryHashFunction() {

-            private Double value;

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction() {

+		// TODO Auto-generated method stub

+		return new IBinaryHashFunction() {

+			private Double value;

 

-            @Override

-            public int hash(byte[] bytes, int offset, int length) {

-                value = Double.longBitsToDouble(LazyUtils.byteArrayToLong(bytes, offset));

-                return value.hashCode();

-            }

-        };

-    }

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				value = Double.longBitsToDouble(LazyUtils.byteArrayToLong(

+						bytes, offset));

+				return value.hashCode();

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveIntegerBinaryHashFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveIntegerBinaryHashFunctionFactory.java
index 90e6ce4..e1a9994 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveIntegerBinaryHashFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveIntegerBinaryHashFunctionFactory.java
@@ -5,29 +5,31 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveIntegerBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveIntegerBinaryHashFunctionFactory implements

+		IBinaryHashFunctionFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static IBinaryHashFunctionFactory INSTANCE = new HiveIntegerBinaryHashFunctionFactory();

+	public static IBinaryHashFunctionFactory INSTANCE = new HiveIntegerBinaryHashFunctionFactory();

 

-    private HiveIntegerBinaryHashFunctionFactory() {

-    }

+	private HiveIntegerBinaryHashFunctionFactory() {

+	}

 

-    @Override

-    public IBinaryHashFunction createBinaryHashFunction() {

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction() {

 

-        return new IBinaryHashFunction() {

-            private VInt value = new VInt();

+		return new IBinaryHashFunction() {

+			private VInt value = new VInt();

 

-            @Override

-            public int hash(byte[] bytes, int offset, int length) {

-                LazyUtils.readVInt(bytes, offset, value);

-                if (value.length != length)

-                    throw new IllegalArgumentException("length mismatch in int hash function actual: " + length

-                            + " expected " + value.length);

-                return value.value;

-            }

-        };

-    }

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				LazyUtils.readVInt(bytes, offset, value);

+				if (value.length != length)

+					throw new IllegalArgumentException(

+							"length mismatch in int hash function actual: "

+									+ length + " expected " + value.length);

+				return value.value;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveLongBinaryHashFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveLongBinaryHashFunctionFactory.java
index 1b61f67..6f7c6f2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveLongBinaryHashFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveLongBinaryHashFunctionFactory.java
@@ -5,26 +5,27 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveLongBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveLongBinaryHashFunctionFactory implements

+		IBinaryHashFunctionFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static IBinaryHashFunctionFactory INSTANCE = new HiveLongBinaryHashFunctionFactory();

+	public static IBinaryHashFunctionFactory INSTANCE = new HiveLongBinaryHashFunctionFactory();

 

-    private HiveLongBinaryHashFunctionFactory() {

-    }

+	private HiveLongBinaryHashFunctionFactory() {

+	}

 

-    @Override

-    public IBinaryHashFunction createBinaryHashFunction() {

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction() {

 

-        return new IBinaryHashFunction() {

-            private VLong value = new VLong();

+		return new IBinaryHashFunction() {

+			private VLong value = new VLong();

 

-            @Override

-            public int hash(byte[] bytes, int offset, int length) {

-                LazyUtils.readVLong(bytes, offset, value);

-                return (int) value.value;

-            }

-        };

-    }

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				LazyUtils.readVLong(bytes, offset, value);

+				return (int) value.value;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveRawBinaryHashFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveRawBinaryHashFunctionFactory.java
index f2b7b44..e03dde0 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveRawBinaryHashFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveRawBinaryHashFunctionFactory.java
@@ -3,29 +3,30 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveRawBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveRawBinaryHashFunctionFactory implements

+		IBinaryHashFunctionFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static IBinaryHashFunctionFactory INSTANCE = new HiveRawBinaryHashFunctionFactory();

+	public static IBinaryHashFunctionFactory INSTANCE = new HiveRawBinaryHashFunctionFactory();

 

-    private HiveRawBinaryHashFunctionFactory() {

+	private HiveRawBinaryHashFunctionFactory() {

 

-    }

+	}

 

-    @Override

-    public IBinaryHashFunction createBinaryHashFunction() {

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction() {

 

-        return new IBinaryHashFunction() {

+		return new IBinaryHashFunction() {

 

-            @Override

-            public int hash(byte[] bytes, int offset, int length) {

-                int value = 1;

-                int end = offset + length;

-                for (int i = offset; i < end; i++)

-                    value = value * 31 + (int) bytes[i];

-                return value;

-            }

-        };

-    }

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				int value = 1;

+				int end = offset + length;

+				for (int i = offset; i < end; i++)

+					value = value * 31 + (int) bytes[i];

+				return value;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveStingBinaryHashFunctionFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveStingBinaryHashFunctionFactory.java
index a9cf6fd..055c077 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveStingBinaryHashFunctionFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/hashfunction/HiveStingBinaryHashFunctionFactory.java
@@ -5,37 +5,41 @@
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveStingBinaryHashFunctionFactory implements IBinaryHashFunctionFactory {

-    private static final long serialVersionUID = 1L;

+public class HiveStingBinaryHashFunctionFactory implements

+		IBinaryHashFunctionFactory {

+	private static final long serialVersionUID = 1L;

 

-    public static HiveStingBinaryHashFunctionFactory INSTANCE = new HiveStingBinaryHashFunctionFactory();

+	public static HiveStingBinaryHashFunctionFactory INSTANCE = new HiveStingBinaryHashFunctionFactory();

 

-    private HiveStingBinaryHashFunctionFactory() {

-    }

+	private HiveStingBinaryHashFunctionFactory() {

+	}

 

-    @Override

-    public IBinaryHashFunction createBinaryHashFunction() {

-        // TODO Auto-generated method stub

-        return new IBinaryHashFunction() {

-            private VInt len = new VInt();

+	@Override

+	public IBinaryHashFunction createBinaryHashFunction() {

+		// TODO Auto-generated method stub

+		return new IBinaryHashFunction() {

+			private VInt len = new VInt();

 

-            @Override

-            public int hash(byte[] bytes, int offset, int length) {

-                LazyUtils.readVInt(bytes, offset, len);

-                if (len.value + len.length != length)

-                    throw new IllegalStateException("parse string: length mismatch, expected "

-                            + (len.value + len.length) + " but get " + length);

-                return hashBytes(bytes, offset + len.length, length - len.length);

-            }

+			@Override

+			public int hash(byte[] bytes, int offset, int length) {

+				LazyUtils.readVInt(bytes, offset, len);

+				if (len.value + len.length != length)

+					throw new IllegalStateException(

+							"parse string: length mismatch, expected "

+									+ (len.value + len.length) + " but get "

+									+ length);

+				return hashBytes(bytes, offset + len.length, length

+						- len.length);

+			}

 

-            public int hashBytes(byte[] bytes, int offset, int length) {

-                int value = 1;

-                int end = offset + length;

-                for (int i = offset; i < end; i++)

-                    value = value * 31 + (int) bytes[i];

-                return value;

-            }

-        };

-    }

+			public int hashBytes(byte[] bytes, int offset, int length) {

+				int value = 1;

+				int end = offset + length;

+				for (int i = offset; i < end; i++)

+					value = value * 31 + (int) bytes[i];

+				return value;

+			}

+		};

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleAscNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleAscNormalizedKeyComputerFactory.java
index 6ac012f..5f03962 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleAscNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleAscNormalizedKeyComputerFactory.java
@@ -4,21 +4,22 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveDoubleAscNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveDoubleAscNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
 
-        return new INormalizedKeyComputer() {
+		return new INormalizedKeyComputer() {
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                int header = LazyUtils.byteArrayToInt(bytes, start);
-                long unsignedValue = (long) header;
-                return (int) ((unsignedValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
-            }
-        };
-    }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				int header = LazyUtils.byteArrayToInt(bytes, start);
+				long unsignedValue = (long) header;
+				return (int) ((unsignedValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleDescNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleDescNormalizedKeyComputerFactory.java
index 3044109..e4587a2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleDescNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveDoubleDescNormalizedKeyComputerFactory.java
@@ -3,22 +3,24 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveDoubleDescNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveDoubleDescNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
-    private final INormalizedKeyComputerFactory ascNormalizedKeyComputerFactory = new HiveDoubleAscNormalizedKeyComputerFactory();
+	private static final long serialVersionUID = 1L;
+	private final INormalizedKeyComputerFactory ascNormalizedKeyComputerFactory = new HiveDoubleAscNormalizedKeyComputerFactory();
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
-        return new INormalizedKeyComputer() {
-            private INormalizedKeyComputer nmkComputer = ascNormalizedKeyComputerFactory.createNormalizedKeyComputer();
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
+		return new INormalizedKeyComputer() {
+			private INormalizedKeyComputer nmkComputer = ascNormalizedKeyComputerFactory
+					.createNormalizedKeyComputer();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                int nk = nmkComputer.normalize(bytes, start, length);
-                return (int) ((long) Integer.MAX_VALUE - (long) (nk - Integer.MIN_VALUE));
-            }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				int nk = nmkComputer.normalize(bytes, start, length);
+				return (int) ((long) Integer.MAX_VALUE - (long) (nk - Integer.MIN_VALUE));
+			}
 
-        };
-    }
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerAscNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerAscNormalizedKeyComputerFactory.java
index a1d4d48..2ff390a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerAscNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerAscNormalizedKeyComputerFactory.java
@@ -5,25 +5,27 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveIntegerAscNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveIntegerAscNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
 
-        return new INormalizedKeyComputer() {
-            private VInt vint = new VInt();
+		return new INormalizedKeyComputer() {
+			private VInt vint = new VInt();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                LazyUtils.readVInt(bytes, start, vint);
-                if (vint.length != length)
-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "
-                            + vint.length + " expected " + length);
-                long unsignedValue = (long) vint.value;
-                return (int) ((unsignedValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
-            }
-        };
-    }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				LazyUtils.readVInt(bytes, start, vint);
+				if (vint.length != length)
+					throw new IllegalArgumentException(
+							"length mismatch in int comparator function actual: "
+									+ vint.length + " expected " + length);
+				long unsignedValue = (long) vint.value;
+				return (int) ((unsignedValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerDescNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerDescNormalizedKeyComputerFactory.java
index 39d4a4b..8eff1f8 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerDescNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveIntegerDescNormalizedKeyComputerFactory.java
@@ -5,25 +5,27 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveIntegerDescNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveIntegerDescNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
 
-        return new INormalizedKeyComputer() {
-            private VInt vint = new VInt();
+		return new INormalizedKeyComputer() {
+			private VInt vint = new VInt();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                LazyUtils.readVInt(bytes, start, vint);
-                if (vint.length != length)
-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "
-                            + vint.length + " expected " + length);
-                long unsignedValue = (long) vint.value;
-                return (int) ((long)0xffffffff - unsignedValue);
-            }
-        };
-    }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				LazyUtils.readVInt(bytes, start, vint);
+				if (vint.length != length)
+					throw new IllegalArgumentException(
+							"length mismatch in int comparator function actual: "
+									+ vint.length + " expected " + length);
+				long unsignedValue = (long) vint.value;
+				return (int) ((long) 0xffffffff - unsignedValue);
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongAscNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongAscNormalizedKeyComputerFactory.java
index 079e069..768eec2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongAscNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongAscNormalizedKeyComputerFactory.java
@@ -5,59 +5,61 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveLongAscNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveLongAscNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
 
-        return new INormalizedKeyComputer() {
-            private static final int POSTIVE_LONG_MASK = (3 << 30);
-            private static final int NON_NEGATIVE_INT_MASK = (2 << 30);
-            private static final int NEGATIVE_LONG_MASK = (0 << 30);
-            private VLong vlong = new VLong();
+		return new INormalizedKeyComputer() {
+			private static final int POSTIVE_LONG_MASK = (3 << 30);
+			private static final int NON_NEGATIVE_INT_MASK = (2 << 30);
+			private static final int NEGATIVE_LONG_MASK = (0 << 30);
+			private VLong vlong = new VLong();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                LazyUtils.readVLong(bytes, start, vlong);
-                if (vlong.length != length)
-                    throw new IllegalArgumentException("length mismatch in int comparator function actual: "
-                            + vlong.length + " expected " + length);
-                long value = (long) vlong.value;
-                int highValue = (int) (value >> 32);
-                if (highValue > 0) {
-                    /**
-                     * larger than Integer.MAX
-                     */
-                    int highNmk = getKey(highValue);
-                    highNmk >>= 2;
-                    highNmk |= POSTIVE_LONG_MASK;
-                    return highNmk;
-                } else if (highValue == 0) {
-                    /**
-                     * smaller than Integer.MAX but >=0
-                     */
-                    int lowNmk = (int) value;
-                    lowNmk >>= 2;
-                    lowNmk |= NON_NEGATIVE_INT_MASK;
-                    return lowNmk;
-                } else {
-                    /**
-                     * less than 0; TODO: have not optimized for that
-                     */
-                    int highNmk = getKey(highValue);
-                    highNmk >>= 2;
-                    highNmk |= NEGATIVE_LONG_MASK;
-                    return highNmk;
-                }
-            }
-            
-            private int getKey(int value) {
-                long unsignedFirstValue = (long) value;
-                int nmk = (int) ((unsignedFirstValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
-                return nmk;
-            }
-        };
-    }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				LazyUtils.readVLong(bytes, start, vlong);
+				if (vlong.length != length)
+					throw new IllegalArgumentException(
+							"length mismatch in int comparator function actual: "
+									+ vlong.length + " expected " + length);
+				long value = (long) vlong.value;
+				int highValue = (int) (value >> 32);
+				if (highValue > 0) {
+					/**
+					 * larger than Integer.MAX
+					 */
+					int highNmk = getKey(highValue);
+					highNmk >>= 2;
+					highNmk |= POSTIVE_LONG_MASK;
+					return highNmk;
+				} else if (highValue == 0) {
+					/**
+					 * smaller than Integer.MAX but >=0
+					 */
+					int lowNmk = (int) value;
+					lowNmk >>= 2;
+					lowNmk |= NON_NEGATIVE_INT_MASK;
+					return lowNmk;
+				} else {
+					/**
+					 * less than 0; TODO: have not optimized for that
+					 */
+					int highNmk = getKey(highValue);
+					highNmk >>= 2;
+					highNmk |= NEGATIVE_LONG_MASK;
+					return highNmk;
+				}
+			}
+
+			private int getKey(int value) {
+				long unsignedFirstValue = (long) value;
+				int nmk = (int) ((unsignedFirstValue - ((long) Integer.MIN_VALUE)) & 0xffffffffL);
+				return nmk;
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongDescNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongDescNormalizedKeyComputerFactory.java
index cc5661b..20ae56a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongDescNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveLongDescNormalizedKeyComputerFactory.java
@@ -3,23 +3,25 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputer;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveLongDescNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveLongDescNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
-    private final INormalizedKeyComputerFactory ascNormalizedKeyComputerFactory = new HiveIntegerAscNormalizedKeyComputerFactory();
+	private static final long serialVersionUID = 1L;
+	private final INormalizedKeyComputerFactory ascNormalizedKeyComputerFactory = new HiveIntegerAscNormalizedKeyComputerFactory();
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
-        return new INormalizedKeyComputer() {
-            private INormalizedKeyComputer nmkComputer = ascNormalizedKeyComputerFactory.createNormalizedKeyComputer();
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
+		return new INormalizedKeyComputer() {
+			private INormalizedKeyComputer nmkComputer = ascNormalizedKeyComputerFactory
+					.createNormalizedKeyComputer();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                int nk = nmkComputer.normalize(bytes, start, length);
-                return (int) ((long) Integer.MAX_VALUE - (long) (nk - Integer.MIN_VALUE));
-            }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				int nk = nmkComputer.normalize(bytes, start, length);
+				return (int) ((long) Integer.MAX_VALUE - (long) (nk - Integer.MIN_VALUE));
+			}
 
-        };
-    }
+		};
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringAscNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringAscNormalizedKeyComputerFactory.java
index d0429d6..b16ccba 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringAscNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringAscNormalizedKeyComputerFactory.java
@@ -6,35 +6,39 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 
-public class HiveStringAscNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveStringAscNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
 
-        return new INormalizedKeyComputer() {
-            private VInt len = new VInt();
+		return new INormalizedKeyComputer() {
+			private VInt len = new VInt();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                LazyUtils.readVInt(bytes, start, len);
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				LazyUtils.readVInt(bytes, start, len);
 
-                if (len.value + len.length != length)
-                    throw new IllegalStateException("parse string: length mismatch, expected "
-                            + (len.value + len.length) + " but get " + length);
-                int nk = 0;
-                int offset = start + len.length;
-                for (int i = 0; i < 2; ++i) {
-                    nk <<= 16;
-                    if (i < len.value) {
-                        char character = UTF8StringPointable.charAt(bytes, offset);
-                        nk += ((int) character) & 0xffff;
-                        offset += UTF8StringPointable.charSize(bytes, offset);
-                    }
-                }
-                return nk;
-            }
-        };
-    }
+				if (len.value + len.length != length)
+					throw new IllegalStateException(
+							"parse string: length mismatch, expected "
+									+ (len.value + len.length) + " but get "
+									+ length);
+				int nk = 0;
+				int offset = start + len.length;
+				for (int i = 0; i < 2; ++i) {
+					nk <<= 16;
+					if (i < len.value) {
+						char character = UTF8StringPointable.charAt(bytes,
+								offset);
+						nk += ((int) character) & 0xffff;
+						offset += UTF8StringPointable.charSize(bytes, offset);
+					}
+				}
+				return nk;
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringDescNormalizedKeyComputerFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringDescNormalizedKeyComputerFactory.java
index 15b2d27..e8978c6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringDescNormalizedKeyComputerFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/normalize/HiveStringDescNormalizedKeyComputerFactory.java
@@ -6,32 +6,35 @@
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 import edu.uci.ics.hyracks.data.std.primitive.UTF8StringPointable;
 
-public class HiveStringDescNormalizedKeyComputerFactory implements INormalizedKeyComputerFactory {
+public class HiveStringDescNormalizedKeyComputerFactory implements
+		INormalizedKeyComputerFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    @Override
-    public INormalizedKeyComputer createNormalizedKeyComputer() {
-        return new INormalizedKeyComputer() {
-            private VInt len = new VInt();
+	@Override
+	public INormalizedKeyComputer createNormalizedKeyComputer() {
+		return new INormalizedKeyComputer() {
+			private VInt len = new VInt();
 
-            @Override
-            public int normalize(byte[] bytes, int start, int length) {
-                LazyUtils.readVInt(bytes, start, len);
-                if (len.value + len.length != length)
-                    throw new IllegalStateException("parse string: length mismatch, expected "
-                            + (len.value + len.length) + " but get " + length);
-                int nk = 0;
-                int offset = start + len.length;
-                for (int i = 0; i < 2; ++i) {
-                    nk <<= 16;
-                    if (i < len.value) {
-                        nk += ((int) UTF8StringPointable.charAt(bytes, offset)) & 0xffff;
-                        offset += UTF8StringPointable.charSize(bytes, offset);
-                    }
-                }
-                return (int) ((long) 0xffffffff - (long) nk);
-            }
-        };
-    }
+			@Override
+			public int normalize(byte[] bytes, int start, int length) {
+				LazyUtils.readVInt(bytes, start, len);
+				if (len.value + len.length != length)
+					throw new IllegalStateException(
+							"parse string: length mismatch, expected "
+									+ (len.value + len.length) + " but get "
+									+ length);
+				int nk = 0;
+				int offset = start + len.length;
+				for (int i = 0; i < 2; ++i) {
+					nk <<= 16;
+					if (i < len.value) {
+						nk += ((int) UTF8StringPointable.charAt(bytes, offset)) & 0xffff;
+						offset += UTF8StringPointable.charSize(bytes, offset);
+					}
+				}
+				return (int) ((long) 0xffffffff - (long) nk);
+			}
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/nullwriter/HiveNullWriterFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/nullwriter/HiveNullWriterFactory.java
index 590bd61..91d08c6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/nullwriter/HiveNullWriterFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/factory/nullwriter/HiveNullWriterFactory.java
@@ -8,21 +8,21 @@
 
 public class HiveNullWriterFactory implements INullWriterFactory {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    public static HiveNullWriterFactory INSTANCE = new HiveNullWriterFactory();
+	public static HiveNullWriterFactory INSTANCE = new HiveNullWriterFactory();
 
-    @Override
-    public INullWriter createNullWriter() {
-        return new HiveNullWriter();
-    }
+	@Override
+	public INullWriter createNullWriter() {
+		return new HiveNullWriter();
+	}
 }
 
 class HiveNullWriter implements INullWriter {
 
-    @Override
-    public void writeNull(DataOutput out) throws HyracksDataException {
-        // do nothing
-    }
+	@Override
+	public void writeNull(DataOutput out) throws HyracksDataException {
+		// do nothing
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspector.java
index 677e20e..3d2b141 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspector.java
@@ -4,16 +4,17 @@
 

 public class HiveBinaryBooleanInspector implements IBinaryBooleanInspector {

 

-    HiveBinaryBooleanInspector() {

-    }

+	HiveBinaryBooleanInspector() {

+	}

 

-    @Override

-    public boolean getBooleanValue(byte[] bytes, int offset, int length) {

-        if (length == 0)

-            return false;

-        if (length != 1)

-            throw new IllegalStateException("boolean field error: with length " + length);

-        return bytes[0] == 1;

-    }

+	@Override

+	public boolean getBooleanValue(byte[] bytes, int offset, int length) {

+		if (length == 0)

+			return false;

+		if (length != 1)

+			throw new IllegalStateException("boolean field error: with length "

+					+ length);

+		return bytes[0] == 1;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspectorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspectorFactory.java
index 22a6065..86afbee 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspectorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryBooleanInspectorFactory.java
@@ -4,17 +4,19 @@
 import edu.uci.ics.hyracks.algebricks.data.IBinaryBooleanInspectorFactory;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 
-public class HiveBinaryBooleanInspectorFactory implements IBinaryBooleanInspectorFactory {
-    private static final long serialVersionUID = 1L;
-    public static HiveBinaryBooleanInspectorFactory INSTANCE = new HiveBinaryBooleanInspectorFactory();
+public class HiveBinaryBooleanInspectorFactory implements
+		IBinaryBooleanInspectorFactory {
+	private static final long serialVersionUID = 1L;
+	public static HiveBinaryBooleanInspectorFactory INSTANCE = new HiveBinaryBooleanInspectorFactory();
 
-    private HiveBinaryBooleanInspectorFactory() {
+	private HiveBinaryBooleanInspectorFactory() {
 
-    }
+	}
 
-    @Override
-    public IBinaryBooleanInspector createBinaryBooleanInspector(IHyracksTaskContext arg0) {
-        return new HiveBinaryBooleanInspector();
-    }
+	@Override
+	public IBinaryBooleanInspector createBinaryBooleanInspector(
+			IHyracksTaskContext arg0) {
+		return new HiveBinaryBooleanInspector();
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspector.java
index 555afee..e82e501 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspector.java
@@ -5,18 +5,19 @@
 import edu.uci.ics.hyracks.algebricks.data.IBinaryIntegerInspector;

 

 public class HiveBinaryIntegerInspector implements IBinaryIntegerInspector {

-    private VInt value = new VInt();

+	private VInt value = new VInt();

 

-    HiveBinaryIntegerInspector() {

-    }

+	HiveBinaryIntegerInspector() {

+	}

 

-    @Override

-    public int getIntegerValue(byte[] bytes, int offset, int length) {

-        LazyUtils.readVInt(bytes, offset, value);

-        if (value.length != length)

-            throw new IllegalArgumentException("length mismatch in int hash function actual: " + length + " expected "

-                    + value.length);

-        return value.value;

-    }

+	@Override

+	public int getIntegerValue(byte[] bytes, int offset, int length) {

+		LazyUtils.readVInt(bytes, offset, value);

+		if (value.length != length)

+			throw new IllegalArgumentException(

+					"length mismatch in int hash function actual: " + length

+							+ " expected " + value.length);

+		return value.value;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspectorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspectorFactory.java
index bb93a60..b44e610 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspectorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/inspector/HiveBinaryIntegerInspectorFactory.java
@@ -4,17 +4,19 @@
 import edu.uci.ics.hyracks.algebricks.data.IBinaryIntegerInspectorFactory;
 import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
 
-public class HiveBinaryIntegerInspectorFactory implements IBinaryIntegerInspectorFactory {
-    private static final long serialVersionUID = 1L;
-    public static HiveBinaryIntegerInspectorFactory INSTANCE = new HiveBinaryIntegerInspectorFactory();
+public class HiveBinaryIntegerInspectorFactory implements
+		IBinaryIntegerInspectorFactory {
+	private static final long serialVersionUID = 1L;
+	public static HiveBinaryIntegerInspectorFactory INSTANCE = new HiveBinaryIntegerInspectorFactory();
 
-    private HiveBinaryIntegerInspectorFactory() {
+	private HiveBinaryIntegerInspectorFactory() {
 
-    }
+	}
 
-    @Override
-    public IBinaryIntegerInspector createBinaryIntegerInspector(IHyracksTaskContext arg0) {
-        return new HiveBinaryIntegerInspector();
-    }
+	@Override
+	public IBinaryIntegerInspector createBinaryIntegerInspector(
+			IHyracksTaskContext arg0) {
+		return new HiveBinaryIntegerInspector();
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveConnectorPolicyAssignmentPolicy.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveConnectorPolicyAssignmentPolicy.java
index bdced12..8f559e2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveConnectorPolicyAssignmentPolicy.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveConnectorPolicyAssignmentPolicy.java
@@ -10,56 +10,58 @@
 import edu.uci.ics.hyracks.dataflow.std.connectors.MToNPartitioningConnectorDescriptor;
 import edu.uci.ics.hyracks.dataflow.std.connectors.MToNPartitioningMergingConnectorDescriptor;
 
-public class HiveConnectorPolicyAssignmentPolicy implements IConnectorPolicyAssignmentPolicy {
-    public enum Policy {
-        PIPELINING, SEND_SIDE_MAT_PIPELINING, SEND_SIDE_MAT_BLOCKING, SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING;
-    };
+public class HiveConnectorPolicyAssignmentPolicy implements
+		IConnectorPolicyAssignmentPolicy {
+	public enum Policy {
+		PIPELINING, SEND_SIDE_MAT_PIPELINING, SEND_SIDE_MAT_BLOCKING, SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING;
+	};
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    private final IConnectorPolicy pipeliningPolicy = new PipeliningConnectorPolicy();
-    private final IConnectorPolicy sendSideMatPipeliningPolicy = new SendSideMaterializedPipeliningConnectorPolicy();
-    private final IConnectorPolicy sendSideMatBlockingPolicy = new SendSideMaterializedBlockingConnectorPolicy();
-    private final IConnectorPolicy sendSideMatReceiveSideMatBlockingPolicy = new SendSideMaterializedReceiveSideMaterializedBlockingConnectorPolicy();
-    private final Policy policy;
+	private final IConnectorPolicy pipeliningPolicy = new PipeliningConnectorPolicy();
+	private final IConnectorPolicy sendSideMatPipeliningPolicy = new SendSideMaterializedPipeliningConnectorPolicy();
+	private final IConnectorPolicy sendSideMatBlockingPolicy = new SendSideMaterializedBlockingConnectorPolicy();
+	private final IConnectorPolicy sendSideMatReceiveSideMatBlockingPolicy = new SendSideMaterializedReceiveSideMaterializedBlockingConnectorPolicy();
+	private final Policy policy;
 
-    public HiveConnectorPolicyAssignmentPolicy(Policy policy) {
-        this.policy = policy;
-    }
+	public HiveConnectorPolicyAssignmentPolicy(Policy policy) {
+		this.policy = policy;
+	}
 
-    @Override
-    public IConnectorPolicy getConnectorPolicyAssignment(IConnectorDescriptor c, int nProducers, int nConsumers,
-            int[] fanouts) {
-        if (c instanceof MToNPartitioningMergingConnectorDescriptor) {
-            // avoid deadlocks
-            switch (policy) {
-                case PIPELINING:
-                case SEND_SIDE_MAT_PIPELINING:
-                    return sendSideMatPipeliningPolicy;
-                case SEND_SIDE_MAT_BLOCKING:
-                    return sendSideMatBlockingPolicy;
-                case SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING:
-                    return sendSideMatReceiveSideMatBlockingPolicy;
-                default:
-                    return sendSideMatPipeliningPolicy;
-            }
-        } else if (c instanceof MToNPartitioningConnectorDescriptor) {
-            // support different repartitioning policies
-            switch (policy) {
-                case PIPELINING:
-                    return pipeliningPolicy;
-                case SEND_SIDE_MAT_PIPELINING:
-                    return sendSideMatPipeliningPolicy;
-                case SEND_SIDE_MAT_BLOCKING:
-                    return sendSideMatBlockingPolicy;
-                case SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING:
-                    return sendSideMatReceiveSideMatBlockingPolicy;
-                default:
-                    return pipeliningPolicy;
-            }
-        } else {
-            // pipelining for other connectors
-            return pipeliningPolicy;
-        }
-    }
+	@Override
+	public IConnectorPolicy getConnectorPolicyAssignment(
+			IConnectorDescriptor c, int nProducers, int nConsumers,
+			int[] fanouts) {
+		if (c instanceof MToNPartitioningMergingConnectorDescriptor) {
+			// avoid deadlocks
+			switch (policy) {
+			case PIPELINING:
+			case SEND_SIDE_MAT_PIPELINING:
+				return sendSideMatPipeliningPolicy;
+			case SEND_SIDE_MAT_BLOCKING:
+				return sendSideMatBlockingPolicy;
+			case SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING:
+				return sendSideMatReceiveSideMatBlockingPolicy;
+			default:
+				return sendSideMatPipeliningPolicy;
+			}
+		} else if (c instanceof MToNPartitioningConnectorDescriptor) {
+			// support different repartitioning policies
+			switch (policy) {
+			case PIPELINING:
+				return pipeliningPolicy;
+			case SEND_SIDE_MAT_PIPELINING:
+				return sendSideMatPipeliningPolicy;
+			case SEND_SIDE_MAT_BLOCKING:
+				return sendSideMatBlockingPolicy;
+			case SEND_SIDE_MAT_RECEIVE_SIDE_MAT_BLOCKING:
+				return sendSideMatReceiveSideMatBlockingPolicy;
+			default:
+				return pipeliningPolicy;
+			}
+		} else {
+			// pipelining for other connectors
+			return pipeliningPolicy;
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSink.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSink.java
index ccc2e6c..e4fbca5 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSink.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSink.java
@@ -6,27 +6,27 @@
 

 public class HiveDataSink implements IDataSink {

 

-    private Object[] schema;

+	private Object[] schema;

 

-    private Object fsOperator;

+	private Object fsOperator;

 

-    public HiveDataSink(Object sink, Object[] sourceSchema) {

-        schema = sourceSchema;

-        fsOperator = sink;

-    }

+	public HiveDataSink(Object sink, Object[] sourceSchema) {

+		schema = sourceSchema;

+		fsOperator = sink;

+	}

 

-    @Override

-    public Object getId() {

-        return fsOperator;

-    }

+	@Override

+	public Object getId() {

+		return fsOperator;

+	}

 

-    @Override

-    public Object[] getSchemaTypes() {

-        return schema;

-    }

+	@Override

+	public Object[] getSchemaTypes() {

+		return schema;

+	}

 

-    public IPartitioningProperty getPartitioningProperty() {

-        return new RandomPartitioningProperty(new HiveDomain());

-    }

+	public IPartitioningProperty getPartitioningProperty() {

+		return new RandomPartitioningProperty(new HiveDomain());

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSource.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSource.java
index 67b743b..edff056 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSource.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSource.java
@@ -11,37 +11,38 @@
 

 public class HiveDataSource<P> implements IDataSource<P> {

 

-    private P source;

+	private P source;

 

-    private Object[] schema;

+	private Object[] schema;

 

-    public HiveDataSource(P dataSource, Object[] sourceSchema) {

-        source = dataSource;

-        schema = sourceSchema;

-    }

+	public HiveDataSource(P dataSource, Object[] sourceSchema) {

+		source = dataSource;

+		schema = sourceSchema;

+	}

 

-    @Override

-    public P getId() {

-        return source;

-    }

+	@Override

+	public P getId() {

+		return source;

+	}

 

-    @Override

-    public Object[] getSchemaTypes() {

-        return schema;

-    }

+	@Override

+	public Object[] getSchemaTypes() {

+		return schema;

+	}

 

-    @Override

-    public void computeFDs(List<LogicalVariable> scanVariables, List<FunctionalDependency> fdList) {

-    }

+	@Override

+	public void computeFDs(List<LogicalVariable> scanVariables,

+			List<FunctionalDependency> fdList) {

+	}

 

-    @Override

-    public IDataSourcePropertiesProvider getPropertiesProvider() {

-        return new HiveDataSourcePartitioningProvider();

-    }

+	@Override

+	public IDataSourcePropertiesProvider getPropertiesProvider() {

+		return new HiveDataSourcePartitioningProvider();

+	}

 

-    @Override

-    public String toString() {

-        PartitionDesc desc = (PartitionDesc) source;

-        return desc.getTableName();

-    }

+	@Override

+	public String toString() {

+		PartitionDesc desc = (PartitionDesc) source;

+		return desc.getTableName();

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSourcePartitioningProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSourcePartitioningProvider.java
index bb9c4ce..08dd684 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSourcePartitioningProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDataSourcePartitioningProvider.java
@@ -11,13 +11,16 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty;

 import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector;

 

-public class HiveDataSourcePartitioningProvider implements IDataSourcePropertiesProvider {

+public class HiveDataSourcePartitioningProvider implements

+		IDataSourcePropertiesProvider {

 

-    @Override

-    public IPhysicalPropertiesVector computePropertiesVector(List<LogicalVariable> scanVariables) {

-        IPartitioningProperty property = new RandomPartitioningProperty(new HiveDomain());

-        IPhysicalPropertiesVector vector = new StructuralPropertiesVector(property,

-                new LinkedList<ILocalStructuralProperty>());

-        return vector;

-    }

+	@Override

+	public IPhysicalPropertiesVector computePropertiesVector(

+			List<LogicalVariable> scanVariables) {

+		IPartitioningProperty property = new RandomPartitioningProperty(

+				new HiveDomain());

+		IPhysicalPropertiesVector vector = new StructuralPropertiesVector(

+				property, new LinkedList<ILocalStructuralProperty>());

+		return vector;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDomain.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDomain.java
index 8b1d3b5..0af253a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDomain.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveDomain.java
@@ -4,14 +4,14 @@
 

 public class HiveDomain implements INodeDomain {

 

-    @Override

-    public boolean sameAs(INodeDomain domain) {

-        return true;

-    }

+	@Override

+	public boolean sameAs(INodeDomain domain) {

+		return true;

+	}

 

-    @Override

-    public Integer cardinality() {

-        return 0;

-    }

+	@Override

+	public Integer cardinality() {

+		return 0;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveMetaDataProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveMetaDataProvider.java
index a6cdbe0..5782703 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveMetaDataProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveMetaDataProvider.java
@@ -32,98 +32,118 @@
 @SuppressWarnings("rawtypes")

 public class HiveMetaDataProvider<S, T> implements IMetadataProvider<S, T> {

 

-    private Operator fileSink;

-    private Schema outputSchema;

-    private HashMap<S, IDataSource<S>> dataSourceMap;

+	private Operator fileSink;

+	private Schema outputSchema;

+	private HashMap<S, IDataSource<S>> dataSourceMap;

 

-    public HiveMetaDataProvider(Operator fsOp, Schema oi, HashMap<S, IDataSource<S>> map) {

-        fileSink = fsOp;

-        outputSchema = oi;

-        dataSourceMap = map;

-    }

+	public HiveMetaDataProvider(Operator fsOp, Schema oi,

+			HashMap<S, IDataSource<S>> map) {

+		fileSink = fsOp;

+		outputSchema = oi;

+		dataSourceMap = map;

+	}

 

-    @Override

-    public IDataSourceIndex<T, S> findDataSourceIndex(T indexId, S dataSourceId) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public IDataSourceIndex<T, S> findDataSourceIndex(T indexId, S dataSourceId)

+			throws AlgebricksException {

+		return null;

+	}

 

-    @Override

-    public IDataSource<S> findDataSource(S id) throws AlgebricksException {

-        return dataSourceMap.get(id);

-    }

+	@Override

+	public IDataSource<S> findDataSource(S id) throws AlgebricksException {

+		return dataSourceMap.get(id);

+	}

 

-    @Override

-    public boolean scannerOperatorIsLeaf(IDataSource<S> dataSource) {

-        return true;

-    }

+	@Override

+	public boolean scannerOperatorIsLeaf(IDataSource<S> dataSource) {

+		return true;

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getScannerRuntime(IDataSource<S> dataSource,

-            List<LogicalVariable> scanVariables, List<LogicalVariable> projectVariables, boolean projectPushed,

-            IOperatorSchema opSchema, IVariableTypeEnvironment typeEnv, JobGenContext context, JobSpecification jobSpec)

-            throws AlgebricksException {

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getScannerRuntime(

+			IDataSource<S> dataSource, List<LogicalVariable> scanVariables,

+			List<LogicalVariable> projectVariables, boolean projectPushed,

+			IOperatorSchema opSchema, IVariableTypeEnvironment typeEnv,

+			JobGenContext context, JobSpecification jobSpec)

+			throws AlgebricksException {

 

-        S desc = dataSource.getId();

-        HiveScanRuntimeGenerator generator = new HiveScanRuntimeGenerator((PartitionDesc) desc);

-        return generator.getRuntimeOperatorAndConstraint(dataSource, scanVariables, projectVariables, projectPushed,

-                context, jobSpec);

-    }

+		S desc = dataSource.getId();

+		HiveScanRuntimeGenerator generator = new HiveScanRuntimeGenerator(

+				(PartitionDesc) desc);

+		return generator.getRuntimeOperatorAndConstraint(dataSource,

+				scanVariables, projectVariables, projectPushed, context,

+				jobSpec);

+	}

 

-    @Override

-    public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriteFileRuntime(IDataSink sink,

-            int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc) {

+	@Override

+	public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriteFileRuntime(

+			IDataSink sink, int[] printColumns,

+			IPrinterFactory[] printerFactories, RecordDescriptor inputDesc) {

 

-        HiveWriteRuntimeGenerator generator = new HiveWriteRuntimeGenerator((FileSinkOperator) fileSink, outputSchema);

-        return generator.getWriterRuntime(inputDesc);

-    }

+		HiveWriteRuntimeGenerator generator = new HiveWriteRuntimeGenerator(

+				(FileSinkOperator) fileSink, outputSchema);

+		return generator.getWriterRuntime(inputDesc);

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getDeleteRuntime(IDataSource<S> arg0,

-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, RecordDescriptor arg4,

-            JobGenContext arg5, JobSpecification arg6) throws AlgebricksException {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getDeleteRuntime(

+			IDataSource<S> arg0, IOperatorSchema arg1,

+			List<LogicalVariable> arg2, LogicalVariable arg3,

+			RecordDescriptor arg4, JobGenContext arg5, JobSpecification arg6)

+			throws AlgebricksException {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getInsertRuntime(IDataSource<S> arg0,

-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, RecordDescriptor arg4,

-            JobGenContext arg5, JobSpecification arg6) throws AlgebricksException {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getInsertRuntime(

+			IDataSource<S> arg0, IOperatorSchema arg1,

+			List<LogicalVariable> arg2, LogicalVariable arg3,

+			RecordDescriptor arg4, JobGenContext arg5, JobSpecification arg6)

+			throws AlgebricksException {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getWriteResultRuntime(IDataSource<S> arg0,

-            IOperatorSchema arg1, List<LogicalVariable> arg2, LogicalVariable arg3, JobGenContext arg4,

-            JobSpecification arg5) throws AlgebricksException {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getWriteResultRuntime(

+			IDataSource<S> arg0, IOperatorSchema arg1,

+			List<LogicalVariable> arg2, LogicalVariable arg3,

+			JobGenContext arg4, JobSpecification arg5)

+			throws AlgebricksException {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

-    @Override

-    public IFunctionInfo lookupFunction(FunctionIdentifier arg0) {

-        return new HiveFunctionInfo(arg0, null);

-    }

+	@Override

+	public IFunctionInfo lookupFunction(FunctionIdentifier arg0) {

+		return new HiveFunctionInfo(arg0, null);

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexInsertRuntime(

-            IDataSourceIndex<T, S> dataSource, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas,

-            IVariableTypeEnvironment typeEnv, List<LogicalVariable> primaryKeys, List<LogicalVariable> secondaryKeys,

-            ILogicalExpression filterExpr, RecordDescriptor recordDesc, JobGenContext context, JobSpecification spec)

-            throws AlgebricksException {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexInsertRuntime(

+			IDataSourceIndex<T, S> dataSource,

+			IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas,

+			IVariableTypeEnvironment typeEnv,

+			List<LogicalVariable> primaryKeys,

+			List<LogicalVariable> secondaryKeys, ILogicalExpression filterExpr,

+			RecordDescriptor recordDesc, JobGenContext context,

+			JobSpecification spec) throws AlgebricksException {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

-    @Override

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexDeleteRuntime(

-            IDataSourceIndex<T, S> dataSource, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas,

-            IVariableTypeEnvironment typeEnv, List<LogicalVariable> primaryKeys, List<LogicalVariable> secondaryKeys,

-            ILogicalExpression filterExpr, RecordDescriptor recordDesc, JobGenContext context, JobSpecification spec)

-            throws AlgebricksException {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getIndexDeleteRuntime(

+			IDataSourceIndex<T, S> dataSource,

+			IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas,

+			IVariableTypeEnvironment typeEnv,

+			List<LogicalVariable> primaryKeys,

+			List<LogicalVariable> secondaryKeys, ILogicalExpression filterExpr,

+			RecordDescriptor recordDesc, JobGenContext context,

+			JobSpecification spec) throws AlgebricksException {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveOperatorSchema.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveOperatorSchema.java
index cdb0e95..83382f0 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveOperatorSchema.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveOperatorSchema.java
@@ -11,74 +11,74 @@
 

 public class HiveOperatorSchema implements IOperatorSchema {

 

-    private final Map<LogicalVariable, Integer> varMap;

+	private final Map<LogicalVariable, Integer> varMap;

 

-    private final List<LogicalVariable> varList;

+	private final List<LogicalVariable> varList;

 

-    public HiveOperatorSchema() {

-        varMap = new HashMap<LogicalVariable, Integer>();

-        varList = new ArrayList<LogicalVariable>();

-    }

+	public HiveOperatorSchema() {

+		varMap = new HashMap<LogicalVariable, Integer>();

+		varList = new ArrayList<LogicalVariable>();

+	}

 

-    @Override

-    public void addAllVariables(IOperatorSchema source) {

-        for (LogicalVariable v : source) {

-            varMap.put(v, varList.size());

-            varList.add(v);

-        }

-    }

+	@Override

+	public void addAllVariables(IOperatorSchema source) {

+		for (LogicalVariable v : source) {

+			varMap.put(v, varList.size());

+			varList.add(v);

+		}

+	}

 

-    @Override

-    public void addAllNewVariables(IOperatorSchema source) {

-        for (LogicalVariable v : source) {

-            if (varMap.get(v) == null) {

-                varMap.put(v, varList.size());

-                varList.add(v);

-            }

-        }

-    }

+	@Override

+	public void addAllNewVariables(IOperatorSchema source) {

+		for (LogicalVariable v : source) {

+			if (varMap.get(v) == null) {

+				varMap.put(v, varList.size());

+				varList.add(v);

+			}

+		}

+	}

 

-    @Override

-    public int addVariable(LogicalVariable var) {

-        int idx = varList.size();

-        varMap.put(var, idx);

-        varList.add(var);

-        return idx;

-    }

+	@Override

+	public int addVariable(LogicalVariable var) {

+		int idx = varList.size();

+		varMap.put(var, idx);

+		varList.add(var);

+		return idx;

+	}

 

-    @Override

-    public void clear() {

-        varMap.clear();

-        varList.clear();

-    }

+	@Override

+	public void clear() {

+		varMap.clear();

+		varList.clear();

+	}

 

-    @Override

-    public int findVariable(LogicalVariable var) {

-        Integer i = varMap.get(var);

-        if (i == null) {

-            return -1;

-        }

-        return i;

-    }

+	@Override

+	public int findVariable(LogicalVariable var) {

+		Integer i = varMap.get(var);

+		if (i == null) {

+			return -1;

+		}

+		return i;

+	}

 

-    @Override

-    public int getSize() {

-        return varList.size();

-    }

+	@Override

+	public int getSize() {

+		return varList.size();

+	}

 

-    @Override

-    public LogicalVariable getVariable(int index) {

-        return varList.get(index);

-    }

+	@Override

+	public LogicalVariable getVariable(int index) {

+		return varList.get(index);

+	}

 

-    @Override

-    public Iterator<LogicalVariable> iterator() {

-        return varList.iterator();

-    }

+	@Override

+	public Iterator<LogicalVariable> iterator() {

+		return varList.iterator();

+	}

 

-    @Override

-    public String toString() {

-        return varMap.toString();

-    }

+	@Override

+	public String toString() {

+		return varMap.toString();

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveScanRuntimeGenerator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveScanRuntimeGenerator.java
index 69fb66a..27f01e2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveScanRuntimeGenerator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveScanRuntimeGenerator.java
@@ -28,79 +28,90 @@
 

 public class HiveScanRuntimeGenerator {

 

-    private PartitionDesc fileDesc;

+	private PartitionDesc fileDesc;

 

-    private transient Path filePath;

+	private transient Path filePath;

 

-    private String filePathName;

+	private String filePathName;

 

-    private Properties properties;

+	private Properties properties;

 

-    public HiveScanRuntimeGenerator(PartitionDesc path) {

-        fileDesc = path;

-        properties = fileDesc.getProperties();

+	public HiveScanRuntimeGenerator(PartitionDesc path) {

+		fileDesc = path;

+		properties = fileDesc.getProperties();

 

-        String inputPath = (String) properties.getProperty("location");

+		String inputPath = (String) properties.getProperty("location");

 

-        if (inputPath.startsWith("file:")) {

-            // Windows

-            String[] strs = inputPath.split(":");

-            filePathName = strs[strs.length - 1];

-        } else {

-            // Linux

-            filePathName = inputPath;

-        }

+		if (inputPath.startsWith("file:")) {

+			// Windows

+			String[] strs = inputPath.split(":");

+			filePathName = strs[strs.length - 1];

+		} else {

+			// Linux

+			filePathName = inputPath;

+		}

 

-        filePath = new Path(filePathName);

-    }

+		filePath = new Path(filePathName);

+	}

 

-    public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getRuntimeOperatorAndConstraint(

-            IDataSource dataSource, List<LogicalVariable> scanVariables, List<LogicalVariable> projectVariables,

-            boolean projectPushed, JobGenContext context, JobSpecification jobSpec) throws AlgebricksException {

-        // get the correct delimiter from Hive metastore or other data

-        // structures

-        IOperatorSchema propagatedSchema = new HiveOperatorSchema();

+	public Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> getRuntimeOperatorAndConstraint(

+			IDataSource dataSource, List<LogicalVariable> scanVariables,

+			List<LogicalVariable> projectVariables, boolean projectPushed,

+			JobGenContext context, JobSpecification jobSpec)

+			throws AlgebricksException {

+		// get the correct delimiter from Hive metastore or other data

+		// structures

+		IOperatorSchema propagatedSchema = new HiveOperatorSchema();

 

-        List<LogicalVariable> outputVariables = projectPushed ? projectVariables : scanVariables;

-        for (LogicalVariable var : outputVariables)

-            propagatedSchema.addVariable(var);

+		List<LogicalVariable> outputVariables = projectPushed ? projectVariables

+				: scanVariables;

+		for (LogicalVariable var : outputVariables)

+			propagatedSchema.addVariable(var);

 

-        int[] outputColumnsOffset = new int[scanVariables.size()];

-        int i = 0;

-        for (LogicalVariable var : scanVariables)

-            if (outputVariables.contains(var)) {

-                int offset = outputVariables.indexOf(var);

-                outputColumnsOffset[i++] = offset;

-            } else

-                outputColumnsOffset[i++] = -1;

+		int[] outputColumnsOffset = new int[scanVariables.size()];

+		int i = 0;

+		for (LogicalVariable var : scanVariables)

+			if (outputVariables.contains(var)) {

+				int offset = outputVariables.indexOf(var);

+				outputColumnsOffset[i++] = offset;

+			} else

+				outputColumnsOffset[i++] = -1;

 

-        Object[] schemaTypes = dataSource.getSchemaTypes();

-        // get record descriptor

-        RecordDescriptor recDescriptor = mkRecordDescriptor(propagatedSchema, schemaTypes, context);

+		Object[] schemaTypes = dataSource.getSchemaTypes();

+		// get record descriptor

+		RecordDescriptor recDescriptor = mkRecordDescriptor(propagatedSchema,

+				schemaTypes, context);

 

-        // setup the run time operator

-        JobConf conf = ConfUtil.getJobConf(fileDesc.getInputFileFormatClass(), filePath);

-        int clusterSize = ConfUtil.getNCs().length;

-        IFileSplitProvider fsprovider = new HiveFileSplitProvider(conf, filePathName, clusterSize);

-        ITupleParserFactory tupleParserFactory = new HiveTupleParserFactory(fileDesc, conf, outputColumnsOffset);

-        HiveFileScanOperatorDescriptor opDesc = new HiveFileScanOperatorDescriptor(jobSpec, fsprovider,

-                tupleParserFactory, recDescriptor);

+		// setup the run time operator

+		JobConf conf = ConfUtil.getJobConf(fileDesc.getInputFileFormatClass(),

+				filePath);

+		int clusterSize = ConfUtil.getNCs().length;

+		IFileSplitProvider fsprovider = new HiveFileSplitProvider(conf,

+				filePathName, clusterSize);

+		ITupleParserFactory tupleParserFactory = new HiveTupleParserFactory(

+				fileDesc, conf, outputColumnsOffset);

+		HiveFileScanOperatorDescriptor opDesc = new HiveFileScanOperatorDescriptor(

+				jobSpec, fsprovider, tupleParserFactory, recDescriptor);

 

-        return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(opDesc, opDesc.getPartitionConstraint());

-    }

+		return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(

+				opDesc, opDesc.getPartitionConstraint());

+	}

 

-    @SuppressWarnings("unchecked")

-    private static RecordDescriptor mkRecordDescriptor(IOperatorSchema opSchema, Object[] types, JobGenContext context)

-            throws AlgebricksException {

-        ISerializerDeserializer[] fields = new ISerializerDeserializer[opSchema.getSize()];

-        ISerializerDeserializerProvider sdp = context.getSerializerDeserializerProvider();

-        int i = 0;

-        for (LogicalVariable var : opSchema) {

-            Object t = types[i];

-            fields[i] = sdp.getSerializerDeserializer(t);

-            i++;

-        }

-        return new RecordDescriptor(fields);

-    }

+	@SuppressWarnings("unchecked")

+	private static RecordDescriptor mkRecordDescriptor(

+			IOperatorSchema opSchema, Object[] types, JobGenContext context)

+			throws AlgebricksException {

+		ISerializerDeserializer[] fields = new ISerializerDeserializer[opSchema

+				.getSize()];

+		ISerializerDeserializerProvider sdp = context

+				.getSerializerDeserializerProvider();

+		int i = 0;

+		for (LogicalVariable var : opSchema) {

+			Object t = types[i];

+			fields[i] = sdp.getSerializerDeserializer(t);

+			i++;

+		}

+		return new RecordDescriptor(fields);

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveWriteRuntimeGenerator.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveWriteRuntimeGenerator.java
index bd5bc7f..40428c8 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveWriteRuntimeGenerator.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/jobgen/HiveWriteRuntimeGenerator.java
@@ -12,26 +12,28 @@
 import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;

 

 public class HiveWriteRuntimeGenerator {

-    private FileSinkOperator fileSink;

+	private FileSinkOperator fileSink;

 

-    private Schema inputSchema;

+	private Schema inputSchema;

 

-    public HiveWriteRuntimeGenerator(FileSinkOperator fsOp, Schema oi) {

-        fileSink = fsOp;

-        inputSchema = oi;

-    }

+	public HiveWriteRuntimeGenerator(FileSinkOperator fsOp, Schema oi) {

+		fileSink = fsOp;

+		inputSchema = oi;

+	}

 

-    /**

-     * get the write runtime

-     * 

-     * @param inputDesc

-     * @return

-     */

-    public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriterRuntime(RecordDescriptor inputDesc) {

-        JobConf conf = ConfUtil.getJobConf();

-        IPushRuntimeFactory factory = new HivePushRuntimeFactory(inputDesc, conf, fileSink, inputSchema);

-        Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> pair = new Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint>(

-                factory, null);

-        return pair;

-    }

+	/**

+	 * get the write runtime

+	 * 

+	 * @param inputDesc

+	 * @return

+	 */

+	public Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> getWriterRuntime(

+			RecordDescriptor inputDesc) {

+		JobConf conf = ConfUtil.getJobConf();

+		IPushRuntimeFactory factory = new HivePushRuntimeFactory(inputDesc,

+				conf, fileSink, inputSchema);

+		Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint> pair = new Pair<IPushRuntimeFactory, AlgebricksPartitionConstraint>(

+				factory, null);

+		return pair;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveFileSplitProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveFileSplitProvider.java
index 642280d..598238e 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveFileSplitProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveFileSplitProvider.java
@@ -3,14 +3,15 @@
 import edu.uci.ics.hyracks.dataflow.std.file.FileSplit;

 import edu.uci.ics.hyracks.dataflow.std.file.IFileSplitProvider;

 

-public abstract class AbstractHiveFileSplitProvider implements IFileSplitProvider {

+public abstract class AbstractHiveFileSplitProvider implements

+		IFileSplitProvider {

 

-    @Override

-    public FileSplit[] getFileSplits() {

-        // TODO Auto-generated method stub

-        return null;

-    }

+	@Override

+	public FileSplit[] getFileSplits() {

+		// TODO Auto-generated method stub

+		return null;

+	}

 

-    public abstract org.apache.hadoop.mapred.FileSplit[] getFileSplitArray();

+	public abstract org.apache.hadoop.mapred.FileSplit[] getFileSplitArray();

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveTupleParser.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveTupleParser.java
index a76a383..bec9034 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveTupleParser.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/AbstractHiveTupleParser.java
@@ -10,17 +10,19 @@
 

 public abstract class AbstractHiveTupleParser implements ITupleParser {

 

-    @Override

-    public void parse(InputStream in, IFrameWriter writer) throws HyracksDataException {

-        // empty implementation

-    }

+	@Override

+	public void parse(InputStream in, IFrameWriter writer)

+			throws HyracksDataException {

+		// empty implementation

+	}

 

-    /**

-     * method for parsing HDFS file split

-     * 

-     * @param split

-     * @param writer

-     */

-    abstract public void parse(FileSplit split, IFrameWriter writer) throws HyracksDataException;

+	/**

+	 * method for parsing HDFS file split

+	 * 

+	 * @param split

+	 * @param writer

+	 */

+	abstract public void parse(FileSplit split, IFrameWriter writer)

+			throws HyracksDataException;

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
index 00a9d0a..9c8b293 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileScanOperatorDescriptor.java
@@ -39,126 +39,134 @@
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParser;
 import edu.uci.ics.hyracks.dataflow.std.file.ITupleParserFactory;
 
-public class HiveFileScanOperatorDescriptor extends AbstractSingleActivityOperatorDescriptor {
-    private static final long serialVersionUID = 1L;
+public class HiveFileScanOperatorDescriptor extends
+		AbstractSingleActivityOperatorDescriptor {
+	private static final long serialVersionUID = 1L;
 
-    /**
-     * tuple parser factory
-     */
-    private final ITupleParserFactory tupleParserFactory;
+	/**
+	 * tuple parser factory
+	 */
+	private final ITupleParserFactory tupleParserFactory;
 
-    /**
-     * Hive file split
-     */
-    private Partition[] parts;
+	/**
+	 * Hive file split
+	 */
+	private Partition[] parts;
 
-    /**
-     * IFileSplitProvider
-     */
-    private IFileSplitProvider fileSplitProvider;
+	/**
+	 * IFileSplitProvider
+	 */
+	private IFileSplitProvider fileSplitProvider;
 
-    /**
-     * constrains in the form of host DNS names
-     */
-    private String[] constraintsByHostNames;
+	/**
+	 * constrains in the form of host DNS names
+	 */
+	private String[] constraintsByHostNames;
 
-    /**
-     * ip-to-node controller mapping
-     */
-    private Map<String, List<String>> ncMapping;
+	/**
+	 * ip-to-node controller mapping
+	 */
+	private Map<String, List<String>> ncMapping;
 
-    /**
-     * an array of NCs
-     */
-    private String[] NCs;
+	/**
+	 * an array of NCs
+	 */
+	private String[] NCs;
 
-    /**
-     * 
-     * @param spec
-     * @param fsProvider
-     */
-    public HiveFileScanOperatorDescriptor(JobSpecification spec, IFileSplitProvider fsProvider,
-            ITupleParserFactory tupleParserFactory, RecordDescriptor rDesc) {
-        super(spec, 0, 1);
-        this.tupleParserFactory = tupleParserFactory;
-        recordDescriptors[0] = rDesc;
-        fileSplitProvider = fsProvider;
-    }
+	/**
+	 * 
+	 * @param spec
+	 * @param fsProvider
+	 */
+	public HiveFileScanOperatorDescriptor(JobSpecification spec,
+			IFileSplitProvider fsProvider,
+			ITupleParserFactory tupleParserFactory, RecordDescriptor rDesc) {
+		super(spec, 0, 1);
+		this.tupleParserFactory = tupleParserFactory;
+		recordDescriptors[0] = rDesc;
+		fileSplitProvider = fsProvider;
+	}
 
-    /**
-     * set partition constraint at the first time it is called the number of
-     * partitions is obtained from HDFS name node
-     */
-    public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() throws AlgebricksException {
-        FileSplit[] returnedSplits = ((AbstractHiveFileSplitProvider) fileSplitProvider).getFileSplitArray();
-        Random random = new Random(System.currentTimeMillis());
-        ncMapping = ConfUtil.getNCMapping();
-        NCs = ConfUtil.getNCs();
+	/**
+	 * set partition constraint at the first time it is called the number of
+	 * partitions is obtained from HDFS name node
+	 */
+	public AlgebricksAbsolutePartitionConstraint getPartitionConstraint()
+			throws AlgebricksException {
+		FileSplit[] returnedSplits = ((AbstractHiveFileSplitProvider) fileSplitProvider)
+				.getFileSplitArray();
+		Random random = new Random(System.currentTimeMillis());
+		ncMapping = ConfUtil.getNCMapping();
+		NCs = ConfUtil.getNCs();
 
-        int size = 0;
-        for (FileSplit split : returnedSplits)
-            if (split != null)
-                size++;
+		int size = 0;
+		for (FileSplit split : returnedSplits)
+			if (split != null)
+				size++;
 
-        FileSplit[] splits = new FileSplit[size];
-        for (int i = 0; i < returnedSplits.length; i++)
-            if (returnedSplits[i] != null)
-                splits[i] = returnedSplits[i];
+		FileSplit[] splits = new FileSplit[size];
+		for (int i = 0; i < returnedSplits.length; i++)
+			if (returnedSplits[i] != null)
+				splits[i] = returnedSplits[i];
 
-        System.out.println("!!! number of splits: " + splits.length);
-        constraintsByHostNames = new String[splits.length];
-        for (int i = 0; i < splits.length; i++) {
-            try {
-                String[] loc = splits[i].getLocations();
-                Collections.shuffle(Arrays.asList(loc), random);
-                if (loc.length > 0) {
-                    InetAddress[] allIps = InetAddress.getAllByName(loc[0]);
-                    for (InetAddress ip : allIps) {
-                        if (ncMapping.get(ip.getHostAddress()) != null) {
-                            List<String> ncs = ncMapping.get(ip.getHostAddress());
-                            int pos = random.nextInt(ncs.size());
-                            constraintsByHostNames[i] = ncs.get(pos);
-                        } else {
-                            int pos = random.nextInt(NCs.length);
-                            constraintsByHostNames[i] = NCs[pos];
-                        }
-                    }
-                } else {
-                    int pos = random.nextInt(NCs.length);
-                    constraintsByHostNames[i] = NCs[pos];
-                    if (splits[i].getLength() > 0)
-                        throw new IllegalStateException("non local scanner non locations!!");
-                }
-            } catch (IOException e) {
-                throw new AlgebricksException(e);
-            }
-        }
+		System.out.println("!!! number of splits: " + splits.length);
+		constraintsByHostNames = new String[splits.length];
+		for (int i = 0; i < splits.length; i++) {
+			try {
+				String[] loc = splits[i].getLocations();
+				Collections.shuffle(Arrays.asList(loc), random);
+				if (loc.length > 0) {
+					InetAddress[] allIps = InetAddress.getAllByName(loc[0]);
+					for (InetAddress ip : allIps) {
+						if (ncMapping.get(ip.getHostAddress()) != null) {
+							List<String> ncs = ncMapping.get(ip
+									.getHostAddress());
+							int pos = random.nextInt(ncs.size());
+							constraintsByHostNames[i] = ncs.get(pos);
+						} else {
+							int pos = random.nextInt(NCs.length);
+							constraintsByHostNames[i] = NCs[pos];
+						}
+					}
+				} else {
+					int pos = random.nextInt(NCs.length);
+					constraintsByHostNames[i] = NCs[pos];
+					if (splits[i].getLength() > 0)
+						throw new IllegalStateException(
+								"non local scanner non locations!!");
+				}
+			} catch (IOException e) {
+				throw new AlgebricksException(e);
+			}
+		}
 
-        parts = new Partition[splits.length];
-        for (int i = 0; i < splits.length; i++) {
-            parts[i] = new Partition(splits[i]);
-        }
-        return new AlgebricksAbsolutePartitionConstraint(constraintsByHostNames);
-    }
+		parts = new Partition[splits.length];
+		for (int i = 0; i < splits.length; i++) {
+			parts[i] = new Partition(splits[i]);
+		}
+		return new AlgebricksAbsolutePartitionConstraint(constraintsByHostNames);
+	}
 
-    @Override
-    public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
-            IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) {
+	@Override
+	public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
+			IRecordDescriptorProvider recordDescProvider, int partition,
+			int nPartitions) {
 
-        final ITupleParser tp = tupleParserFactory.createTupleParser(ctx);
-        final int partitionId = partition;
+		final ITupleParser tp = tupleParserFactory.createTupleParser(ctx);
+		final int partitionId = partition;
 
-        return new AbstractUnaryOutputSourceOperatorNodePushable() {
+		return new AbstractUnaryOutputSourceOperatorNodePushable() {
 
-            @Override
-            public void initialize() throws HyracksDataException {
-                writer.open();
-                FileSplit split = parts[partitionId].toFileSplit();
-                if (split == null)
-                    throw new HyracksDataException("partition " + partitionId + " is null!");
-                ((AbstractHiveTupleParser) tp).parse(split, writer);
-                writer.close();
-            }
-        };
-    }
+			@Override
+			public void initialize() throws HyracksDataException {
+				writer.open();
+				FileSplit split = parts[partitionId].toFileSplit();
+				if (split == null)
+					throw new HyracksDataException("partition " + partitionId
+							+ " is null!");
+				((AbstractHiveTupleParser) tp).parse(split, writer);
+				writer.close();
+			}
+		};
+	}
 }
\ No newline at end of file
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileSplitProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileSplitProvider.java
index 9e85ac4..177fc7a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileSplitProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveFileSplitProvider.java
@@ -17,92 +17,99 @@
 

 public class HiveFileSplitProvider extends AbstractHiveFileSplitProvider {

 

-    private transient InputFormat format;

-    private transient JobConf conf;

-    private String confContent;

-    final private int nPartition;

-    private transient FileSplit[] splits;

-    private String inputFormatStr;

+	private transient InputFormat format;

+	private transient JobConf conf;

+	private String confContent;

+	final private int nPartition;

+	private transient FileSplit[] splits;

+	private String inputFormatStr;

 

-    public HiveFileSplitProvider(JobConf conf, String filePath, int nPartition) {

-        format = conf.getInputFormat();

-        inputFormatStr = format.getClass().getName();

-        this.conf = conf;

-        this.nPartition = nPartition;

-        writeConfContent();

-    }

+	public HiveFileSplitProvider(JobConf conf, String filePath, int nPartition) {

+		format = conf.getInputFormat();

+		inputFormatStr = format.getClass().getName();

+		this.conf = conf;

+		this.nPartition = nPartition;

+		writeConfContent();

+	}

 

-    private void writeConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void writeConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            DataOutputStream out = new DataOutputStream(new FileOutputStream(new File(fileName)));

-            conf.writeXml(out);

-            out.close();

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			DataOutputStream out = new DataOutputStream(new FileOutputStream(

+					new File(fileName)));

+			conf.writeXml(out);

+			out.close();

 

-            DataInputStream in = new DataInputStream(new FileInputStream(fileName));

-            StringBuffer buffer = new StringBuffer();

-            String line;

-            while ((line = in.readLine()) != null) {

-                buffer.append(line + "\n");

-            }

-            in.close();

-            confContent = buffer.toString();

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+			DataInputStream in = new DataInputStream(new FileInputStream(

+					fileName));

+			StringBuffer buffer = new StringBuffer();

+			String line;

+			while ((line = in.readLine()) != null) {

+				buffer.append(line + "\n");

+			}

+			in.close();

+			confContent = buffer.toString();

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

-    private void readConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void readConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            PrintWriter out = new PrintWriter((new OutputStreamWriter(new FileOutputStream(new File(fileName)))));

-            out.write(confContent);

-            out.close();

-            conf = new JobConf(fileName);

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			PrintWriter out = new PrintWriter((new OutputStreamWriter(

+					new FileOutputStream(new File(fileName)))));

+			out.write(confContent);

+			out.close();

+			conf = new JobConf(fileName);

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

-    @Override

-    /**

-     * get the HDFS file split

-     */

-    public FileSplit[] getFileSplitArray() {

-        readConfContent();

-        conf.setClassLoader(this.getClass().getClassLoader());

-        format = conf.getInputFormat();

-        //int splitSize = conf.getInt("mapred.min.split.size", 0);

+	@Override

+	/**

+	 * get the HDFS file split

+	 */

+	public FileSplit[] getFileSplitArray() {

+		readConfContent();

+		conf.setClassLoader(this.getClass().getClassLoader());

+		format = conf.getInputFormat();

+		// int splitSize = conf.getInt("mapred.min.split.size", 0);

 

-        if (splits == null) {

-            try {

-                splits = (org.apache.hadoop.mapred.FileSplit[]) format.getSplits(conf, nPartition);

-                System.out.println("hdfs split number: " + splits.length);

-            } catch (IOException e) {

-                String inputPath = conf.get("mapred.input.dir");

-                String hdfsURL = conf.get("fs.default.name");

-                String alternatePath = inputPath.replaceAll(hdfsURL, "file:");

-                conf.set("mapred.input.dir", alternatePath);

-                try {

-                    splits = (org.apache.hadoop.mapred.FileSplit[]) format.getSplits(conf, nPartition);

-                    System.out.println("hdfs split number: " + splits.length);

-                } catch (IOException e1) {

-                    e1.printStackTrace();

-                    Log.debug(e1.getMessage());

-                    return null;

-                }

-            }

-        }

-        return splits;

-    }

+		if (splits == null) {

+			try {

+				splits = (org.apache.hadoop.mapred.FileSplit[]) format

+						.getSplits(conf, nPartition);

+				System.out.println("hdfs split number: " + splits.length);

+			} catch (IOException e) {

+				String inputPath = conf.get("mapred.input.dir");

+				String hdfsURL = conf.get("fs.default.name");

+				String alternatePath = inputPath.replaceAll(hdfsURL, "file:");

+				conf.set("mapred.input.dir", alternatePath);

+				try {

+					splits = (org.apache.hadoop.mapred.FileSplit[]) format

+							.getSplits(conf, nPartition);

+					System.out.println("hdfs split number: " + splits.length);

+				} catch (IOException e1) {

+					e1.printStackTrace();

+					Log.debug(e1.getMessage());

+					return null;

+				}

+			}

+		}

+		return splits;

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParser.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParser.java
index ffcaa1d..6c40b95 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParser.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParser.java
@@ -35,185 +35,203 @@
 

 public class HiveTupleParser extends AbstractHiveTupleParser {

 

-    private int[] outputColumnsOffset;

-    /**

-     * class of input format

-     */

-    private InputFormat inputFormat;

+	private int[] outputColumnsOffset;

+	/**

+	 * class of input format

+	 */

+	private InputFormat inputFormat;

 

-    /**

-     * serialization/deserialization object

-     */

-    private SerDe serDe;

+	/**

+	 * serialization/deserialization object

+	 */

+	private SerDe serDe;

 

-    /**

-     * the input row object inspector

-     */

-    private ObjectInspector objectInspector;

+	/**

+	 * the input row object inspector

+	 */

+	private ObjectInspector objectInspector;

 

-    /**

-     * the hadoop job conf

-     */

-    private JobConf job;

+	/**

+	 * the hadoop job conf

+	 */

+	private JobConf job;

 

-    /**

-     * Hyrax context to control resource allocation

-     */

-    private final IHyracksTaskContext ctx;

+	/**

+	 * Hyrax context to control resource allocation

+	 */

+	private final IHyracksTaskContext ctx;

 

-    /**

-     * lazy serde: format flow in between operators

-     */

-    private final SerDe outputSerDe;

+	/**

+	 * lazy serde: format flow in between operators

+	 */

+	private final SerDe outputSerDe;

 

-    /**

-     * the parser from hive data to binary data

-     */

-    private IHiveParser parser = null;

+	/**

+	 * the parser from hive data to binary data

+	 */

+	private IHiveParser parser = null;

 

-    /**

-     * parser for any hive input format

-     * 

-     * @param inputFormatClass

-     * @param serDeClass

-     * @param tbl

-     * @param conf

-     * @throws AlgebricksException

-     */

-    public HiveTupleParser(String inputFormatClass, String serDeClass, String outputSerDeClass, Properties tbl,

-            JobConf conf, final IHyracksTaskContext ctx, int[] outputColumnsOffset) throws AlgebricksException {

-        try {

-            conf.setClassLoader(this.getClass().getClassLoader());

+	/**

+	 * parser for any hive input format

+	 * 

+	 * @param inputFormatClass

+	 * @param serDeClass

+	 * @param tbl

+	 * @param conf

+	 * @throws AlgebricksException

+	 */

+	public HiveTupleParser(String inputFormatClass, String serDeClass,

+			String outputSerDeClass, Properties tbl, JobConf conf,

+			final IHyracksTaskContext ctx, int[] outputColumnsOffset)

+			throws AlgebricksException {

+		try {

+			conf.setClassLoader(this.getClass().getClassLoader());

 

-            inputFormat = (InputFormat) ReflectionUtils.newInstance(Class.forName(inputFormatClass), conf);

-            job = conf;

+			inputFormat = (InputFormat) ReflectionUtils.newInstance(

+					Class.forName(inputFormatClass), conf);

+			job = conf;

 

-            // initialize the input serde

-            serDe = (SerDe) ReflectionUtils.newInstance(Class.forName(serDeClass), job);

-            serDe.initialize(job, tbl);

+			// initialize the input serde

+			serDe = (SerDe) ReflectionUtils.newInstance(

+					Class.forName(serDeClass), job);

+			serDe.initialize(job, tbl);

 

-            // initialize the output serde

-            outputSerDe = (SerDe) ReflectionUtils.newInstance(Class.forName(outputSerDeClass), job);

-            outputSerDe.initialize(job, tbl);

+			// initialize the output serde

+			outputSerDe = (SerDe) ReflectionUtils.newInstance(

+					Class.forName(outputSerDeClass), job);

+			outputSerDe.initialize(job, tbl);

 

-            // object inspector of the row

-            objectInspector = serDe.getObjectInspector();

+			// object inspector of the row

+			objectInspector = serDe.getObjectInspector();

 

-            // hyracks context

-            this.ctx = ctx;

-            this.outputColumnsOffset = outputColumnsOffset;

+			// hyracks context

+			this.ctx = ctx;

+			this.outputColumnsOffset = outputColumnsOffset;

 

-            if (objectInspector instanceof LazySimpleStructObjectInspector) {

-                LazySimpleStructObjectInspector rowInspector = (LazySimpleStructObjectInspector) objectInspector;

-                List<? extends StructField> fieldRefs = rowInspector.getAllStructFieldRefs();

-                boolean lightWeightParsable = true;

-                for (StructField fieldRef : fieldRefs) {

-                    Category category = fieldRef.getFieldObjectInspector().getCategory();

-                    if (!(category == Category.PRIMITIVE)) {

-                        lightWeightParsable = false;

-                        break;

-                    }

-                }

-                if (lightWeightParsable)

-                    parser = new TextToBinaryTupleParser(this.outputColumnsOffset, this.objectInspector);

-            }

-        } catch (Exception e) {

-            throw new AlgebricksException(e);

-        }

-    }

+			if (objectInspector instanceof LazySimpleStructObjectInspector) {

+				LazySimpleStructObjectInspector rowInspector = (LazySimpleStructObjectInspector) objectInspector;

+				List<? extends StructField> fieldRefs = rowInspector

+						.getAllStructFieldRefs();

+				boolean lightWeightParsable = true;

+				for (StructField fieldRef : fieldRefs) {

+					Category category = fieldRef.getFieldObjectInspector()

+							.getCategory();

+					if (!(category == Category.PRIMITIVE)) {

+						lightWeightParsable = false;

+						break;

+					}

+				}

+				if (lightWeightParsable)

+					parser = new TextToBinaryTupleParser(

+							this.outputColumnsOffset, this.objectInspector);

+			}

+		} catch (Exception e) {

+			throw new AlgebricksException(e);

+		}

+	}

 

-    /**

-     * parse a input HDFS file split, the result is send to the writer

-     * one-frame-a-time

-     * 

-     * @param split

-     *            the HDFS file split

-     * @param writer

-     *            the writer

-     * @throws HyracksDataException

-     *             if there is sth. wrong in the ser/de

-     */

-    @Override

-    public void parse(FileSplit split, IFrameWriter writer) throws HyracksDataException {

-        try {

-            StructObjectInspector structInspector = (StructObjectInspector) objectInspector;

+	/**

+	 * parse a input HDFS file split, the result is send to the writer

+	 * one-frame-a-time

+	 * 

+	 * @param split

+	 *            the HDFS file split

+	 * @param writer

+	 *            the writer

+	 * @throws HyracksDataException

+	 *             if there is sth. wrong in the ser/de

+	 */

+	@Override

+	public void parse(FileSplit split, IFrameWriter writer)

+			throws HyracksDataException {

+		try {

+			StructObjectInspector structInspector = (StructObjectInspector) objectInspector;

 

-            // create the reader, key, and value

-            RecordReader reader = inputFormat.getRecordReader(split, job, Reporter.NULL);

-            Object key = reader.createKey();

-            Object value = reader.createValue();

+			// create the reader, key, and value

+			RecordReader reader = inputFormat.getRecordReader(split, job,

+					Reporter.NULL);

+			Object key = reader.createKey();

+			Object value = reader.createValue();

 

-            // allocate a new frame

-            ByteBuffer frame = ctx.allocateFrame();

-            FrameTupleAppender appender = new FrameTupleAppender(ctx.getFrameSize());

-            appender.reset(frame, true);

+			// allocate a new frame

+			ByteBuffer frame = ctx.allocateFrame();

+			FrameTupleAppender appender = new FrameTupleAppender(

+					ctx.getFrameSize());

+			appender.reset(frame, true);

 

-            List<? extends StructField> fieldRefs = structInspector.getAllStructFieldRefs();

-            int size = 0;

-            for (int i = 0; i < outputColumnsOffset.length; i++)

-                if (outputColumnsOffset[i] >= 0)

-                    size++;

+			List<? extends StructField> fieldRefs = structInspector

+					.getAllStructFieldRefs();

+			int size = 0;

+			for (int i = 0; i < outputColumnsOffset.length; i++)

+				if (outputColumnsOffset[i] >= 0)

+					size++;

 

-            ArrayTupleBuilder tb = new ArrayTupleBuilder(size);

-            DataOutput dos = tb.getDataOutput();

-            StructField[] outputFieldRefs = new StructField[size];

-            Object[] outputFields = new Object[size];

-            for (int i = 0; i < outputColumnsOffset.length; i++)

-                if (outputColumnsOffset[i] >= 0)

-                    outputFieldRefs[outputColumnsOffset[i]] = fieldRefs.get(i);

+			ArrayTupleBuilder tb = new ArrayTupleBuilder(size);

+			DataOutput dos = tb.getDataOutput();

+			StructField[] outputFieldRefs = new StructField[size];

+			Object[] outputFields = new Object[size];

+			for (int i = 0; i < outputColumnsOffset.length; i++)

+				if (outputColumnsOffset[i] >= 0)

+					outputFieldRefs[outputColumnsOffset[i]] = fieldRefs.get(i);

 

-            long serDeTime = 0;

-            while (reader.next(key, value)) {

-                long start = System.currentTimeMillis();

-                // reuse the tuple builder

-                tb.reset();

-                if (parser != null) {

-                    Text text = (Text) value;

-                    parser.parse(text.getBytes(), 0, text.getLength(), tb);

-                } else {

-                    Object row = serDe.deserialize((Writable) value);

-                    // write fields to the tuple builder one by one

-                    int i = 0;

-                    for (StructField fieldRef : fieldRefs) {

-                        if (outputColumnsOffset[i] >= 0)

-                            outputFields[outputColumnsOffset[i]] = structInspector.getStructFieldData(row, fieldRef);

-                        i++;

-                    }

+			long serDeTime = 0;

+			while (reader.next(key, value)) {

+				long start = System.currentTimeMillis();

+				// reuse the tuple builder

+				tb.reset();

+				if (parser != null) {

+					Text text = (Text) value;

+					parser.parse(text.getBytes(), 0, text.getLength(), tb);

+				} else {

+					Object row = serDe.deserialize((Writable) value);

+					// write fields to the tuple builder one by one

+					int i = 0;

+					for (StructField fieldRef : fieldRefs) {

+						if (outputColumnsOffset[i] >= 0)

+							outputFields[outputColumnsOffset[i]] = structInspector

+									.getStructFieldData(row, fieldRef);

+						i++;

+					}

 

-                    i = 0;

-                    for (Object field : outputFields) {

-                        BytesWritable fieldWritable = (BytesWritable) outputSerDe.serialize(field,

-                                outputFieldRefs[i].getFieldObjectInspector());

-                        dos.write(fieldWritable.getBytes(), 0, fieldWritable.getSize());

-                        tb.addFieldEndOffset();

-                        i++;

-                    }

-                }

-                long end = System.currentTimeMillis();

-                serDeTime += (end - start);

+					i = 0;

+					for (Object field : outputFields) {

+						BytesWritable fieldWritable = (BytesWritable) outputSerDe

+								.serialize(field, outputFieldRefs[i]

+										.getFieldObjectInspector());

+						dos.write(fieldWritable.getBytes(), 0,

+								fieldWritable.getSize());

+						tb.addFieldEndOffset();

+						i++;

+					}

+				}

+				long end = System.currentTimeMillis();

+				serDeTime += (end - start);

 

-                if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {

-                    if (appender.getTupleCount() <= 0)

-                        throw new IllegalStateException("zero tuples in a frame!");

-                    FrameUtils.flushFrame(frame, writer);

-                    appender.reset(frame, true);

-                    if (!appender.append(tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize())) {

-                        throw new IllegalStateException();

-                    }

-                }

-            }

-            System.out.println("serde time: " + serDeTime);

-            reader.close();

-            System.gc();

+				if (!appender.append(tb.getFieldEndOffsets(),

+						tb.getByteArray(), 0, tb.getSize())) {

+					if (appender.getTupleCount() <= 0)

+						throw new IllegalStateException(

+								"zero tuples in a frame!");

+					FrameUtils.flushFrame(frame, writer);

+					appender.reset(frame, true);

+					if (!appender.append(tb.getFieldEndOffsets(),

+							tb.getByteArray(), 0, tb.getSize())) {

+						throw new IllegalStateException();

+					}

+				}

+			}

+			System.out.println("serde time: " + serDeTime);

+			reader.close();

+			System.gc();

 

-            // flush the last frame

-            if (appender.getTupleCount() > 0) {

-                FrameUtils.flushFrame(frame, writer);

-            }

-        } catch (IOException e) {

-            throw new HyracksDataException(e);

-        } catch (SerDeException e) {

-            throw new HyracksDataException(e);

-        }

-    }

+			// flush the last frame

+			if (appender.getTupleCount() > 0) {

+				FrameUtils.flushFrame(frame, writer);

+			}

+		} catch (IOException e) {

+			throw new HyracksDataException(e);

+		} catch (SerDeException e) {

+			throw new HyracksDataException(e);

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParserFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParserFactory.java
index ccd18ee..6a8802c 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParserFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/HiveTupleParserFactory.java
@@ -20,84 +20,91 @@
 

 public class HiveTupleParserFactory implements ITupleParserFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private int[] outputColumns;

+	private int[] outputColumns;

 

-    private String outputSerDeClass = LazySerDe.class.getName();

+	private String outputSerDeClass = LazySerDe.class.getName();

 

-    private String inputSerDeClass;

+	private String inputSerDeClass;

 

-    private transient JobConf conf;

+	private transient JobConf conf;

 

-    private Properties tbl;

+	private Properties tbl;

 

-    private String confContent;

+	private String confContent;

 

-    private String inputFormatClass;

+	private String inputFormatClass;

 

-    public HiveTupleParserFactory(PartitionDesc desc, JobConf conf, int[] outputColumns) {

-        this.conf = conf;

-        tbl = desc.getProperties();

-        inputFormatClass = (String) tbl.getProperty("file.inputformat");

-        inputSerDeClass = (String) tbl.getProperty("serialization.lib");

-        this.outputColumns = outputColumns;

+	public HiveTupleParserFactory(PartitionDesc desc, JobConf conf,

+			int[] outputColumns) {

+		this.conf = conf;

+		tbl = desc.getProperties();

+		inputFormatClass = (String) tbl.getProperty("file.inputformat");

+		inputSerDeClass = (String) tbl.getProperty("serialization.lib");

+		this.outputColumns = outputColumns;

 

-        writeConfContent();

-    }

+		writeConfContent();

+	}

 

-    @Override

-    public ITupleParser createTupleParser(IHyracksTaskContext ctx) {

-        readConfContent();

-        try {

-            return new HiveTupleParser(inputFormatClass, inputSerDeClass, outputSerDeClass, tbl, conf, ctx, outputColumns);

-        } catch (Exception e) {

-            e.printStackTrace();

-            return null;

-        }

-    }

+	@Override

+	public ITupleParser createTupleParser(IHyracksTaskContext ctx) {

+		readConfContent();

+		try {

+			return new HiveTupleParser(inputFormatClass, inputSerDeClass,

+					outputSerDeClass, tbl, conf, ctx, outputColumns);

+		} catch (Exception e) {

+			e.printStackTrace();

+			return null;

+		}

+	}

 

-    private void writeConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void writeConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            DataOutputStream out = new DataOutputStream(new FileOutputStream(new File(fileName)));

-            conf.writeXml(out);

-            out.close();

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			DataOutputStream out = new DataOutputStream(new FileOutputStream(

+					new File(fileName)));

+			conf.writeXml(out);

+			out.close();

 

-            DataInputStream in = new DataInputStream(new FileInputStream(fileName));

-            StringBuffer buffer = new StringBuffer();

-            String line;

-            while ((line = in.readLine()) != null) {

-                buffer.append(line + "\n");

-            }

-            in.close();

-            confContent = buffer.toString();

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+			DataInputStream in = new DataInputStream(new FileInputStream(

+					fileName));

+			StringBuffer buffer = new StringBuffer();

+			String line;

+			while ((line = in.readLine()) != null) {

+				buffer.append(line + "\n");

+			}

+			in.close();

+			confContent = buffer.toString();

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

-    private void readConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void readConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            PrintWriter out = new PrintWriter((new OutputStreamWriter(new FileOutputStream(new File(fileName)))));

-            out.write(confContent);

-            out.close();

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			PrintWriter out = new PrintWriter((new OutputStreamWriter(

+					new FileOutputStream(new File(fileName)))));

+			out.write(confContent);

+			out.close();

 

-            conf = new JobConf(fileName);

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+			conf = new JobConf(fileName);

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/Partition.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/Partition.java
index db9dd78..c23c3f9 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/Partition.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filescan/Partition.java
@@ -8,26 +8,26 @@
 

 public class Partition implements Serializable {

 

-    private String uri;

-    private long offset;

-    private long length;

-    private String[] locations;

+	private String uri;

+	private long offset;

+	private long length;

+	private String[] locations;

 

-    public Partition() {

-    }

+	public Partition() {

+	}

 

-    public Partition(FileSplit file) {

-        uri = file.getPath().toUri().toString();

-        offset = file.getStart();

-        length = file.getLength();

-        try {

-            locations = file.getLocations();

-        } catch (IOException e) {

-            throw new IllegalStateException(e);

-        }

-    }

+	public Partition(FileSplit file) {

+		uri = file.getPath().toUri().toString();

+		offset = file.getStart();

+		length = file.getLength();

+		try {

+			locations = file.getLocations();

+		} catch (IOException e) {

+			throw new IllegalStateException(e);

+		}

+	}

 

-    public FileSplit toFileSplit() {

-        return new FileSplit(new Path(uri), offset, length, locations);

-    }

+	public FileSplit toFileSplit() {

+		return new FileSplit(new Path(uri), offset, length, locations);

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HiveFileWritePushRuntime.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HiveFileWritePushRuntime.java
index 1abade8..dcb3920 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HiveFileWritePushRuntime.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HiveFileWritePushRuntime.java
@@ -23,124 +23,130 @@
 

 public class HiveFileWritePushRuntime implements IPushRuntime {

 

-    /**

-     * frame tuple accessor to access byte buffer

-     */

-    private final FrameTupleAccessor accessor;

+	/**

+	 * frame tuple accessor to access byte buffer

+	 */

+	private final FrameTupleAccessor accessor;

 

-    /**

-     * input object inspector

-     */

-    private final ObjectInspector inputInspector;

+	/**

+	 * input object inspector

+	 */

+	private final ObjectInspector inputInspector;

 

-    /**

-     * cachedInput

-     */

-    private final LazyColumnar cachedInput;

+	/**

+	 * cachedInput

+	 */

+	private final LazyColumnar cachedInput;

 

-    /**

-     * File sink operator of Hive

-     */

-    private final FileSinkDesc fileSink;

+	/**

+	 * File sink operator of Hive

+	 */

+	private final FileSinkDesc fileSink;

 

-    /**

-     * job configuration, which contain name node and other configuration

-     * information

-     */

-    private JobConf conf;

+	/**

+	 * job configuration, which contain name node and other configuration

+	 * information

+	 */

+	private JobConf conf;

 

-    /**

-     * input object inspector

-     */

-    private final Schema inputSchema;

+	/**

+	 * input object inspector

+	 */

+	private final Schema inputSchema;

 

-    /**

-     * a copy of hive schema representation

-     */

-    private RowSchema rowSchema;

+	/**

+	 * a copy of hive schema representation

+	 */

+	private RowSchema rowSchema;

 

-    /**

-     * the Hive file sink operator

-     */

-    private FileSinkOperator fsOp;

+	/**

+	 * the Hive file sink operator

+	 */

+	private FileSinkOperator fsOp;

 

-    /**

-     * cached tuple object reference

-     */

-    private FrameTupleReference tuple = new FrameTupleReference();

+	/**

+	 * cached tuple object reference

+	 */

+	private FrameTupleReference tuple = new FrameTupleReference();

 

-    /**

-     * @param spec

-     * @param fsProvider

-     */

-    public HiveFileWritePushRuntime(IHyracksTaskContext context, RecordDescriptor inputRecordDesc, JobConf job,

-            FileSinkDesc fs, RowSchema schema, Schema oi) {

-        fileSink = fs;

-        fileSink.setGatherStats(false);

+	/**

+	 * @param spec

+	 * @param fsProvider

+	 */

+	public HiveFileWritePushRuntime(IHyracksTaskContext context,

+			RecordDescriptor inputRecordDesc, JobConf job, FileSinkDesc fs,

+			RowSchema schema, Schema oi) {

+		fileSink = fs;

+		fileSink.setGatherStats(false);

 

-        rowSchema = schema;

-        conf = job;

-        inputSchema = oi;

+		rowSchema = schema;

+		conf = job;

+		inputSchema = oi;

 

-        accessor = new FrameTupleAccessor(context.getFrameSize(), inputRecordDesc);

-        inputInspector = inputSchema.toObjectInspector();

-        cachedInput = new LazyColumnar((LazyColumnarObjectInspector) inputInspector);

-    }

+		accessor = new FrameTupleAccessor(context.getFrameSize(),

+				inputRecordDesc);

+		inputInspector = inputSchema.toObjectInspector();

+		cachedInput = new LazyColumnar(

+				(LazyColumnarObjectInspector) inputInspector);

+	}

 

-    @Override

-    public void open() throws HyracksDataException {

-        fsOp = (FileSinkOperator) OperatorFactory.get(fileSink, rowSchema);

-        fsOp.setChildOperators(null);

-        fsOp.setParentOperators(null);

-        conf.setClassLoader(this.getClass().getClassLoader());

+	@Override

+	public void open() throws HyracksDataException {

+		fsOp = (FileSinkOperator) OperatorFactory.get(fileSink, rowSchema);

+		fsOp.setChildOperators(null);

+		fsOp.setParentOperators(null);

+		conf.setClassLoader(this.getClass().getClassLoader());

 

-        ObjectInspector[] inspectors = new ObjectInspector[1];

-        inspectors[0] = inputInspector;

-        try {

-            fsOp.initialize(conf, inspectors);

-            fsOp.setExecContext(null);

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+		ObjectInspector[] inspectors = new ObjectInspector[1];

+		inspectors[0] = inputInspector;

+		try {

+			fsOp.initialize(conf, inspectors);

+			fsOp.setExecContext(null);

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

-    @Override

-    public void nextFrame(ByteBuffer buffer) throws HyracksDataException {

-        accessor.reset(buffer);

-        int n = accessor.getTupleCount();

-        try {

-            for (int i = 0; i < n; ++i) {

-                tuple.reset(accessor, i);

-                cachedInput.init(tuple);

-                fsOp.process(cachedInput, 0);

-            }

-        } catch (HiveException e) {

-            throw new HyracksDataException(e);

-        }

-    }

+	@Override

+	public void nextFrame(ByteBuffer buffer) throws HyracksDataException {

+		accessor.reset(buffer);

+		int n = accessor.getTupleCount();

+		try {

+			for (int i = 0; i < n; ++i) {

+				tuple.reset(accessor, i);

+				cachedInput.init(tuple);

+				fsOp.process(cachedInput, 0);

+			}

+		} catch (HiveException e) {

+			throw new HyracksDataException(e);

+		}

+	}

 

-    @Override

-    public void close() throws HyracksDataException {

-        try {

-            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

-            fsOp.closeOp(false);

-        } catch (HiveException e) {

-            throw new HyracksDataException(e);

-        }

-    }

+	@Override

+	public void close() throws HyracksDataException {

+		try {

+			Thread.currentThread().setContextClassLoader(

+					this.getClass().getClassLoader());

+			fsOp.closeOp(false);

+		} catch (HiveException e) {

+			throw new HyracksDataException(e);

+		}

+	}

 

-    @Override

-    public void setFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc) {

-        throw new IllegalStateException();

-    }

+	@Override

+	public void setFrameWriter(int index, IFrameWriter writer,

+			RecordDescriptor recordDesc) {

+		throw new IllegalStateException();

+	}

 

-    @Override

-    public void setInputRecordDescriptor(int index, RecordDescriptor recordDescriptor) {

-    }

+	@Override

+	public void setInputRecordDescriptor(int index,

+			RecordDescriptor recordDescriptor) {

+	}

 

-    @Override

-    public void fail() throws HyracksDataException {

+	@Override

+	public void fail() throws HyracksDataException {

 

-    }

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HivePushRuntimeFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HivePushRuntimeFactory.java
index cdc5a36..47c8472 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HivePushRuntimeFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/operator/filewrite/HivePushRuntimeFactory.java
@@ -23,82 +23,90 @@
 

 public class HivePushRuntimeFactory implements IPushRuntimeFactory {

 

-    private static final long serialVersionUID = 1L;

+	private static final long serialVersionUID = 1L;

 

-    private final RecordDescriptor inputRecordDesc;

-    private transient JobConf conf;

-    private final FileSinkDesc fileSink;

-    private final RowSchema outSchema;

-    private final Schema schema;

+	private final RecordDescriptor inputRecordDesc;

+	private transient JobConf conf;

+	private final FileSinkDesc fileSink;

+	private final RowSchema outSchema;

+	private final Schema schema;

 

-    /**

-     * the content of the configuration

-     */

-    private String confContent;

+	/**

+	 * the content of the configuration

+	 */

+	private String confContent;

 

-    public HivePushRuntimeFactory(RecordDescriptor inputRecordDesc, JobConf conf, FileSinkOperator fsp, Schema sch) {

-        this.inputRecordDesc = inputRecordDesc;

-        this.conf = conf;

-        this.fileSink = fsp.getConf();

-        outSchema = fsp.getSchema();

-        this.schema = sch;

+	public HivePushRuntimeFactory(RecordDescriptor inputRecordDesc,

+			JobConf conf, FileSinkOperator fsp, Schema sch) {

+		this.inputRecordDesc = inputRecordDesc;

+		this.conf = conf;

+		this.fileSink = fsp.getConf();

+		outSchema = fsp.getSchema();

+		this.schema = sch;

 

-        writeConfContent();

-    }

+		writeConfContent();

+	}

 

-    @Override

-    public String toString() {

-        return "file write";

-    }

+	@Override

+	public String toString() {

+		return "file write";

+	}

 

-    @Override

-    public IPushRuntime createPushRuntime(IHyracksTaskContext context) throws AlgebricksException {

-        if (conf == null)

-            readConfContent();

+	@Override

+	public IPushRuntime createPushRuntime(IHyracksTaskContext context)

+			throws AlgebricksException {

+		if (conf == null)

+			readConfContent();

 

-        return new HiveFileWritePushRuntime(context, inputRecordDesc, conf, fileSink, outSchema, schema);

-    }

+		return new HiveFileWritePushRuntime(context, inputRecordDesc, conf,

+				fileSink, outSchema, schema);

+	}

 

-    private void readConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void readConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            PrintWriter out = new PrintWriter((new OutputStreamWriter(new FileOutputStream(new File(fileName)))));

-            out.write(confContent);

-            out.close();

-            conf = new JobConf(fileName);

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			PrintWriter out = new PrintWriter((new OutputStreamWriter(

+					new FileOutputStream(new File(fileName)))));

+			out.write(confContent);

+			out.close();

+			conf = new JobConf(fileName);

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

-    private void writeConfContent() {

-        File dir = new File("hadoop-conf-tmp");

-        if (!dir.exists()) {

-            dir.mkdir();

-        }

+	private void writeConfContent() {

+		File dir = new File("hadoop-conf-tmp");

+		if (!dir.exists()) {

+			dir.mkdir();

+		}

 

-        String fileName = "hadoop-conf-tmp/" + UUID.randomUUID() + System.currentTimeMillis() + ".xml";

-        try {

-            DataOutputStream out = new DataOutputStream(new FileOutputStream(new File(fileName)));

-            conf.writeXml(out);

-            out.close();

+		String fileName = "hadoop-conf-tmp/" + UUID.randomUUID()

+				+ System.currentTimeMillis() + ".xml";

+		try {

+			DataOutputStream out = new DataOutputStream(new FileOutputStream(

+					new File(fileName)));

+			conf.writeXml(out);

+			out.close();

 

-            DataInputStream in = new DataInputStream(new FileInputStream(fileName));

-            StringBuffer buffer = new StringBuffer();

-            String line;

-            while ((line = in.readLine()) != null) {

-                buffer.append(line + "\n");

-            }

-            in.close();

-            confContent = buffer.toString();

-        } catch (Exception e) {

-            e.printStackTrace();

-        }

-    }

+			DataInputStream in = new DataInputStream(new FileInputStream(

+					fileName));

+			StringBuffer buffer = new StringBuffer();

+			String line;

+			while ((line = in.readLine()) != null) {

+				buffer.append(line + "\n");

+			}

+			in.close();

+			confContent = buffer.toString();

+		} catch (Exception e) {

+			e.printStackTrace();

+		}

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryComparatorFactoryProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryComparatorFactoryProvider.java
index 467ec0a..5a2e98c 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryComparatorFactoryProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryComparatorFactoryProvider.java
@@ -21,55 +21,57 @@
 import edu.uci.ics.hyracks.algebricks.data.IBinaryComparatorFactoryProvider;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;

 

-public class HiveBinaryComparatorFactoryProvider implements IBinaryComparatorFactoryProvider {

+public class HiveBinaryComparatorFactoryProvider implements

+		IBinaryComparatorFactoryProvider {

 

-    public static final HiveBinaryComparatorFactoryProvider INSTANCE = new HiveBinaryComparatorFactoryProvider();

+	public static final HiveBinaryComparatorFactoryProvider INSTANCE = new HiveBinaryComparatorFactoryProvider();

 

-    private HiveBinaryComparatorFactoryProvider() {

-    }

+	private HiveBinaryComparatorFactoryProvider() {

+	}

 

-    @Override

-    public IBinaryComparatorFactory getBinaryComparatorFactory(Object type, boolean ascending)

-            throws AlgebricksException {

-        if (type.equals(TypeInfoFactory.intTypeInfo)) {

-            if (ascending)

-                return HiveIntegerBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveIntegerBinaryDescComparatorFactory.INSTANCE;

+	@Override

+	public IBinaryComparatorFactory getBinaryComparatorFactory(Object type,

+			boolean ascending) throws AlgebricksException {

+		if (type.equals(TypeInfoFactory.intTypeInfo)) {

+			if (ascending)

+				return HiveIntegerBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveIntegerBinaryDescComparatorFactory.INSTANCE;

 

-        } else if (type.equals(TypeInfoFactory.longTypeInfo)) {

-            if (ascending)

-                return HiveLongBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveLongBinaryDescComparatorFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.longTypeInfo)) {

+			if (ascending)

+				return HiveLongBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveLongBinaryDescComparatorFactory.INSTANCE;

 

-        } else if (type.equals(TypeInfoFactory.floatTypeInfo)) {

-            if (ascending)

-                return HiveFloatBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveFloatBinaryDescComparatorFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.floatTypeInfo)) {

+			if (ascending)

+				return HiveFloatBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveFloatBinaryDescComparatorFactory.INSTANCE;

 

-        } else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {

-            if (ascending)

-                return HiveDoubleBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveDoubleBinaryDescComparatorFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.shortTypeInfo)) {

-            if (ascending)

-                return HiveShortBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveShortBinaryDescComparatorFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.stringTypeInfo)) {

-            if (ascending)

-                return HiveStringBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveStringBinaryDescComparatorFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.byteTypeInfo) || type.equals(TypeInfoFactory.booleanTypeInfo)) {

-            if (ascending)

-                return HiveByteBinaryAscComparatorFactory.INSTANCE;

-            else

-                return HiveByteBinaryDescComparatorFactory.INSTANCE;

-        } else

-            throw new NotImplementedException();

-    }

+		} else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {

+			if (ascending)

+				return HiveDoubleBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveDoubleBinaryDescComparatorFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.shortTypeInfo)) {

+			if (ascending)

+				return HiveShortBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveShortBinaryDescComparatorFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.stringTypeInfo)) {

+			if (ascending)

+				return HiveStringBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveStringBinaryDescComparatorFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.byteTypeInfo)

+				|| type.equals(TypeInfoFactory.booleanTypeInfo)) {

+			if (ascending)

+				return HiveByteBinaryAscComparatorFactory.INSTANCE;

+			else

+				return HiveByteBinaryDescComparatorFactory.INSTANCE;

+		} else

+			throw new NotImplementedException();

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryHashFunctionFactoryProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryHashFunctionFactoryProvider.java
index 473eee1..371d45b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryHashFunctionFactoryProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveBinaryHashFunctionFactoryProvider.java
@@ -11,25 +11,27 @@
 import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFactoryProvider;

 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;

 

-public class HiveBinaryHashFunctionFactoryProvider implements IBinaryHashFunctionFactoryProvider {

+public class HiveBinaryHashFunctionFactoryProvider implements

+		IBinaryHashFunctionFactoryProvider {

 

-    public static final HiveBinaryHashFunctionFactoryProvider INSTANCE = new HiveBinaryHashFunctionFactoryProvider();

+	public static final HiveBinaryHashFunctionFactoryProvider INSTANCE = new HiveBinaryHashFunctionFactoryProvider();

 

-    private HiveBinaryHashFunctionFactoryProvider() {

-    }

+	private HiveBinaryHashFunctionFactoryProvider() {

+	}

 

-    @Override

-    public IBinaryHashFunctionFactory getBinaryHashFunctionFactory(Object type) throws AlgebricksException {

-        if (type.equals(TypeInfoFactory.intTypeInfo)) {

-            return HiveIntegerBinaryHashFunctionFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.longTypeInfo)) {

-            return HiveLongBinaryHashFunctionFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.stringTypeInfo)) {

-            return HiveStingBinaryHashFunctionFactory.INSTANCE;

-        } else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {

-            return HiveDoubleBinaryHashFunctionFactory.INSTANCE;

-        } else {

-            return HiveRawBinaryHashFunctionFactory.INSTANCE;

-        }

-    }

+	@Override

+	public IBinaryHashFunctionFactory getBinaryHashFunctionFactory(Object type)

+			throws AlgebricksException {

+		if (type.equals(TypeInfoFactory.intTypeInfo)) {

+			return HiveIntegerBinaryHashFunctionFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.longTypeInfo)) {

+			return HiveLongBinaryHashFunctionFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.stringTypeInfo)) {

+			return HiveStingBinaryHashFunctionFactory.INSTANCE;

+		} else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {

+			return HiveDoubleBinaryHashFunctionFactory.INSTANCE;

+		} else {

+			return HiveRawBinaryHashFunctionFactory.INSTANCE;

+		}

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveNormalizedKeyComputerFactoryProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveNormalizedKeyComputerFactoryProvider.java
index 91bf3e5..9e3a8ae 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveNormalizedKeyComputerFactoryProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveNormalizedKeyComputerFactoryProvider.java
@@ -13,39 +13,41 @@
 import edu.uci.ics.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider;
 import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
 
-public class HiveNormalizedKeyComputerFactoryProvider implements INormalizedKeyComputerFactoryProvider {
+public class HiveNormalizedKeyComputerFactoryProvider implements
+		INormalizedKeyComputerFactoryProvider {
 
-    public static final HiveNormalizedKeyComputerFactoryProvider INSTANCE = new HiveNormalizedKeyComputerFactoryProvider();
+	public static final HiveNormalizedKeyComputerFactoryProvider INSTANCE = new HiveNormalizedKeyComputerFactoryProvider();
 
-    private HiveNormalizedKeyComputerFactoryProvider() {
-    }
+	private HiveNormalizedKeyComputerFactoryProvider() {
+	}
 
-    @Override
-    public INormalizedKeyComputerFactory getNormalizedKeyComputerFactory(Object type, boolean ascending) {
-        if (ascending) {
-            if (type.equals(TypeInfoFactory.stringTypeInfo)) {
-                return new HiveStringAscNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.intTypeInfo)) {
-                return new HiveIntegerAscNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.longTypeInfo)) {
-                return new HiveLongAscNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {
-                return new HiveDoubleAscNormalizedKeyComputerFactory();
-            } else {
-                return null;
-            }
-        } else {
-            if (type.equals(TypeInfoFactory.stringTypeInfo)) {
-                return new HiveStringDescNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.intTypeInfo)) {
-                return new HiveIntegerDescNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.longTypeInfo)) {
-                return new HiveLongDescNormalizedKeyComputerFactory();
-            } else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {
-                return new HiveDoubleDescNormalizedKeyComputerFactory();
-            } else {
-                return null;
-            }
-        }
-    }
+	@Override
+	public INormalizedKeyComputerFactory getNormalizedKeyComputerFactory(
+			Object type, boolean ascending) {
+		if (ascending) {
+			if (type.equals(TypeInfoFactory.stringTypeInfo)) {
+				return new HiveStringAscNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.intTypeInfo)) {
+				return new HiveIntegerAscNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.longTypeInfo)) {
+				return new HiveLongAscNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {
+				return new HiveDoubleAscNormalizedKeyComputerFactory();
+			} else {
+				return null;
+			}
+		} else {
+			if (type.equals(TypeInfoFactory.stringTypeInfo)) {
+				return new HiveStringDescNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.intTypeInfo)) {
+				return new HiveIntegerDescNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.longTypeInfo)) {
+				return new HiveLongDescNormalizedKeyComputerFactory();
+			} else if (type.equals(TypeInfoFactory.doubleTypeInfo)) {
+				return new HiveDoubleDescNormalizedKeyComputerFactory();
+			} else {
+				return null;
+			}
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HivePrinterFactoryProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HivePrinterFactoryProvider.java
index 10c84d2..bebb457 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HivePrinterFactoryProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HivePrinterFactoryProvider.java
@@ -6,11 +6,12 @@
 

 public class HivePrinterFactoryProvider implements IPrinterFactoryProvider {

 

-    public static IPrinterFactoryProvider INSTANCE = new HivePrinterFactoryProvider();

+	public static IPrinterFactoryProvider INSTANCE = new HivePrinterFactoryProvider();

 

-    @Override

-    public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException {

-        return null;

-    }

+	@Override

+	public IPrinterFactory getPrinterFactory(Object type)

+			throws AlgebricksException {

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveSerializerDeserializerProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveSerializerDeserializerProvider.java
index c8b5699..ea521a6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveSerializerDeserializerProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveSerializerDeserializerProvider.java
@@ -4,18 +4,20 @@
 import edu.uci.ics.hyracks.algebricks.data.ISerializerDeserializerProvider;

 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;

 

-public class HiveSerializerDeserializerProvider implements ISerializerDeserializerProvider {

+public class HiveSerializerDeserializerProvider implements

+		ISerializerDeserializerProvider {

 

-    public static final HiveSerializerDeserializerProvider INSTANCE = new HiveSerializerDeserializerProvider();

+	public static final HiveSerializerDeserializerProvider INSTANCE = new HiveSerializerDeserializerProvider();

 

-    private HiveSerializerDeserializerProvider() {

-    }

+	private HiveSerializerDeserializerProvider() {

+	}

 

-    @Override

-    public ISerializerDeserializer getSerializerDeserializer(Object type) throws AlgebricksException {

-        // TODO Auto-generated method stub

-        // return ARecordSerializerDeserializer.SCHEMALESS_INSTANCE;

-        return null;

-    }

+	@Override

+	public ISerializerDeserializer getSerializerDeserializer(Object type)

+			throws AlgebricksException {

+		// TODO Auto-generated method stub

+		// return ARecordSerializerDeserializer.SCHEMALESS_INSTANCE;

+		return null;

+	}

 

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveTypeTraitProvider.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveTypeTraitProvider.java
index 6ed1e63..4513dbd 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveTypeTraitProvider.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/runtime/provider/HiveTypeTraitProvider.java
@@ -7,27 +7,27 @@
 
 public class HiveTypeTraitProvider implements ITypeTraitProvider, Serializable {
 
-    public static HiveTypeTraitProvider INSTANCE = new HiveTypeTraitProvider();
+	public static HiveTypeTraitProvider INSTANCE = new HiveTypeTraitProvider();
 
-    private HiveTypeTraitProvider() {
+	private HiveTypeTraitProvider() {
 
-    }
+	}
 
-    @Override
-    public ITypeTraits getTypeTrait(Object arg0) {
-        return new ITypeTraits() {
-            private static final long serialVersionUID = 1L;
+	@Override
+	public ITypeTraits getTypeTrait(Object arg0) {
+		return new ITypeTraits() {
+			private static final long serialVersionUID = 1L;
 
-            @Override
-            public int getFixedLength() {
-                return -1;
-            }
+			@Override
+			public int getFixedLength() {
+				return -1;
+			}
 
-            @Override
-            public boolean isFixedLength() {
-                return false;
-            }
+			@Override
+			public boolean isFixedLength() {
+				return false;
+			}
 
-        };
-    }
+		};
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/ByteArrayRef.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/ByteArrayRef.java
index 9bf74b7..673416d 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/ByteArrayRef.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/ByteArrayRef.java
@@ -26,17 +26,17 @@
  */
 public class ByteArrayRef {
 
-    /**
-     * Stores the actual data.
-     */
-    byte[] data;
+	/**
+	 * Stores the actual data.
+	 */
+	byte[] data;
 
-    public byte[] getData() {
-        return data;
-    }
+	public byte[] getData() {
+		return data;
+	}
 
-    public void setData(byte[] data) {
-        this.data = data;
-    }
+	public void setData(byte[] data) {
+		this.data = data;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyArray.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyArray.java
index b79cd86..d36d96d 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyArray.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyArray.java
@@ -43,189 +43,193 @@
 
 public class LazyArray extends LazyNonPrimitive<LazyListObjectInspector> {
 
-    /**
-     * Whether the data is already parsed or not.
-     */
-    boolean parsed = false;
-    /**
-     * The length of the array. Only valid when the data is parsed.
-     */
-    int arraySize = 0;
+	/**
+	 * Whether the data is already parsed or not.
+	 */
+	boolean parsed = false;
+	/**
+	 * The length of the array. Only valid when the data is parsed.
+	 */
+	int arraySize = 0;
 
-    /**
-     * The start positions and lengths of array elements. Only valid when the
-     * data is parsed.
-     */
-    int[] elementStart;
-    int[] elementLength;
+	/**
+	 * The start positions and lengths of array elements. Only valid when the
+	 * data is parsed.
+	 */
+	int[] elementStart;
+	int[] elementLength;
 
-    /**
-     * Whether an element is initialized or not.
-     */
-    boolean[] elementInited;
+	/**
+	 * Whether an element is initialized or not.
+	 */
+	boolean[] elementInited;
 
-    /**
-     * Whether an element is null or not. Because length is 0 does not means the
-     * field is null. In particular, a 0-length string is not null.
-     */
-    boolean[] elementIsNull;
+	/**
+	 * Whether an element is null or not. Because length is 0 does not means the
+	 * field is null. In particular, a 0-length string is not null.
+	 */
+	boolean[] elementIsNull;
 
-    /**
-     * The elements of the array. Note that we call arrayElements[i].init(bytes,
-     * begin, length) only when that element is accessed.
-     */
-    LazyObject[] arrayElements;
+	/**
+	 * The elements of the array. Note that we call arrayElements[i].init(bytes,
+	 * begin, length) only when that element is accessed.
+	 */
+	LazyObject[] arrayElements;
 
-    /**
-     * Construct a LazyArray object with the ObjectInspector.
-     * 
-     * @param oi
-     *            the oi representing the type of this LazyArray
-     */
-    protected LazyArray(LazyListObjectInspector oi) {
-        super(oi);
-    }
+	/**
+	 * Construct a LazyArray object with the ObjectInspector.
+	 * 
+	 * @param oi
+	 *            the oi representing the type of this LazyArray
+	 */
+	protected LazyArray(LazyListObjectInspector oi) {
+		super(oi);
+	}
 
-    /**
-     * Set the row data for this LazyArray.
-     * 
-     * @see LazyObject#init(ByteArrayRef, int, int)
-     */
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        super.init(bytes, start, length);
-        parsed = false;
-    }
+	/**
+	 * Set the row data for this LazyArray.
+	 * 
+	 * @see LazyObject#init(ByteArrayRef, int, int)
+	 */
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		super.init(bytes, start, length);
+		parsed = false;
+	}
 
-    /**
-     * Enlarge the size of arrays storing information for the elements inside
-     * the array.
-     */
-    private void adjustArraySize(int newSize) {
-        if (elementStart == null || elementStart.length < newSize) {
-            elementStart = new int[newSize];
-            elementLength = new int[newSize];
-            elementInited = new boolean[newSize];
-            elementIsNull = new boolean[newSize];
-            arrayElements = new LazyObject[newSize];
-        }
-    }
+	/**
+	 * Enlarge the size of arrays storing information for the elements inside
+	 * the array.
+	 */
+	private void adjustArraySize(int newSize) {
+		if (elementStart == null || elementStart.length < newSize) {
+			elementStart = new int[newSize];
+			elementLength = new int[newSize];
+			elementInited = new boolean[newSize];
+			elementIsNull = new boolean[newSize];
+			arrayElements = new LazyObject[newSize];
+		}
+	}
 
-    VInt vInt = new LazyUtils.VInt();
-    RecordInfo recordInfo = new LazyUtils.RecordInfo();
+	VInt vInt = new LazyUtils.VInt();
+	RecordInfo recordInfo = new LazyUtils.RecordInfo();
 
-    /**
-     * Parse the bytes and fill elementStart, elementLength, elementInited and
-     * elementIsNull.
-     */
-    private void parse() {
+	/**
+	 * Parse the bytes and fill elementStart, elementLength, elementInited and
+	 * elementIsNull.
+	 */
+	private void parse() {
 
-        // get the vlong that represents the map size
-        LazyUtils.readVInt(bytes, start, vInt);
-        arraySize = vInt.value;
-        if (0 == arraySize) {
-            parsed = true;
-            return;
-        }
+		// get the vlong that represents the map size
+		LazyUtils.readVInt(bytes, start, vInt);
+		arraySize = vInt.value;
+		if (0 == arraySize) {
+			parsed = true;
+			return;
+		}
 
-        // adjust arrays
-        adjustArraySize(arraySize);
-        // find out the null-bytes
-        int arryByteStart = start + vInt.length;
-        int nullByteCur = arryByteStart;
-        int nullByteEnd = arryByteStart + (arraySize + 7) / 8;
-        // the begin the real elements
-        int lastElementByteEnd = nullByteEnd;
-        // the list element object inspector
-        ObjectInspector listEleObjectInspector = ((ListObjectInspector) oi).getListElementObjectInspector();
-        // parsing elements one by one
-        for (int i = 0; i < arraySize; i++) {
-            elementIsNull[i] = true;
-            if ((bytes[nullByteCur] & (1 << (i % 8))) != 0) {
-                elementIsNull[i] = false;
-                LazyUtils.checkObjectByteInfo(listEleObjectInspector, bytes, lastElementByteEnd, recordInfo);
-                elementStart[i] = lastElementByteEnd + recordInfo.elementOffset;
-                elementLength[i] = recordInfo.elementSize;
-                lastElementByteEnd = elementStart[i] + elementLength[i];
-            }
-            // move onto the next null byte
-            if (7 == (i % 8)) {
-                nullByteCur++;
-            }
-        }
+		// adjust arrays
+		adjustArraySize(arraySize);
+		// find out the null-bytes
+		int arryByteStart = start + vInt.length;
+		int nullByteCur = arryByteStart;
+		int nullByteEnd = arryByteStart + (arraySize + 7) / 8;
+		// the begin the real elements
+		int lastElementByteEnd = nullByteEnd;
+		// the list element object inspector
+		ObjectInspector listEleObjectInspector = ((ListObjectInspector) oi)
+				.getListElementObjectInspector();
+		// parsing elements one by one
+		for (int i = 0; i < arraySize; i++) {
+			elementIsNull[i] = true;
+			if ((bytes[nullByteCur] & (1 << (i % 8))) != 0) {
+				elementIsNull[i] = false;
+				LazyUtils.checkObjectByteInfo(listEleObjectInspector, bytes,
+						lastElementByteEnd, recordInfo);
+				elementStart[i] = lastElementByteEnd + recordInfo.elementOffset;
+				elementLength[i] = recordInfo.elementSize;
+				lastElementByteEnd = elementStart[i] + elementLength[i];
+			}
+			// move onto the next null byte
+			if (7 == (i % 8)) {
+				nullByteCur++;
+			}
+		}
 
-        Arrays.fill(elementInited, 0, arraySize, false);
-        parsed = true;
-    }
+		Arrays.fill(elementInited, 0, arraySize, false);
+		parsed = true;
+	}
 
-    /**
-     * Returns the actual primitive object at the index position inside the
-     * array represented by this LazyObject.
-     */
-    public Object getListElementObject(int index) {
-        if (!parsed) {
-            parse();
-        }
-        if (index < 0 || index >= arraySize) {
-            return null;
-        }
-        return uncheckedGetElement(index);
-    }
+	/**
+	 * Returns the actual primitive object at the index position inside the
+	 * array represented by this LazyObject.
+	 */
+	public Object getListElementObject(int index) {
+		if (!parsed) {
+			parse();
+		}
+		if (index < 0 || index >= arraySize) {
+			return null;
+		}
+		return uncheckedGetElement(index);
+	}
 
-    /**
-     * Get the element without checking out-of-bound index.
-     * 
-     * @param index
-     *            index to the array element
-     */
-    private Object uncheckedGetElement(int index) {
+	/**
+	 * Get the element without checking out-of-bound index.
+	 * 
+	 * @param index
+	 *            index to the array element
+	 */
+	private Object uncheckedGetElement(int index) {
 
-        if (elementIsNull[index]) {
-            return null;
-        } else {
-            if (!elementInited[index]) {
-                elementInited[index] = true;
-                if (arrayElements[index] == null) {
-                    arrayElements[index] = LazyFactory.createLazyObject((oi).getListElementObjectInspector());
-                }
-                arrayElements[index].init(bytes, elementStart[index], elementLength[index]);
-            }
-        }
-        return arrayElements[index].getObject();
-    }
+		if (elementIsNull[index]) {
+			return null;
+		} else {
+			if (!elementInited[index]) {
+				elementInited[index] = true;
+				if (arrayElements[index] == null) {
+					arrayElements[index] = LazyFactory.createLazyObject((oi)
+							.getListElementObjectInspector());
+				}
+				arrayElements[index].init(bytes, elementStart[index],
+						elementLength[index]);
+			}
+		}
+		return arrayElements[index].getObject();
+	}
 
-    /**
-     * Returns the array size.
-     */
-    public int getListLength() {
-        if (!parsed) {
-            parse();
-        }
-        return arraySize;
-    }
+	/**
+	 * Returns the array size.
+	 */
+	public int getListLength() {
+		if (!parsed) {
+			parse();
+		}
+		return arraySize;
+	}
 
-    /**
-     * cachedList is reused every time getList is called. Different
-     * LazyBianryArray instances cannot share the same cachedList.
-     */
-    ArrayList<Object> cachedList;
+	/**
+	 * cachedList is reused every time getList is called. Different
+	 * LazyBianryArray instances cannot share the same cachedList.
+	 */
+	ArrayList<Object> cachedList;
 
-    /**
-     * Returns the List of actual primitive objects. Returns null for null
-     * array.
-     */
-    public List<Object> getList() {
-        if (!parsed) {
-            parse();
-        }
-        if (cachedList == null) {
-            cachedList = new ArrayList<Object>(arraySize);
-        } else {
-            cachedList.clear();
-        }
-        for (int index = 0; index < arraySize; index++) {
-            cachedList.add(uncheckedGetElement(index));
-        }
-        return cachedList;
-    }
+	/**
+	 * Returns the List of actual primitive objects. Returns null for null
+	 * array.
+	 */
+	public List<Object> getList() {
+		if (!parsed) {
+			parse();
+		}
+		if (cachedList == null) {
+			cachedList = new ArrayList<Object>(arraySize);
+		} else {
+			cachedList.clear();
+		}
+		for (int index = 0; index < arraySize; index++) {
+			cachedList.add(uncheckedGetElement(index));
+		}
+		return cachedList;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyBoolean.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyBoolean.java
index 471a64a..83b6254 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyBoolean.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyBoolean.java
@@ -34,34 +34,35 @@
  * </p>
  * 
  */
-public class LazyBoolean extends LazyPrimitive<LazyBooleanObjectInspector, BooleanWritable> {
+public class LazyBoolean extends
+		LazyPrimitive<LazyBooleanObjectInspector, BooleanWritable> {
 
-    public LazyBoolean(LazyBooleanObjectInspector oi) {
-        super(oi);
-        data = new BooleanWritable();
-    }
+	public LazyBoolean(LazyBooleanObjectInspector oi) {
+		super(oi);
+		data = new BooleanWritable();
+	}
 
-    public LazyBoolean(LazyBoolean copy) {
-        super(copy);
-        data = new BooleanWritable(copy.data.get());
-    }
+	public LazyBoolean(LazyBoolean copy) {
+		super(copy);
+		data = new BooleanWritable(copy.data.get());
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
-        
-        // a temporal hack
-        assert (1 == length);
-        byte val = bytes[start];
-        if (val == 0) {
-            data.set(false);
-        } else if (val == 1) {
-            data.set(true);
-        }
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
+
+		// a temporal hack
+		assert (1 == length);
+		byte val = bytes[start];
+		if (val == 0) {
+			data.set(false);
+		} else if (val == 1) {
+			data.set(true);
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyByte.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyByte.java
index d57dcb8..264015b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyByte.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyByte.java
@@ -34,28 +34,29 @@
  * </p>
  * 
  */
-public class LazyByte extends LazyPrimitive<LazyByteObjectInspector, ByteWritable> {
+public class LazyByte extends
+		LazyPrimitive<LazyByteObjectInspector, ByteWritable> {
 
-    public LazyByte(LazyByteObjectInspector oi) {
-        super(oi);
-        data = new ByteWritable();
-    }
+	public LazyByte(LazyByteObjectInspector oi) {
+		super(oi);
+		data = new ByteWritable();
+	}
 
-    public LazyByte(LazyByte copy) {
-        super(copy);
-        data = new ByteWritable(copy.data.get());
-    }
+	public LazyByte(LazyByte copy) {
+		super(copy);
+		data = new ByteWritable(copy.data.get());
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
-        
-        assert (1 == length);
-        data.set(bytes[start]);
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
+
+		assert (1 == length);
+		data.set(bytes[start]);
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyColumnar.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyColumnar.java
index 2ca9ded..e538c71 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyColumnar.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyColumnar.java
@@ -38,175 +38,177 @@
  */
 public class LazyColumnar extends LazyNonPrimitive<LazyColumnarObjectInspector> {
 
-    private static Log LOG = LogFactory.getLog(LazyColumnar.class.getName());
+	private static Log LOG = LogFactory.getLog(LazyColumnar.class.getName());
 
-    /**
-     * IFrameTupleReference: the backend of the struct
-     */
-    IFrameTupleReference tuple;
+	/**
+	 * IFrameTupleReference: the backend of the struct
+	 */
+	IFrameTupleReference tuple;
 
-    /**
-     * Whether the data is already parsed or not.
-     */
-    boolean reset;
+	/**
+	 * Whether the data is already parsed or not.
+	 */
+	boolean reset;
 
-    /**
-     * The fields of the struct.
-     */
-    LazyObject[] fields;
+	/**
+	 * The fields of the struct.
+	 */
+	LazyObject[] fields;
 
-    /**
-     * Whether init() has been called on the field or not.
-     */
-    boolean[] fieldVisited;
+	/**
+	 * Whether init() has been called on the field or not.
+	 */
+	boolean[] fieldVisited;
 
-    /**
-     * whether it is the first time initialization
-     */
-    boolean start = true;
+	/**
+	 * whether it is the first time initialization
+	 */
+	boolean start = true;
 
-    /**
-     * Construct a LazyStruct object with the ObjectInspector.
-     */
-    public LazyColumnar(LazyColumnarObjectInspector oi) {
-        super(oi);
-    }
+	/**
+	 * Construct a LazyStruct object with the ObjectInspector.
+	 */
+	public LazyColumnar(LazyColumnarObjectInspector oi) {
+		super(oi);
+	}
 
-    /**
-     * Set the row data for this LazyStruct.
-     * 
-     * @see LazyObject#init(ByteArrayRef, int, int)
-     */
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        super.init(bytes, start, length);
-        reset = false;
-    }
+	/**
+	 * Set the row data for this LazyStruct.
+	 * 
+	 * @see LazyObject#init(ByteArrayRef, int, int)
+	 */
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		super.init(bytes, start, length);
+		reset = false;
+	}
 
-    /**
-     * Parse the byte[] and fill each field.
-     */
-    private void parse() {
+	/**
+	 * Parse the byte[] and fill each field.
+	 */
+	private void parse() {
 
-        if (start) {
-            // initialize field array and reusable objects
-            List<? extends StructField> fieldRefs = ((StructObjectInspector) oi).getAllStructFieldRefs();
+		if (start) {
+			// initialize field array and reusable objects
+			List<? extends StructField> fieldRefs = ((StructObjectInspector) oi)
+					.getAllStructFieldRefs();
 
-            fields = new LazyObject[fieldRefs.size()];
-            for (int i = 0; i < fields.length; i++) {
-                fields[i] = LazyFactory.createLazyObject(fieldRefs.get(i).getFieldObjectInspector());
-            }
-            fieldVisited = new boolean[fields.length];
-            start = false;
-        }
+			fields = new LazyObject[fieldRefs.size()];
+			for (int i = 0; i < fields.length; i++) {
+				fields[i] = LazyFactory.createLazyObject(fieldRefs.get(i)
+						.getFieldObjectInspector());
+			}
+			fieldVisited = new boolean[fields.length];
+			start = false;
+		}
 
-        Arrays.fill(fieldVisited, false);
-        reset = true;
-    }
+		Arrays.fill(fieldVisited, false);
+		reset = true;
+	}
 
-    /**
-     * Get one field out of the struct.
-     * 
-     * If the field is a primitive field, return the actual object. Otherwise
-     * return the LazyObject. This is because PrimitiveObjectInspector does not
-     * have control over the object used by the user - the user simply directly
-     * use the Object instead of going through Object
-     * PrimitiveObjectInspector.get(Object).
-     * 
-     * @param fieldID
-     *            The field ID
-     * @return The field as a LazyObject
-     */
-    public Object getField(int fieldID) {
-        if (!reset) {
-            parse();
-        }
-        return uncheckedGetField(fieldID);
-    }
+	/**
+	 * Get one field out of the struct.
+	 * 
+	 * If the field is a primitive field, return the actual object. Otherwise
+	 * return the LazyObject. This is because PrimitiveObjectInspector does not
+	 * have control over the object used by the user - the user simply directly
+	 * use the Object instead of going through Object
+	 * PrimitiveObjectInspector.get(Object).
+	 * 
+	 * @param fieldID
+	 *            The field ID
+	 * @return The field as a LazyObject
+	 */
+	public Object getField(int fieldID) {
+		if (!reset) {
+			parse();
+		}
+		return uncheckedGetField(fieldID);
+	}
 
-    /**
-     * Get the field out of the row without checking parsed. This is called by
-     * both getField and getFieldsAsList.
-     * 
-     * @param fieldID
-     *            The id of the field starting from 0.
-     * @param nullSequence
-     *            The sequence representing NULL value.
-     * @return The value of the field
-     */
-    private Object uncheckedGetField(int fieldID) {
-        // get the buffer
-        byte[] buffer = tuple.getFieldData(fieldID);
-        // get the offset of the field
-        int s1 = tuple.getFieldStart(fieldID);
-        int l1 = tuple.getFieldLength(fieldID);
+	/**
+	 * Get the field out of the row without checking parsed. This is called by
+	 * both getField and getFieldsAsList.
+	 * 
+	 * @param fieldID
+	 *            The id of the field starting from 0.
+	 * @param nullSequence
+	 *            The sequence representing NULL value.
+	 * @return The value of the field
+	 */
+	private Object uncheckedGetField(int fieldID) {
+		// get the buffer
+		byte[] buffer = tuple.getFieldData(fieldID);
+		// get the offset of the field
+		int s1 = tuple.getFieldStart(fieldID);
+		int l1 = tuple.getFieldLength(fieldID);
 
-        if (!fieldVisited[fieldID]) {
-            fieldVisited[fieldID] = true;
-            fields[fieldID].init(buffer, s1, l1);
-        }
-        //if (fields[fieldID].getObject() == null) {
-        //    throw new IllegalStateException("illegal field " + fieldID);
-        //}
-        return fields[fieldID].getObject();
-    }
+		if (!fieldVisited[fieldID]) {
+			fieldVisited[fieldID] = true;
+			fields[fieldID].init(buffer, s1, l1);
+		}
+		// if (fields[fieldID].getObject() == null) {
+		// throw new IllegalStateException("illegal field " + fieldID);
+		// }
+		return fields[fieldID].getObject();
+	}
 
-    ArrayList<Object> cachedList;
+	ArrayList<Object> cachedList;
 
-    /**
-     * Get the values of the fields as an ArrayList.
-     * 
-     * @return The values of the fields as an ArrayList.
-     */
-    public ArrayList<Object> getFieldsAsList() {
-        if (!reset) {
-            parse();
-        }
-        if (cachedList == null) {
-            cachedList = new ArrayList<Object>();
-        } else {
-            cachedList.clear();
-        }
-        for (int i = 0; i < fields.length; i++) {
-            cachedList.add(uncheckedGetField(i));
-        }
-        return cachedList;
-    }
+	/**
+	 * Get the values of the fields as an ArrayList.
+	 * 
+	 * @return The values of the fields as an ArrayList.
+	 */
+	public ArrayList<Object> getFieldsAsList() {
+		if (!reset) {
+			parse();
+		}
+		if (cachedList == null) {
+			cachedList = new ArrayList<Object>();
+		} else {
+			cachedList.clear();
+		}
+		for (int i = 0; i < fields.length; i++) {
+			cachedList.add(uncheckedGetField(i));
+		}
+		return cachedList;
+	}
 
-    @Override
-    public Object getObject() {
-        return this;
-    }
+	@Override
+	public Object getObject() {
+		return this;
+	}
 
-    protected boolean getParsed() {
-        return reset;
-    }
+	protected boolean getParsed() {
+		return reset;
+	}
 
-    protected void setParsed(boolean parsed) {
-        this.reset = parsed;
-    }
+	protected void setParsed(boolean parsed) {
+		this.reset = parsed;
+	}
 
-    protected LazyObject[] getFields() {
-        return fields;
-    }
+	protected LazyObject[] getFields() {
+		return fields;
+	}
 
-    protected void setFields(LazyObject[] fields) {
-        this.fields = fields;
-    }
+	protected void setFields(LazyObject[] fields) {
+		this.fields = fields;
+	}
 
-    protected boolean[] getFieldInited() {
-        return fieldVisited;
-    }
+	protected boolean[] getFieldInited() {
+		return fieldVisited;
+	}
 
-    protected void setFieldInited(boolean[] fieldInited) {
-        this.fieldVisited = fieldInited;
-    }
+	protected void setFieldInited(boolean[] fieldInited) {
+		this.fieldVisited = fieldInited;
+	}
 
-    /**
-     * rebind a frametuplereference to the struct
-     */
-    public void init(IFrameTupleReference r) {
-        this.tuple = r;
-        reset = false;
-    }
+	/**
+	 * rebind a frametuplereference to the struct
+	 */
+	public void init(IFrameTupleReference r) {
+		this.tuple = r;
+		reset = false;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyDouble.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyDouble.java
index f7bb633..d687aa1 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyDouble.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyDouble.java
@@ -25,27 +25,29 @@
  * LazyObject for storing a value of Double.
  * 
  */
-public class LazyDouble extends LazyPrimitive<LazyDoubleObjectInspector, DoubleWritable> {
+public class LazyDouble extends
+		LazyPrimitive<LazyDoubleObjectInspector, DoubleWritable> {
 
-    public LazyDouble(LazyDoubleObjectInspector oi) {
-        super(oi);
-        data = new DoubleWritable();
-    }
+	public LazyDouble(LazyDoubleObjectInspector oi) {
+		super(oi);
+		data = new DoubleWritable();
+	}
 
-    public LazyDouble(LazyDouble copy) {
-        super(copy);
-        data = new DoubleWritable(copy.data.get());
-    }
+	public LazyDouble(LazyDouble copy) {
+		super(copy);
+		data = new DoubleWritable(copy.data.get());
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
-        assert (8 == length);
-        data.set(Double.longBitsToDouble(LazyUtils.byteArrayToLong(bytes, start)));
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
+		assert (8 == length);
+		data.set(Double.longBitsToDouble(LazyUtils
+				.byteArrayToLong(bytes, start)));
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFactory.java
index a249d61..54487b9 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFactory.java
@@ -40,56 +40,58 @@
  */
 public final class LazyFactory {
 
-    /**
-     * Create a lazy binary primitive class given the type name.
-     */
-    public static LazyPrimitive<?, ?> createLazyPrimitiveClass(PrimitiveObjectInspector oi) {
-        PrimitiveCategory p = oi.getPrimitiveCategory();
-        switch (p) {
-            case BOOLEAN:
-                return new LazyBoolean((LazyBooleanObjectInspector) oi);
-            case BYTE:
-                return new LazyByte((LazyByteObjectInspector) oi);
-            case SHORT:
-                return new LazyShort((LazyShortObjectInspector) oi);
-            case INT:
-                return new LazyInteger((LazyIntObjectInspector) oi);
-            case LONG:
-                return new LazyLong((LazyLongObjectInspector) oi);
-            case FLOAT:
-                return new LazyFloat((LazyFloatObjectInspector) oi);
-            case DOUBLE:
-                return new LazyDouble((LazyDoubleObjectInspector) oi);
-            case STRING:
-                return new LazyString((LazyStringObjectInspector) oi);
-            default:
-                throw new RuntimeException("Internal error: no LazyObject for " + p);
-        }
-    }
+	/**
+	 * Create a lazy binary primitive class given the type name.
+	 */
+	public static LazyPrimitive<?, ?> createLazyPrimitiveClass(
+			PrimitiveObjectInspector oi) {
+		PrimitiveCategory p = oi.getPrimitiveCategory();
+		switch (p) {
+		case BOOLEAN:
+			return new LazyBoolean((LazyBooleanObjectInspector) oi);
+		case BYTE:
+			return new LazyByte((LazyByteObjectInspector) oi);
+		case SHORT:
+			return new LazyShort((LazyShortObjectInspector) oi);
+		case INT:
+			return new LazyInteger((LazyIntObjectInspector) oi);
+		case LONG:
+			return new LazyLong((LazyLongObjectInspector) oi);
+		case FLOAT:
+			return new LazyFloat((LazyFloatObjectInspector) oi);
+		case DOUBLE:
+			return new LazyDouble((LazyDoubleObjectInspector) oi);
+		case STRING:
+			return new LazyString((LazyStringObjectInspector) oi);
+		default:
+			throw new RuntimeException("Internal error: no LazyObject for " + p);
+		}
+	}
 
-    /**
-     * Create a hierarchical LazyObject based on the given typeInfo.
-     */
-    public static LazyObject<? extends ObjectInspector> createLazyObject(ObjectInspector oi) {
-        ObjectInspector.Category c = oi.getCategory();
-        switch (c) {
-            case PRIMITIVE:
-                return createLazyPrimitiveClass((PrimitiveObjectInspector) oi);
-            case MAP:
-                return new LazyMap((LazyMapObjectInspector) oi);
-            case LIST:
-                return new LazyArray((LazyListObjectInspector) oi);
-            case STRUCT: // check whether it is a top-level struct
-                if (oi instanceof LazyStructObjectInspector)
-                    return new LazyStruct((LazyStructObjectInspector) oi);
-                else
-                    return new LazyColumnar((LazyColumnarObjectInspector) oi);
-        }
+	/**
+	 * Create a hierarchical LazyObject based on the given typeInfo.
+	 */
+	public static LazyObject<? extends ObjectInspector> createLazyObject(
+			ObjectInspector oi) {
+		ObjectInspector.Category c = oi.getCategory();
+		switch (c) {
+		case PRIMITIVE:
+			return createLazyPrimitiveClass((PrimitiveObjectInspector) oi);
+		case MAP:
+			return new LazyMap((LazyMapObjectInspector) oi);
+		case LIST:
+			return new LazyArray((LazyListObjectInspector) oi);
+		case STRUCT: // check whether it is a top-level struct
+			if (oi instanceof LazyStructObjectInspector)
+				return new LazyStruct((LazyStructObjectInspector) oi);
+			else
+				return new LazyColumnar((LazyColumnarObjectInspector) oi);
+		}
 
-        throw new RuntimeException("Hive LazySerDe Internal error.");
-    }
+		throw new RuntimeException("Hive LazySerDe Internal error.");
+	}
 
-    private LazyFactory() {
-        // prevent instantiation
-    }
+	private LazyFactory() {
+		// prevent instantiation
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFloat.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFloat.java
index 26aa299..303cc67 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFloat.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyFloat.java
@@ -25,28 +25,29 @@
  * LazyObject for storing a value of Double.
  * 
  */
-public class LazyFloat extends LazyPrimitive<LazyFloatObjectInspector, FloatWritable> {
+public class LazyFloat extends
+		LazyPrimitive<LazyFloatObjectInspector, FloatWritable> {
 
-    public LazyFloat(LazyFloatObjectInspector oi) {
-        super(oi);
-        data = new FloatWritable();
-    }
+	public LazyFloat(LazyFloatObjectInspector oi) {
+		super(oi);
+		data = new FloatWritable();
+	}
 
-    public LazyFloat(LazyFloat copy) {
-        super(copy);
-        data = new FloatWritable(copy.data.get());
-    }
+	public LazyFloat(LazyFloat copy) {
+		super(copy);
+		data = new FloatWritable(copy.data.get());
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
 
-        assert (4 == length);
-        data.set(Float.intBitsToFloat(LazyUtils.byteArrayToInt(bytes, start)));
-    }
+		assert (4 == length);
+		data.set(Float.intBitsToFloat(LazyUtils.byteArrayToInt(bytes, start)));
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyInteger.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyInteger.java
index 5a0f0c1..c908c40 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyInteger.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyInteger.java
@@ -35,36 +35,38 @@
  * </p>
  * 
  */
-public class LazyInteger extends LazyPrimitive<LazyIntObjectInspector, IntWritable> {
+public class LazyInteger extends
+		LazyPrimitive<LazyIntObjectInspector, IntWritable> {
 
-    public LazyInteger(LazyIntObjectInspector oi) {
-        super(oi);
-        data = new IntWritable();
-    }
+	public LazyInteger(LazyIntObjectInspector oi) {
+		super(oi);
+		data = new IntWritable();
+	}
 
-    public LazyInteger(LazyInteger copy) {
-        super(copy);
-        data = new IntWritable(copy.data.get());
-    }
+	public LazyInteger(LazyInteger copy) {
+		super(copy);
+		data = new IntWritable(copy.data.get());
+	}
 
-    /**
-     * The reusable vInt for decoding the integer.
-     */
-    VInt vInt = new LazyUtils.VInt();
+	/**
+	 * The reusable vInt for decoding the integer.
+	 */
+	VInt vInt = new LazyUtils.VInt();
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
 
-        LazyUtils.readVInt(bytes, start, vInt);
-        assert (length == vInt.length);
-        if (length != vInt.length)
-            throw new IllegalStateException("parse int: length mismatch, expected " + vInt.length + " but get "
-                    + length);
-        data.set(vInt.value);
-    }
+		LazyUtils.readVInt(bytes, start, vInt);
+		assert (length == vInt.length);
+		if (length != vInt.length)
+			throw new IllegalStateException(
+					"parse int: length mismatch, expected " + vInt.length
+							+ " but get " + length);
+		data.set(vInt.value);
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyLong.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyLong.java
index 2d02e53..38097e6 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyLong.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyLong.java
@@ -35,36 +35,37 @@
  * </p>
  * 
  */
-public class LazyLong extends LazyPrimitive<LazyLongObjectInspector, LongWritable> {
+public class LazyLong extends
+		LazyPrimitive<LazyLongObjectInspector, LongWritable> {
 
-    public LazyLong(LazyLongObjectInspector oi) {
-        super(oi);
-        data = new LongWritable();
-    }
+	public LazyLong(LazyLongObjectInspector oi) {
+		super(oi);
+		data = new LongWritable();
+	}
 
-    public LazyLong(LazyLong copy) {
-        super(copy);
-        data = new LongWritable(copy.data.get());
-    }
+	public LazyLong(LazyLong copy) {
+		super(copy);
+		data = new LongWritable(copy.data.get());
+	}
 
-    /**
-     * The reusable vLong for decoding the long.
-     */
-    VLong vLong = new LazyUtils.VLong();
+	/**
+	 * The reusable vLong for decoding the long.
+	 */
+	VLong vLong = new LazyUtils.VLong();
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
 
-        LazyUtils.readVLong(bytes, start, vLong);
-        assert (length == vLong.length);
-        if (length != vLong.length)
-            throw new IllegalStateException("parse long: length mismatch");
-        data.set(vLong.value);
-    }
+		LazyUtils.readVLong(bytes, start, vLong);
+		assert (length == vLong.length);
+		if (length != vLong.length)
+			throw new IllegalStateException("parse long: length mismatch");
+		data.set(vLong.value);
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyMap.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyMap.java
index c84a1d2..a7f930f 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyMap.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyMap.java
@@ -48,284 +48,289 @@
 
 public class LazyMap extends LazyNonPrimitive<LazyMapObjectInspector> {
 
-    private static Log LOG = LogFactory.getLog(LazyMap.class.getName());
+	private static Log LOG = LogFactory.getLog(LazyMap.class.getName());
 
-    /**
-     * Whether the data is already parsed or not.
-     */
-    boolean parsed;
+	/**
+	 * Whether the data is already parsed or not.
+	 */
+	boolean parsed;
 
-    /**
-     * The size of the map. Only valid when the data is parsed. -1 when the map
-     * is NULL.
-     */
-    int mapSize = 0;
+	/**
+	 * The size of the map. Only valid when the data is parsed. -1 when the map
+	 * is NULL.
+	 */
+	int mapSize = 0;
 
-    /**
-     * The beginning position and length of key[i] and value[i]. Only valid when
-     * the data is parsed.
-     */
-    int[] keyStart;
-    int[] keyLength;
-    int[] valueStart;
-    int[] valueLength;
-    /**
-     * Whether valueObjects[i]/keyObjects[i] is initialized or not.
-     */
-    boolean[] keyInited;
-    boolean[] valueInited;
+	/**
+	 * The beginning position and length of key[i] and value[i]. Only valid when
+	 * the data is parsed.
+	 */
+	int[] keyStart;
+	int[] keyLength;
+	int[] valueStart;
+	int[] valueLength;
+	/**
+	 * Whether valueObjects[i]/keyObjects[i] is initialized or not.
+	 */
+	boolean[] keyInited;
+	boolean[] valueInited;
 
-    /**
-     * Whether valueObjects[i]/keyObjects[i] is null or not This could not be
-     * inferred from the length of the object. In particular, a 0-length string
-     * is not null.
-     */
-    boolean[] keyIsNull;
-    boolean[] valueIsNull;
+	/**
+	 * Whether valueObjects[i]/keyObjects[i] is null or not This could not be
+	 * inferred from the length of the object. In particular, a 0-length string
+	 * is not null.
+	 */
+	boolean[] keyIsNull;
+	boolean[] valueIsNull;
 
-    /**
-     * The keys are stored in an array of LazyPrimitives.
-     */
-    LazyPrimitive<?, ?>[] keyObjects;
-    /**
-     * The values are stored in an array of LazyObjects. value[index] will start
-     * from KeyEnd[index] + 1, and ends before KeyStart[index+1] - 1.
-     */
-    LazyObject[] valueObjects;
+	/**
+	 * The keys are stored in an array of LazyPrimitives.
+	 */
+	LazyPrimitive<?, ?>[] keyObjects;
+	/**
+	 * The values are stored in an array of LazyObjects. value[index] will start
+	 * from KeyEnd[index] + 1, and ends before KeyStart[index+1] - 1.
+	 */
+	LazyObject[] valueObjects;
 
-    protected LazyMap(LazyMapObjectInspector oi) {
-        super(oi);
-    }
+	protected LazyMap(LazyMapObjectInspector oi) {
+		super(oi);
+	}
 
-    /**
-     * Set the row data for this LazyMap.
-     * 
-     * @see LazyObject#init(ByteArrayRef, int, int)
-     */
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        super.init(bytes, start, length);
-        parsed = false;
-    }
+	/**
+	 * Set the row data for this LazyMap.
+	 * 
+	 * @see LazyObject#init(ByteArrayRef, int, int)
+	 */
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		super.init(bytes, start, length);
+		parsed = false;
+	}
 
-    /**
-     * Adjust the size of arrays: keyStart, keyLength valueStart, valueLength
-     * keyInited, keyIsNull valueInited, valueIsNull.
-     */
-    protected void adjustArraySize(int newSize) {
-        if (keyStart == null || keyStart.length < newSize) {
-            keyStart = new int[newSize];
-            keyLength = new int[newSize];
-            valueStart = new int[newSize];
-            valueLength = new int[newSize];
-            keyInited = new boolean[newSize];
-            keyIsNull = new boolean[newSize];
-            valueInited = new boolean[newSize];
-            valueIsNull = new boolean[newSize];
-            keyObjects = new LazyPrimitive<?, ?>[newSize];
-            valueObjects = new LazyObject[newSize];
-        }
-    }
+	/**
+	 * Adjust the size of arrays: keyStart, keyLength valueStart, valueLength
+	 * keyInited, keyIsNull valueInited, valueIsNull.
+	 */
+	protected void adjustArraySize(int newSize) {
+		if (keyStart == null || keyStart.length < newSize) {
+			keyStart = new int[newSize];
+			keyLength = new int[newSize];
+			valueStart = new int[newSize];
+			valueLength = new int[newSize];
+			keyInited = new boolean[newSize];
+			keyIsNull = new boolean[newSize];
+			valueInited = new boolean[newSize];
+			valueIsNull = new boolean[newSize];
+			keyObjects = new LazyPrimitive<?, ?>[newSize];
+			valueObjects = new LazyObject[newSize];
+		}
+	}
 
-    boolean nullMapKey = false;
-    VInt vInt = new LazyUtils.VInt();
-    RecordInfo recordInfo = new LazyUtils.RecordInfo();
+	boolean nullMapKey = false;
+	VInt vInt = new LazyUtils.VInt();
+	RecordInfo recordInfo = new LazyUtils.RecordInfo();
 
-    /**
-     * Parse the byte[] and fill keyStart, keyLength, keyIsNull valueStart,
-     * valueLength and valueIsNull.
-     */
-    private void parse() {
+	/**
+	 * Parse the byte[] and fill keyStart, keyLength, keyIsNull valueStart,
+	 * valueLength and valueIsNull.
+	 */
+	private void parse() {
 
-        // get the VInt that represents the map size
-        LazyUtils.readVInt(bytes, start, vInt);
-        mapSize = vInt.value;
-        if (0 == mapSize) {
-            parsed = true;
-            return;
-        }
+		// get the VInt that represents the map size
+		LazyUtils.readVInt(bytes, start, vInt);
+		mapSize = vInt.value;
+		if (0 == mapSize) {
+			parsed = true;
+			return;
+		}
 
-        // adjust arrays
-        adjustArraySize(mapSize);
+		// adjust arrays
+		adjustArraySize(mapSize);
 
-        // find out the null-bytes
-        int mapByteStart = start + vInt.length;
-        int nullByteCur = mapByteStart;
-        int nullByteEnd = mapByteStart + (mapSize * 2 + 7) / 8;
-        int lastElementByteEnd = nullByteEnd;
+		// find out the null-bytes
+		int mapByteStart = start + vInt.length;
+		int nullByteCur = mapByteStart;
+		int nullByteEnd = mapByteStart + (mapSize * 2 + 7) / 8;
+		int lastElementByteEnd = nullByteEnd;
 
-        // parsing the keys and values one by one
-        for (int i = 0; i < mapSize; i++) {
-            // parse a key
-            keyIsNull[i] = true;
-            if ((bytes[nullByteCur] & (1 << ((i * 2) % 8))) != 0) {
-                keyIsNull[i] = false;
-                LazyUtils.checkObjectByteInfo(((MapObjectInspector) oi).getMapKeyObjectInspector(), bytes,
-                        lastElementByteEnd, recordInfo);
-                keyStart[i] = lastElementByteEnd + recordInfo.elementOffset;
-                keyLength[i] = recordInfo.elementSize;
-                lastElementByteEnd = keyStart[i] + keyLength[i];
-            } else if (!nullMapKey) {
-                nullMapKey = true;
-                LOG.warn("Null map key encountered! Ignoring similar problems.");
-            }
+		// parsing the keys and values one by one
+		for (int i = 0; i < mapSize; i++) {
+			// parse a key
+			keyIsNull[i] = true;
+			if ((bytes[nullByteCur] & (1 << ((i * 2) % 8))) != 0) {
+				keyIsNull[i] = false;
+				LazyUtils.checkObjectByteInfo(
+						((MapObjectInspector) oi).getMapKeyObjectInspector(),
+						bytes, lastElementByteEnd, recordInfo);
+				keyStart[i] = lastElementByteEnd + recordInfo.elementOffset;
+				keyLength[i] = recordInfo.elementSize;
+				lastElementByteEnd = keyStart[i] + keyLength[i];
+			} else if (!nullMapKey) {
+				nullMapKey = true;
+				LOG.warn("Null map key encountered! Ignoring similar problems.");
+			}
 
-            // parse a value
-            valueIsNull[i] = true;
-            if ((bytes[nullByteCur] & (1 << ((i * 2 + 1) % 8))) != 0) {
-                valueIsNull[i] = false;
-                LazyUtils.checkObjectByteInfo(((MapObjectInspector) oi).getMapValueObjectInspector(), bytes,
-                        lastElementByteEnd, recordInfo);
-                valueStart[i] = lastElementByteEnd + recordInfo.elementOffset;
-                valueLength[i] = recordInfo.elementSize;
-                lastElementByteEnd = valueStart[i] + valueLength[i];
-            }
+			// parse a value
+			valueIsNull[i] = true;
+			if ((bytes[nullByteCur] & (1 << ((i * 2 + 1) % 8))) != 0) {
+				valueIsNull[i] = false;
+				LazyUtils.checkObjectByteInfo(
+						((MapObjectInspector) oi).getMapValueObjectInspector(),
+						bytes, lastElementByteEnd, recordInfo);
+				valueStart[i] = lastElementByteEnd + recordInfo.elementOffset;
+				valueLength[i] = recordInfo.elementSize;
+				lastElementByteEnd = valueStart[i] + valueLength[i];
+			}
 
-            // move onto the next null byte
-            if (3 == (i % 4)) {
-                nullByteCur++;
-            }
-        }
+			// move onto the next null byte
+			if (3 == (i % 4)) {
+				nullByteCur++;
+			}
+		}
 
-        Arrays.fill(keyInited, 0, mapSize, false);
-        Arrays.fill(valueInited, 0, mapSize, false);
-        parsed = true;
-    }
+		Arrays.fill(keyInited, 0, mapSize, false);
+		Arrays.fill(valueInited, 0, mapSize, false);
+		parsed = true;
+	}
 
-    /**
-     * Get the value object with the index without checking parsed.
-     * 
-     * @param index
-     *            The index into the array starting from 0
-     */
-    private LazyObject uncheckedGetValue(int index) {
-        if (valueIsNull[index]) {
-            return null;
-        }
-        if (!valueInited[index]) {
-            valueInited[index] = true;
-            if (valueObjects[index] == null) {
-                valueObjects[index] = LazyFactory.createLazyObject(((MapObjectInspector) oi)
-                        .getMapValueObjectInspector());
-            }
-            valueObjects[index].init(bytes, valueStart[index], valueLength[index]);
-        }
-        return valueObjects[index];
-    }
+	/**
+	 * Get the value object with the index without checking parsed.
+	 * 
+	 * @param index
+	 *            The index into the array starting from 0
+	 */
+	private LazyObject uncheckedGetValue(int index) {
+		if (valueIsNull[index]) {
+			return null;
+		}
+		if (!valueInited[index]) {
+			valueInited[index] = true;
+			if (valueObjects[index] == null) {
+				valueObjects[index] = LazyFactory
+						.createLazyObject(((MapObjectInspector) oi)
+								.getMapValueObjectInspector());
+			}
+			valueObjects[index].init(bytes, valueStart[index],
+					valueLength[index]);
+		}
+		return valueObjects[index];
+	}
 
-    /**
-     * Get the value in the map for the key.
-     * 
-     * If there are multiple matches (which is possible in the serialized
-     * format), only the first one is returned.
-     * 
-     * The most efficient way to get the value for the key is to serialize the
-     * key and then try to find it in the array. We do linear search because in
-     * most cases, user only wants to get one or two values out of the map, and
-     * the cost of building up a HashMap is substantially higher.
-     * 
-     * @param key
-     *            The key object that we are looking for.
-     * @return The corresponding value object, or NULL if not found
-     */
-    public Object getMapValueElement(Object key) {
-        if (!parsed) {
-            parse();
-        }
-        // search for the key
-        for (int i = 0; i < mapSize; i++) {
-            LazyPrimitive<?, ?> lazyKeyI = uncheckedGetKey(i);
-            if (lazyKeyI == null) {
-                continue;
-            }
-            // getWritableObject() will convert LazyPrimitive to actual
-            // primitive
-            // writable objects.
-            Object keyI = lazyKeyI.getWritableObject();
-            if (keyI == null) {
-                continue;
-            }
-            if (keyI.equals(key)) {
-                // Got a match, return the value
-                LazyObject v = uncheckedGetValue(i);
-                return v == null ? v : v.getObject();
-            }
-        }
-        return null;
-    }
+	/**
+	 * Get the value in the map for the key.
+	 * 
+	 * If there are multiple matches (which is possible in the serialized
+	 * format), only the first one is returned.
+	 * 
+	 * The most efficient way to get the value for the key is to serialize the
+	 * key and then try to find it in the array. We do linear search because in
+	 * most cases, user only wants to get one or two values out of the map, and
+	 * the cost of building up a HashMap is substantially higher.
+	 * 
+	 * @param key
+	 *            The key object that we are looking for.
+	 * @return The corresponding value object, or NULL if not found
+	 */
+	public Object getMapValueElement(Object key) {
+		if (!parsed) {
+			parse();
+		}
+		// search for the key
+		for (int i = 0; i < mapSize; i++) {
+			LazyPrimitive<?, ?> lazyKeyI = uncheckedGetKey(i);
+			if (lazyKeyI == null) {
+				continue;
+			}
+			// getWritableObject() will convert LazyPrimitive to actual
+			// primitive
+			// writable objects.
+			Object keyI = lazyKeyI.getWritableObject();
+			if (keyI == null) {
+				continue;
+			}
+			if (keyI.equals(key)) {
+				// Got a match, return the value
+				LazyObject v = uncheckedGetValue(i);
+				return v == null ? v : v.getObject();
+			}
+		}
+		return null;
+	}
 
-    /**
-     * Get the key object with the index without checking parsed.
-     * 
-     * @param index
-     *            The index into the array starting from 0
-     */
-    private LazyPrimitive<?, ?> uncheckedGetKey(int index) {
-        if (keyIsNull[index]) {
-            return null;
-        }
-        if (!keyInited[index]) {
-            keyInited[index] = true;
-            if (keyObjects[index] == null) {
-                // Keys are always primitive
-                keyObjects[index] = LazyFactory
-                        .createLazyPrimitiveClass((PrimitiveObjectInspector) ((MapObjectInspector) oi)
-                                .getMapKeyObjectInspector());
-            }
-            keyObjects[index].init(bytes, keyStart[index], keyLength[index]);
-        }
-        return keyObjects[index];
-    }
+	/**
+	 * Get the key object with the index without checking parsed.
+	 * 
+	 * @param index
+	 *            The index into the array starting from 0
+	 */
+	private LazyPrimitive<?, ?> uncheckedGetKey(int index) {
+		if (keyIsNull[index]) {
+			return null;
+		}
+		if (!keyInited[index]) {
+			keyInited[index] = true;
+			if (keyObjects[index] == null) {
+				// Keys are always primitive
+				keyObjects[index] = LazyFactory
+						.createLazyPrimitiveClass((PrimitiveObjectInspector) ((MapObjectInspector) oi)
+								.getMapKeyObjectInspector());
+			}
+			keyObjects[index].init(bytes, keyStart[index], keyLength[index]);
+		}
+		return keyObjects[index];
+	}
 
-    /**
-     * cachedMap is reused for different calls to getMap(). But each LazyMap has
-     * a separate cachedMap so we won't overwrite the data by accident.
-     */
-    LinkedHashMap<Object, Object> cachedMap;
+	/**
+	 * cachedMap is reused for different calls to getMap(). But each LazyMap has
+	 * a separate cachedMap so we won't overwrite the data by accident.
+	 */
+	LinkedHashMap<Object, Object> cachedMap;
 
-    /**
-     * Return the map object representing this LazyMap. Note that the keyObjects
-     * will be Writable primitive objects.
-     * 
-     * @return the map object
-     */
-    public Map<Object, Object> getMap() {
-        if (!parsed) {
-            parse();
-        }
-        if (cachedMap == null) {
-            // Use LinkedHashMap to provide deterministic order
-            cachedMap = new LinkedHashMap<Object, Object>();
-        } else {
-            cachedMap.clear();
-        }
+	/**
+	 * Return the map object representing this LazyMap. Note that the keyObjects
+	 * will be Writable primitive objects.
+	 * 
+	 * @return the map object
+	 */
+	public Map<Object, Object> getMap() {
+		if (!parsed) {
+			parse();
+		}
+		if (cachedMap == null) {
+			// Use LinkedHashMap to provide deterministic order
+			cachedMap = new LinkedHashMap<Object, Object>();
+		} else {
+			cachedMap.clear();
+		}
 
-        // go through each element of the map
-        for (int i = 0; i < mapSize; i++) {
-            LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i);
-            if (lazyKey == null) {
-                continue;
-            }
-            Object key = lazyKey.getObject();
-            // do not overwrite if there are duplicate keys
-            if (key != null && !cachedMap.containsKey(key)) {
-                LazyObject lazyValue = uncheckedGetValue(i);
-                Object value = (lazyValue == null ? null : lazyValue.getObject());
-                cachedMap.put(key, value);
-            }
-        }
-        return cachedMap;
-    }
+		// go through each element of the map
+		for (int i = 0; i < mapSize; i++) {
+			LazyPrimitive<?, ?> lazyKey = uncheckedGetKey(i);
+			if (lazyKey == null) {
+				continue;
+			}
+			Object key = lazyKey.getObject();
+			// do not overwrite if there are duplicate keys
+			if (key != null && !cachedMap.containsKey(key)) {
+				LazyObject lazyValue = uncheckedGetValue(i);
+				Object value = (lazyValue == null ? null : lazyValue
+						.getObject());
+				cachedMap.put(key, value);
+			}
+		}
+		return cachedMap;
+	}
 
-    /**
-     * Get the size of the map represented by this LazyMap.
-     * 
-     * @return The size of the map
-     */
-    public int getMapSize() {
-        if (!parsed) {
-            parse();
-        }
-        return mapSize;
-    }
+	/**
+	 * Get the size of the map represented by this LazyMap.
+	 * 
+	 * @return The size of the map
+	 */
+	public int getMapSize() {
+		if (!parsed) {
+			parse();
+		}
+		return mapSize;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyNonPrimitive.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyNonPrimitive.java
index f7ae1e3..b151f2d 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyNonPrimitive.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyNonPrimitive.java
@@ -24,54 +24,55 @@
 /**
  * LazyPrimitive stores a primitive Object in a LazyObject.
  */
-public abstract class LazyNonPrimitive<OI extends ObjectInspector> extends LazyObject<OI> {
+public abstract class LazyNonPrimitive<OI extends ObjectInspector> extends
+		LazyObject<OI> {
 
-    protected byte[] bytes;
-    protected int start;
-    protected int length;
+	protected byte[] bytes;
+	protected int start;
+	protected int length;
 
-    /**
-     * Create a LazyNonPrimitive object with the specified ObjectInspector.
-     * 
-     * @param oi
-     *            The ObjectInspector would have to have a hierarchy of
-     *            LazyObjectInspectors with the leaf nodes being
-     *            WritableObjectInspectors. It's used both for accessing the
-     *            type hierarchy of the complex object, as well as getting meta
-     *            information (separator, nullSequence, etc) when parsing the
-     *            lazy object.
-     */
-    protected LazyNonPrimitive(OI oi) {
-        super(oi);
-        bytes = null;
-        start = 0;
-        length = 0;
-    }
+	/**
+	 * Create a LazyNonPrimitive object with the specified ObjectInspector.
+	 * 
+	 * @param oi
+	 *            The ObjectInspector would have to have a hierarchy of
+	 *            LazyObjectInspectors with the leaf nodes being
+	 *            WritableObjectInspectors. It's used both for accessing the
+	 *            type hierarchy of the complex object, as well as getting meta
+	 *            information (separator, nullSequence, etc) when parsing the
+	 *            lazy object.
+	 */
+	protected LazyNonPrimitive(OI oi) {
+		super(oi);
+		bytes = null;
+		start = 0;
+		length = 0;
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (bytes == null) {
-            throw new RuntimeException("bytes cannot be null!");
-        }
-        this.bytes = bytes;
-        this.start = start;
-        this.length = length;
-        assert start >= 0;
-        assert start + length <= bytes.length;
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (bytes == null) {
+			throw new RuntimeException("bytes cannot be null!");
+		}
+		this.bytes = bytes;
+		this.start = start;
+		this.length = length;
+		assert start >= 0;
+		assert start + length <= bytes.length;
+	}
 
-    @Override
-    public Object getObject() {
-        return this;
-    }
+	@Override
+	public Object getObject() {
+		return this;
+	}
 
-    @Override
-    public int hashCode() {
-        return LazyUtils.hashBytes(bytes, start, length);
-    }
+	@Override
+	public int hashCode() {
+		return LazyUtils.hashBytes(bytes, start, length);
+	}
 
-    @Override
-    public void init(IFrameTupleReference tuple) {
-    }
+	@Override
+	public void init(IFrameTupleReference tuple) {
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyObject.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyObject.java
index d71817b..9aaaa88 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyObject.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyObject.java
@@ -29,50 +29,50 @@
  */
 public abstract class LazyObject<OI extends ObjectInspector> {
 
-    OI oi;
+	OI oi;
 
-    /**
-     * Create a LazyObject.
-     * 
-     * @param oi
-     *            Derived classes can access meta information about this Lazy
-     *            Object (e.g, separator, nullSequence, escaper) from it.
-     */
-    protected LazyObject(OI oi) {
-        this.oi = oi;
-    }
+	/**
+	 * Create a LazyObject.
+	 * 
+	 * @param oi
+	 *            Derived classes can access meta information about this Lazy
+	 *            Object (e.g, separator, nullSequence, escaper) from it.
+	 */
+	protected LazyObject(OI oi) {
+		this.oi = oi;
+	}
 
-    /**
-     * Set the data for this LazyObject. We take ByteArrayRef instead of byte[]
-     * so that we will be able to drop the reference to byte[] by a single
-     * assignment. The ByteArrayRef object can be reused across multiple rows.
-     * 
-     * @param bytes
-     *            The wrapper of the byte[].
-     * @param start
-     *            The start position inside the bytes.
-     * @param length
-     *            The length of the data, starting from "start"
-     * @see ByteArrayRef
-     */
-    public abstract void init(byte[] bytes, int start, int length);
+	/**
+	 * Set the data for this LazyObject. We take ByteArrayRef instead of byte[]
+	 * so that we will be able to drop the reference to byte[] by a single
+	 * assignment. The ByteArrayRef object can be reused across multiple rows.
+	 * 
+	 * @param bytes
+	 *            The wrapper of the byte[].
+	 * @param start
+	 *            The start position inside the bytes.
+	 * @param length
+	 *            The length of the data, starting from "start"
+	 * @see ByteArrayRef
+	 */
+	public abstract void init(byte[] bytes, int start, int length);
 
-    public abstract void init(IFrameTupleReference tuple);
+	public abstract void init(IFrameTupleReference tuple);
 
-    /**
-     * If the LazyObject is a primitive Object, then deserialize it and return
-     * the actual primitive Object. Otherwise (array, map, struct), return this.
-     */
-    public abstract Object getObject();
+	/**
+	 * If the LazyObject is a primitive Object, then deserialize it and return
+	 * the actual primitive Object. Otherwise (array, map, struct), return this.
+	 */
+	public abstract Object getObject();
 
-    @Override
-    public abstract int hashCode();
+	@Override
+	public abstract int hashCode();
 
-    protected OI getInspector() {
-        return oi;
-    }
+	protected OI getInspector() {
+		return oi;
+	}
 
-    protected void setInspector(OI oi) {
-        this.oi = oi;
-    }
+	protected void setInspector(OI oi) {
+		this.oi = oi;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyPrimitive.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyPrimitive.java
index 8139c65..888e5b2 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyPrimitive.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyPrimitive.java
@@ -25,45 +25,46 @@
 /**
  * LazyPrimitive stores a primitive Object in a LazyObject.
  */
-public abstract class LazyPrimitive<OI extends ObjectInspector, T extends Writable> extends LazyObject<OI> {
+public abstract class LazyPrimitive<OI extends ObjectInspector, T extends Writable>
+		extends LazyObject<OI> {
 
-    LazyPrimitive(OI oi) {
-        super(oi);
-    }
+	LazyPrimitive(OI oi) {
+		super(oi);
+	}
 
-    LazyPrimitive(LazyPrimitive<OI, T> copy) {
-        super(copy.oi);
-        isNull = copy.isNull;
-    }
+	LazyPrimitive(LazyPrimitive<OI, T> copy) {
+		super(copy.oi);
+		isNull = copy.isNull;
+	}
 
-    T data;
-    boolean isNull = false;
+	T data;
+	boolean isNull = false;
 
-    /**
-     * Returns the primitive object represented by this LazyObject. This is
-     * useful because it can make sure we have "null" for null objects.
-     */
-    @Override
-    public Object getObject() {
-        return isNull ? null : this;
-    }
+	/**
+	 * Returns the primitive object represented by this LazyObject. This is
+	 * useful because it can make sure we have "null" for null objects.
+	 */
+	@Override
+	public Object getObject() {
+		return isNull ? null : this;
+	}
 
-    public T getWritableObject() {
-        return isNull ? null : data;
-    }
+	public T getWritableObject() {
+		return isNull ? null : data;
+	}
 
-    @Override
-    public String toString() {
-        return isNull ? "null" : data.toString();
-    }
+	@Override
+	public String toString() {
+		return isNull ? "null" : data.toString();
+	}
 
-    @Override
-    public int hashCode() {
-        return isNull ? 0 : data.hashCode();
-    }
+	@Override
+	public int hashCode() {
+		return isNull ? 0 : data.hashCode();
+	}
 
-    @Override
-    public void init(IFrameTupleReference tuple) {
-    }
+	@Override
+	public void init(IFrameTupleReference tuple) {
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazySerDe.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazySerDe.java
index a5d4b3b..e239c2d 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazySerDe.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazySerDe.java
@@ -62,398 +62,415 @@
  */
 public class LazySerDe implements SerDe {
 
-    public static final Log LOG = LogFactory.getLog(LazySerDe.class.getName());
+	public static final Log LOG = LogFactory.getLog(LazySerDe.class.getName());
 
-    public LazySerDe() {
-    }
+	public LazySerDe() {
+	}
 
-    List<String> columnNames;
-    List<TypeInfo> columnTypes;
+	List<String> columnNames;
+	List<TypeInfo> columnTypes;
 
-    TypeInfo rowTypeInfo;
-    ObjectInspector cachedObjectInspector;
+	TypeInfo rowTypeInfo;
+	ObjectInspector cachedObjectInspector;
 
-    // The object for storing row data
-    LazyColumnar cachedLazyStruct;
+	// The object for storing row data
+	LazyColumnar cachedLazyStruct;
 
-    /**
-     * Initialize the SerDe with configuration and table information.
-     */
-    @Override
-    public void initialize(Configuration conf, Properties tbl) throws SerDeException {
-        // Get column names and types
-        String columnNameProperty = tbl.getProperty(Constants.LIST_COLUMNS);
-        String columnTypeProperty = tbl.getProperty(Constants.LIST_COLUMN_TYPES);
-        if (columnNameProperty.length() == 0) {
-            columnNames = new ArrayList<String>();
-        } else {
-            columnNames = Arrays.asList(columnNameProperty.split(","));
-        }
-        if (columnTypeProperty.length() == 0) {
-            columnTypes = new ArrayList<TypeInfo>();
-        } else {
-            columnTypes = TypeInfoUtils.getTypeInfosFromTypeString(columnTypeProperty);
-        }
-        assert (columnNames.size() == columnTypes.size());
-        // Create row related objects
-        rowTypeInfo = TypeInfoFactory.getStructTypeInfo(columnNames, columnTypes);
-        // Create the object inspector and the lazy binary struct object
-        cachedObjectInspector = LazyUtils.getLazyObjectInspectorFromTypeInfo(rowTypeInfo, true);
-        cachedLazyStruct = (LazyColumnar) LazyFactory.createLazyObject(cachedObjectInspector);
-        // output debug info
-        LOG.debug("LazySerDe initialized with: columnNames=" + columnNames + " columnTypes=" + columnTypes);
-    }
+	/**
+	 * Initialize the SerDe with configuration and table information.
+	 */
+	@Override
+	public void initialize(Configuration conf, Properties tbl)
+			throws SerDeException {
+		// Get column names and types
+		String columnNameProperty = tbl.getProperty(Constants.LIST_COLUMNS);
+		String columnTypeProperty = tbl
+				.getProperty(Constants.LIST_COLUMN_TYPES);
+		if (columnNameProperty.length() == 0) {
+			columnNames = new ArrayList<String>();
+		} else {
+			columnNames = Arrays.asList(columnNameProperty.split(","));
+		}
+		if (columnTypeProperty.length() == 0) {
+			columnTypes = new ArrayList<TypeInfo>();
+		} else {
+			columnTypes = TypeInfoUtils
+					.getTypeInfosFromTypeString(columnTypeProperty);
+		}
+		assert (columnNames.size() == columnTypes.size());
+		// Create row related objects
+		rowTypeInfo = TypeInfoFactory.getStructTypeInfo(columnNames,
+				columnTypes);
+		// Create the object inspector and the lazy binary struct object
+		cachedObjectInspector = LazyUtils.getLazyObjectInspectorFromTypeInfo(
+				rowTypeInfo, true);
+		cachedLazyStruct = (LazyColumnar) LazyFactory
+				.createLazyObject(cachedObjectInspector);
+		// output debug info
+		LOG.debug("LazySerDe initialized with: columnNames=" + columnNames
+				+ " columnTypes=" + columnTypes);
+	}
 
-    /**
-     * Returns the ObjectInspector for the row.
-     */
-    @Override
-    public ObjectInspector getObjectInspector() throws SerDeException {
-        return cachedObjectInspector;
-    }
+	/**
+	 * Returns the ObjectInspector for the row.
+	 */
+	@Override
+	public ObjectInspector getObjectInspector() throws SerDeException {
+		return cachedObjectInspector;
+	}
 
-    /**
-     * Returns the Writable Class after serialization.
-     */
-    @Override
-    public Class<? extends Writable> getSerializedClass() {
-        return BytesWritable.class;
-    }
+	/**
+	 * Returns the Writable Class after serialization.
+	 */
+	@Override
+	public Class<? extends Writable> getSerializedClass() {
+		return BytesWritable.class;
+	}
 
-    // The wrapper for byte array
-    ByteArrayRef byteArrayRef;
+	// The wrapper for byte array
+	ByteArrayRef byteArrayRef;
 
-    /**
-     * Deserialize a table record to a Lazy struct.
-     */
-    @Override
-    public Object deserialize(Writable field) throws SerDeException {
-        if (byteArrayRef == null) {
-            byteArrayRef = new ByteArrayRef();
-        }
-        if (field instanceof BytesWritable) {
-            BytesWritable b = (BytesWritable) field;
-            if (b.getSize() == 0) {
-                return null;
-            }
-            // For backward-compatibility with hadoop 0.17
-            byteArrayRef.setData(b.get());
-            cachedLazyStruct.init(byteArrayRef.getData(), 0, b.getSize());
-        } else if (field instanceof Text) {
-            Text t = (Text) field;
-            if (t.getLength() == 0) {
-                return null;
-            }
-            byteArrayRef.setData(t.getBytes());
-            cachedLazyStruct.init(byteArrayRef.getData(), 0, t.getLength());
-        } else {
-            throw new SerDeException(getClass().toString() + ": expects either BytesWritable or Text object!");
-        }
-        return cachedLazyStruct;
-    }
+	/**
+	 * Deserialize a table record to a Lazy struct.
+	 */
+	@Override
+	public Object deserialize(Writable field) throws SerDeException {
+		if (byteArrayRef == null) {
+			byteArrayRef = new ByteArrayRef();
+		}
+		if (field instanceof BytesWritable) {
+			BytesWritable b = (BytesWritable) field;
+			if (b.getSize() == 0) {
+				return null;
+			}
+			// For backward-compatibility with hadoop 0.17
+			byteArrayRef.setData(b.get());
+			cachedLazyStruct.init(byteArrayRef.getData(), 0, b.getSize());
+		} else if (field instanceof Text) {
+			Text t = (Text) field;
+			if (t.getLength() == 0) {
+				return null;
+			}
+			byteArrayRef.setData(t.getBytes());
+			cachedLazyStruct.init(byteArrayRef.getData(), 0, t.getLength());
+		} else {
+			throw new SerDeException(getClass().toString()
+					+ ": expects either BytesWritable or Text object!");
+		}
+		return cachedLazyStruct;
+	}
 
-    /**
-     * The reusable output buffer and serialize byte buffer.
-     */
-    BytesWritable serializeBytesWritable = new BytesWritable();
-    ByteStream.Output serializeByteStream = new ByteStream.Output();
+	/**
+	 * The reusable output buffer and serialize byte buffer.
+	 */
+	BytesWritable serializeBytesWritable = new BytesWritable();
+	ByteStream.Output serializeByteStream = new ByteStream.Output();
 
-    /**
-     * Serialize an object to a byte buffer in a binary compact way.
-     */
-    @Override
-    public Writable serialize(Object obj, ObjectInspector objInspector) throws SerDeException {
-        // make sure it is a struct record or not
-        serializeByteStream.reset();
+	/**
+	 * Serialize an object to a byte buffer in a binary compact way.
+	 */
+	@Override
+	public Writable serialize(Object obj, ObjectInspector objInspector)
+			throws SerDeException {
+		// make sure it is a struct record or not
+		serializeByteStream.reset();
 
-        if (objInspector.getCategory() != Category.STRUCT) {
-            // serialize the primitive object
-            serialize(serializeByteStream, obj, objInspector);
-        } else {
-            // serialize the row as a struct
-            serializeStruct(serializeByteStream, obj, (StructObjectInspector) objInspector);
-        }
-        // return the serialized bytes
-        serializeBytesWritable.set(serializeByteStream.getData(), 0, serializeByteStream.getCount());
-        return serializeBytesWritable;
-    }
+		if (objInspector.getCategory() != Category.STRUCT) {
+			// serialize the primitive object
+			serialize(serializeByteStream, obj, objInspector);
+		} else {
+			// serialize the row as a struct
+			serializeStruct(serializeByteStream, obj,
+					(StructObjectInspector) objInspector);
+		}
+		// return the serialized bytes
+		serializeBytesWritable.set(serializeByteStream.getData(), 0,
+				serializeByteStream.getCount());
+		return serializeBytesWritable;
+	}
 
-    boolean nullMapKey = false;
+	boolean nullMapKey = false;
 
-    /**
-     * Serialize a struct object without writing the byte size. This function is
-     * shared by both row serialization and struct serialization.
-     * 
-     * @param byteStream
-     *            the byte stream storing the serialization data
-     * @param obj
-     *            the struct object to serialize
-     * @param objInspector
-     *            the struct object inspector
-     */
-    private void serializeStruct(Output byteStream, Object obj, StructObjectInspector soi) {
-        // do nothing for null struct
-        if (null == obj) {
-            return;
-        }
-        /*
-         * Interleave serializing one null byte and 8 struct fields in each
-         * round, in order to support data deserialization with different table
-         * schemas
-         */
-        List<? extends StructField> fields = soi.getAllStructFieldRefs();
-        int size = fields.size();
-        int lasti = 0;
-        byte nullByte = 0;
-        for (int i = 0; i < size; i++) {
-            // set bit to 1 if a field is not null
-            if (null != soi.getStructFieldData(obj, fields.get(i))) {
-                nullByte |= 1 << (i % 8);
-            }
-            // write the null byte every eight elements or
-            // if this is the last element and serialize the
-            // corresponding 8 struct fields at the same time
-            if (7 == i % 8 || i == size - 1) {
-                serializeByteStream.write(nullByte);
-                for (int j = lasti; j <= i; j++) {
-                    serialize(serializeByteStream, soi.getStructFieldData(obj, fields.get(j)), fields.get(j)
-                            .getFieldObjectInspector());
-                }
-                lasti = i + 1;
-                nullByte = 0;
-            }
-        }
-    }
+	/**
+	 * Serialize a struct object without writing the byte size. This function is
+	 * shared by both row serialization and struct serialization.
+	 * 
+	 * @param byteStream
+	 *            the byte stream storing the serialization data
+	 * @param obj
+	 *            the struct object to serialize
+	 * @param objInspector
+	 *            the struct object inspector
+	 */
+	private void serializeStruct(Output byteStream, Object obj,
+			StructObjectInspector soi) {
+		// do nothing for null struct
+		if (null == obj) {
+			return;
+		}
+		/*
+		 * Interleave serializing one null byte and 8 struct fields in each
+		 * round, in order to support data deserialization with different table
+		 * schemas
+		 */
+		List<? extends StructField> fields = soi.getAllStructFieldRefs();
+		int size = fields.size();
+		int lasti = 0;
+		byte nullByte = 0;
+		for (int i = 0; i < size; i++) {
+			// set bit to 1 if a field is not null
+			if (null != soi.getStructFieldData(obj, fields.get(i))) {
+				nullByte |= 1 << (i % 8);
+			}
+			// write the null byte every eight elements or
+			// if this is the last element and serialize the
+			// corresponding 8 struct fields at the same time
+			if (7 == i % 8 || i == size - 1) {
+				serializeByteStream.write(nullByte);
+				for (int j = lasti; j <= i; j++) {
+					serialize(serializeByteStream, soi.getStructFieldData(obj,
+							fields.get(j)), fields.get(j)
+							.getFieldObjectInspector());
+				}
+				lasti = i + 1;
+				nullByte = 0;
+			}
+		}
+	}
 
-    /**
-     * A recursive function that serialize an object to a byte buffer based on
-     * its object inspector.
-     * 
-     * @param byteStream
-     *            the byte stream storing the serialization data
-     * @param obj
-     *            the object to serialize
-     * @param objInspector
-     *            the object inspector
-     */
-    private void serialize(Output byteStream, Object obj, ObjectInspector objInspector) {
+	/**
+	 * A recursive function that serialize an object to a byte buffer based on
+	 * its object inspector.
+	 * 
+	 * @param byteStream
+	 *            the byte stream storing the serialization data
+	 * @param obj
+	 *            the object to serialize
+	 * @param objInspector
+	 *            the object inspector
+	 */
+	private void serialize(Output byteStream, Object obj,
+			ObjectInspector objInspector) {
 
-        // do nothing for null object
-        if (null == obj) {
-            return;
-        }
+		// do nothing for null object
+		if (null == obj) {
+			return;
+		}
 
-        switch (objInspector.getCategory()) {
-            case PRIMITIVE: {
-                PrimitiveObjectInspector poi = (PrimitiveObjectInspector) objInspector;
-                switch (poi.getPrimitiveCategory()) {
-                    case VOID: {
-                        return;
-                    }
-                    case BOOLEAN: {
-                        boolean v = ((BooleanObjectInspector) poi).get(obj);
-                        byteStream.write((byte) (v ? 1 : 0));
-                        return;
-                    }
-                    case BYTE: {
-                        ByteObjectInspector boi = (ByteObjectInspector) poi;
-                        byte v = boi.get(obj);
-                        byteStream.write(v);
-                        return;
-                    }
-                    case SHORT: {
-                        ShortObjectInspector spoi = (ShortObjectInspector) poi;
-                        short v = spoi.get(obj);
-                        byteStream.write((byte) (v >> 8));
-                        byteStream.write((byte) (v));
-                        return;
-                    }
-                    case INT: {
-                        IntObjectInspector ioi = (IntObjectInspector) poi;
-                        int v = ioi.get(obj);
-                        LazyUtils.writeVInt(byteStream, v);
-                        return;
-                    }
-                    case LONG: {
-                        LongObjectInspector loi = (LongObjectInspector) poi;
-                        long v = loi.get(obj);
-                        LazyUtils.writeVLong(byteStream, v);
-                        return;
-                    }
-                    case FLOAT: {
-                        FloatObjectInspector foi = (FloatObjectInspector) poi;
-                        int v = Float.floatToIntBits(foi.get(obj));
-                        byteStream.write((byte) (v >> 24));
-                        byteStream.write((byte) (v >> 16));
-                        byteStream.write((byte) (v >> 8));
-                        byteStream.write((byte) (v));
-                        return;
-                    }
-                    case DOUBLE: {
-                        DoubleObjectInspector doi = (DoubleObjectInspector) poi;
-                        long v = Double.doubleToLongBits(doi.get(obj));
-                        byteStream.write((byte) (v >> 56));
-                        byteStream.write((byte) (v >> 48));
-                        byteStream.write((byte) (v >> 40));
-                        byteStream.write((byte) (v >> 32));
-                        byteStream.write((byte) (v >> 24));
-                        byteStream.write((byte) (v >> 16));
-                        byteStream.write((byte) (v >> 8));
-                        byteStream.write((byte) (v));
-                        return;
-                    }
-                    case STRING: {
-                        StringObjectInspector soi = (StringObjectInspector) poi;
-                        Text t = soi.getPrimitiveWritableObject(obj);
-                        /* write byte size of the string which is a vint */
-                        int length = t.getLength();
-                        LazyUtils.writeVInt(byteStream, length);
-                        /* write string itself */
-                        byte[] data = t.getBytes();
-                        byteStream.write(data, 0, length);
-                        return;
-                    }
-                    default: {
-                        throw new RuntimeException("Unrecognized type: " + poi.getPrimitiveCategory());
-                    }
-                }
-            }
-            case LIST: {
-                ListObjectInspector loi = (ListObjectInspector) objInspector;
-                ObjectInspector eoi = loi.getListElementObjectInspector();
+		switch (objInspector.getCategory()) {
+		case PRIMITIVE: {
+			PrimitiveObjectInspector poi = (PrimitiveObjectInspector) objInspector;
+			switch (poi.getPrimitiveCategory()) {
+			case VOID: {
+				return;
+			}
+			case BOOLEAN: {
+				boolean v = ((BooleanObjectInspector) poi).get(obj);
+				byteStream.write((byte) (v ? 1 : 0));
+				return;
+			}
+			case BYTE: {
+				ByteObjectInspector boi = (ByteObjectInspector) poi;
+				byte v = boi.get(obj);
+				byteStream.write(v);
+				return;
+			}
+			case SHORT: {
+				ShortObjectInspector spoi = (ShortObjectInspector) poi;
+				short v = spoi.get(obj);
+				byteStream.write((byte) (v >> 8));
+				byteStream.write((byte) (v));
+				return;
+			}
+			case INT: {
+				IntObjectInspector ioi = (IntObjectInspector) poi;
+				int v = ioi.get(obj);
+				LazyUtils.writeVInt(byteStream, v);
+				return;
+			}
+			case LONG: {
+				LongObjectInspector loi = (LongObjectInspector) poi;
+				long v = loi.get(obj);
+				LazyUtils.writeVLong(byteStream, v);
+				return;
+			}
+			case FLOAT: {
+				FloatObjectInspector foi = (FloatObjectInspector) poi;
+				int v = Float.floatToIntBits(foi.get(obj));
+				byteStream.write((byte) (v >> 24));
+				byteStream.write((byte) (v >> 16));
+				byteStream.write((byte) (v >> 8));
+				byteStream.write((byte) (v));
+				return;
+			}
+			case DOUBLE: {
+				DoubleObjectInspector doi = (DoubleObjectInspector) poi;
+				long v = Double.doubleToLongBits(doi.get(obj));
+				byteStream.write((byte) (v >> 56));
+				byteStream.write((byte) (v >> 48));
+				byteStream.write((byte) (v >> 40));
+				byteStream.write((byte) (v >> 32));
+				byteStream.write((byte) (v >> 24));
+				byteStream.write((byte) (v >> 16));
+				byteStream.write((byte) (v >> 8));
+				byteStream.write((byte) (v));
+				return;
+			}
+			case STRING: {
+				StringObjectInspector soi = (StringObjectInspector) poi;
+				Text t = soi.getPrimitiveWritableObject(obj);
+				/* write byte size of the string which is a vint */
+				int length = t.getLength();
+				LazyUtils.writeVInt(byteStream, length);
+				/* write string itself */
+				byte[] data = t.getBytes();
+				byteStream.write(data, 0, length);
+				return;
+			}
+			default: {
+				throw new RuntimeException("Unrecognized type: "
+						+ poi.getPrimitiveCategory());
+			}
+			}
+		}
+		case LIST: {
+			ListObjectInspector loi = (ListObjectInspector) objInspector;
+			ObjectInspector eoi = loi.getListElementObjectInspector();
 
-                // 1/ reserve spaces for the byte size of the list
-                // which is a integer and takes four bytes
-                int byteSizeStart = byteStream.getCount();
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                int listStart = byteStream.getCount();
+			// 1/ reserve spaces for the byte size of the list
+			// which is a integer and takes four bytes
+			int byteSizeStart = byteStream.getCount();
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			int listStart = byteStream.getCount();
 
-                // 2/ write the size of the list as a VInt
-                int size = loi.getListLength(obj);
-                LazyUtils.writeVInt(byteStream, size);
+			// 2/ write the size of the list as a VInt
+			int size = loi.getListLength(obj);
+			LazyUtils.writeVInt(byteStream, size);
 
-                // 3/ write the null bytes
-                byte nullByte = 0;
-                for (int eid = 0; eid < size; eid++) {
-                    // set the bit to 1 if an element is not null
-                    if (null != loi.getListElement(obj, eid)) {
-                        nullByte |= 1 << (eid % 8);
-                    }
-                    // store the byte every eight elements or
-                    // if this is the last element
-                    if (7 == eid % 8 || eid == size - 1) {
-                        byteStream.write(nullByte);
-                        nullByte = 0;
-                    }
-                }
+			// 3/ write the null bytes
+			byte nullByte = 0;
+			for (int eid = 0; eid < size; eid++) {
+				// set the bit to 1 if an element is not null
+				if (null != loi.getListElement(obj, eid)) {
+					nullByte |= 1 << (eid % 8);
+				}
+				// store the byte every eight elements or
+				// if this is the last element
+				if (7 == eid % 8 || eid == size - 1) {
+					byteStream.write(nullByte);
+					nullByte = 0;
+				}
+			}
 
-                // 4/ write element by element from the list
-                for (int eid = 0; eid < size; eid++) {
-                    serialize(byteStream, loi.getListElement(obj, eid), eoi);
-                }
+			// 4/ write element by element from the list
+			for (int eid = 0; eid < size; eid++) {
+				serialize(byteStream, loi.getListElement(obj, eid), eoi);
+			}
 
-                // 5/ update the list byte size
-                int listEnd = byteStream.getCount();
-                int listSize = listEnd - listStart;
-                byte[] bytes = byteStream.getData();
-                bytes[byteSizeStart] = (byte) (listSize >> 24);
-                bytes[byteSizeStart + 1] = (byte) (listSize >> 16);
-                bytes[byteSizeStart + 2] = (byte) (listSize >> 8);
-                bytes[byteSizeStart + 3] = (byte) (listSize);
+			// 5/ update the list byte size
+			int listEnd = byteStream.getCount();
+			int listSize = listEnd - listStart;
+			byte[] bytes = byteStream.getData();
+			bytes[byteSizeStart] = (byte) (listSize >> 24);
+			bytes[byteSizeStart + 1] = (byte) (listSize >> 16);
+			bytes[byteSizeStart + 2] = (byte) (listSize >> 8);
+			bytes[byteSizeStart + 3] = (byte) (listSize);
 
-                return;
-            }
-            case MAP: {
-                MapObjectInspector moi = (MapObjectInspector) objInspector;
-                ObjectInspector koi = moi.getMapKeyObjectInspector();
-                ObjectInspector voi = moi.getMapValueObjectInspector();
-                Map<?, ?> map = moi.getMap(obj);
+			return;
+		}
+		case MAP: {
+			MapObjectInspector moi = (MapObjectInspector) objInspector;
+			ObjectInspector koi = moi.getMapKeyObjectInspector();
+			ObjectInspector voi = moi.getMapValueObjectInspector();
+			Map<?, ?> map = moi.getMap(obj);
 
-                // 1/ reserve spaces for the byte size of the map
-                // which is a integer and takes four bytes
-                int byteSizeStart = byteStream.getCount();
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                int mapStart = byteStream.getCount();
+			// 1/ reserve spaces for the byte size of the map
+			// which is a integer and takes four bytes
+			int byteSizeStart = byteStream.getCount();
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			int mapStart = byteStream.getCount();
 
-                // 2/ write the size of the map which is a VInt
-                int size = map.size();
-                LazyUtils.writeVInt(byteStream, size);
+			// 2/ write the size of the map which is a VInt
+			int size = map.size();
+			LazyUtils.writeVInt(byteStream, size);
 
-                // 3/ write the null bytes
-                int b = 0;
-                byte nullByte = 0;
-                for (Map.Entry<?, ?> entry : map.entrySet()) {
-                    // set the bit to 1 if a key is not null
-                    if (null != entry.getKey()) {
-                        nullByte |= 1 << (b % 8);
-                    } else if (!nullMapKey) {
-                        nullMapKey = true;
-                        LOG.warn("Null map key encountered! Ignoring similar problems.");
-                    }
-                    b++;
-                    // set the bit to 1 if a value is not null
-                    if (null != entry.getValue()) {
-                        nullByte |= 1 << (b % 8);
-                    }
-                    b++;
-                    // write the byte to stream every 4 key-value pairs
-                    // or if this is the last key-value pair
-                    if (0 == b % 8 || b == size * 2) {
-                        byteStream.write(nullByte);
-                        nullByte = 0;
-                    }
-                }
+			// 3/ write the null bytes
+			int b = 0;
+			byte nullByte = 0;
+			for (Map.Entry<?, ?> entry : map.entrySet()) {
+				// set the bit to 1 if a key is not null
+				if (null != entry.getKey()) {
+					nullByte |= 1 << (b % 8);
+				} else if (!nullMapKey) {
+					nullMapKey = true;
+					LOG.warn("Null map key encountered! Ignoring similar problems.");
+				}
+				b++;
+				// set the bit to 1 if a value is not null
+				if (null != entry.getValue()) {
+					nullByte |= 1 << (b % 8);
+				}
+				b++;
+				// write the byte to stream every 4 key-value pairs
+				// or if this is the last key-value pair
+				if (0 == b % 8 || b == size * 2) {
+					byteStream.write(nullByte);
+					nullByte = 0;
+				}
+			}
 
-                // 4/ write key-value pairs one by one
-                for (Map.Entry<?, ?> entry : map.entrySet()) {
-                    serialize(byteStream, entry.getKey(), koi);
-                    serialize(byteStream, entry.getValue(), voi);
-                }
+			// 4/ write key-value pairs one by one
+			for (Map.Entry<?, ?> entry : map.entrySet()) {
+				serialize(byteStream, entry.getKey(), koi);
+				serialize(byteStream, entry.getValue(), voi);
+			}
 
-                // 5/ update the byte size of the map
-                int mapEnd = byteStream.getCount();
-                int mapSize = mapEnd - mapStart;
-                byte[] bytes = byteStream.getData();
-                bytes[byteSizeStart] = (byte) (mapSize >> 24);
-                bytes[byteSizeStart + 1] = (byte) (mapSize >> 16);
-                bytes[byteSizeStart + 2] = (byte) (mapSize >> 8);
-                bytes[byteSizeStart + 3] = (byte) (mapSize);
+			// 5/ update the byte size of the map
+			int mapEnd = byteStream.getCount();
+			int mapSize = mapEnd - mapStart;
+			byte[] bytes = byteStream.getData();
+			bytes[byteSizeStart] = (byte) (mapSize >> 24);
+			bytes[byteSizeStart + 1] = (byte) (mapSize >> 16);
+			bytes[byteSizeStart + 2] = (byte) (mapSize >> 8);
+			bytes[byteSizeStart + 3] = (byte) (mapSize);
 
-                return;
-            }
-            case STRUCT: {
-                // 1/ reserve spaces for the byte size of the struct
-                // which is a integer and takes four bytes
-                int byteSizeStart = byteStream.getCount();
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                byteStream.write((byte) 0);
-                int structStart = byteStream.getCount();
+			return;
+		}
+		case STRUCT: {
+			// 1/ reserve spaces for the byte size of the struct
+			// which is a integer and takes four bytes
+			int byteSizeStart = byteStream.getCount();
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			byteStream.write((byte) 0);
+			int structStart = byteStream.getCount();
 
-                // 2/ serialize the struct
-                serializeStruct(byteStream, obj, (StructObjectInspector) objInspector);
+			// 2/ serialize the struct
+			serializeStruct(byteStream, obj,
+					(StructObjectInspector) objInspector);
 
-                // 3/ update the byte size of the struct
-                int structEnd = byteStream.getCount();
-                int structSize = structEnd - structStart;
-                byte[] bytes = byteStream.getData();
-                bytes[byteSizeStart] = (byte) (structSize >> 24);
-                bytes[byteSizeStart + 1] = (byte) (structSize >> 16);
-                bytes[byteSizeStart + 2] = (byte) (structSize >> 8);
-                bytes[byteSizeStart + 3] = (byte) (structSize);
+			// 3/ update the byte size of the struct
+			int structEnd = byteStream.getCount();
+			int structSize = structEnd - structStart;
+			byte[] bytes = byteStream.getData();
+			bytes[byteSizeStart] = (byte) (structSize >> 24);
+			bytes[byteSizeStart + 1] = (byte) (structSize >> 16);
+			bytes[byteSizeStart + 2] = (byte) (structSize >> 8);
+			bytes[byteSizeStart + 3] = (byte) (structSize);
 
-                return;
-            }
-            default: {
-                throw new RuntimeException("Unrecognized type: " + objInspector.getCategory());
-            }
-        }
-    }
+			return;
+		}
+		default: {
+			throw new RuntimeException("Unrecognized type: "
+					+ objInspector.getCategory());
+		}
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyShort.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyShort.java
index 4588c58..7484b72 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyShort.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyShort.java
@@ -34,28 +34,29 @@
  * </p>
  * 
  */
-public class LazyShort extends LazyPrimitive<LazyShortObjectInspector, ShortWritable> {
+public class LazyShort extends
+		LazyPrimitive<LazyShortObjectInspector, ShortWritable> {
 
-    public LazyShort(LazyShortObjectInspector oi) {
-        super(oi);
-        data = new ShortWritable();
-    }
+	public LazyShort(LazyShortObjectInspector oi) {
+		super(oi);
+		data = new ShortWritable();
+	}
 
-    public LazyShort(LazyShort copy) {
-        super(copy);
-        data = new ShortWritable(copy.data.get());
-    }
+	public LazyShort(LazyShort copy) {
+		super(copy);
+		data = new ShortWritable(copy.data.get());
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
-        
-        assert (2 == length);
-        data.set(LazyUtils.byteArrayToShort(bytes, start));
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
+
+		assert (2 == length);
+		data.set(LazyUtils.byteArrayToShort(bytes, start));
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyString.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyString.java
index a11b1e1..c13533b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyString.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyString.java
@@ -27,33 +27,34 @@
  */
 public class LazyString extends LazyPrimitive<LazyStringObjectInspector, Text> {
 
-    public LazyString(LazyStringObjectInspector oi) {
-        super(oi);
-        data = new Text();
-    }
+	public LazyString(LazyStringObjectInspector oi) {
+		super(oi);
+		data = new Text();
+	}
 
-    public LazyString(LazyString copy) {
-        super(copy);
-        data = new Text(copy.data);
-    }
+	public LazyString(LazyString copy) {
+		super(copy);
+		data = new Text(copy.data);
+	}
 
-    VInt vInt = new LazyUtils.VInt();
+	VInt vInt = new LazyUtils.VInt();
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        if (length == 0) {
-            isNull = true;
-            return;
-        } else
-            isNull = false;
-        
-        // get the byte length of the string
-        LazyUtils.readVInt(bytes, start, vInt);
-        if (vInt.value + vInt.length != length)
-            throw new IllegalStateException("parse string: length mismatch, expected " + (vInt.value + vInt.length)
-                    + " but get " + length);
-        assert (length - vInt.length > -1);
-        data.set(bytes, start + vInt.length, length - vInt.length);
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		if (length == 0) {
+			isNull = true;
+			return;
+		} else
+			isNull = false;
+
+		// get the byte length of the string
+		LazyUtils.readVInt(bytes, start, vInt);
+		if (vInt.value + vInt.length != length)
+			throw new IllegalStateException(
+					"parse string: length mismatch, expected "
+							+ (vInt.value + vInt.length) + " but get " + length);
+		assert (length - vInt.length > -1);
+		data.set(bytes, start + vInt.length, length - vInt.length);
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyStruct.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyStruct.java
index 3ab59b3..a6cf404 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyStruct.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyStruct.java
@@ -43,194 +43,201 @@
  */
 public class LazyStruct extends LazyNonPrimitive<LazyStructObjectInspector> {
 
-    private static Log LOG = LogFactory.getLog(LazyStruct.class.getName());
+	private static Log LOG = LogFactory.getLog(LazyStruct.class.getName());
 
-    /**
-     * Whether the data is already parsed or not.
-     */
-    boolean parsed;
+	/**
+	 * Whether the data is already parsed or not.
+	 */
+	boolean parsed;
 
-    /**
-     * The fields of the struct.
-     */
-    LazyObject[] fields;
+	/**
+	 * The fields of the struct.
+	 */
+	LazyObject[] fields;
 
-    /**
-     * Whether a field is initialized or not.
-     */
-    boolean[] fieldInited;
+	/**
+	 * Whether a field is initialized or not.
+	 */
+	boolean[] fieldInited;
 
-    /**
-     * Whether a field is null or not. Because length is 0 does not means the
-     * field is null. In particular, a 0-length string is not null.
-     */
-    boolean[] fieldIsNull;
+	/**
+	 * Whether a field is null or not. Because length is 0 does not means the
+	 * field is null. In particular, a 0-length string is not null.
+	 */
+	boolean[] fieldIsNull;
 
-    /**
-     * The start positions and lengths of struct fields. Only valid when the
-     * data is parsed.
-     */
-    int[] fieldStart;
-    int[] fieldLength;
+	/**
+	 * The start positions and lengths of struct fields. Only valid when the
+	 * data is parsed.
+	 */
+	int[] fieldStart;
+	int[] fieldLength;
 
-    /**
-     * Construct a LazyStruct object with an ObjectInspector.
-     */
-    protected LazyStruct(LazyStructObjectInspector oi) {
-        super(oi);
-    }
+	/**
+	 * Construct a LazyStruct object with an ObjectInspector.
+	 */
+	protected LazyStruct(LazyStructObjectInspector oi) {
+		super(oi);
+	}
 
-    @Override
-    public void init(byte[] bytes, int start, int length) {
-        super.init(bytes, start, length);
-        parsed = false;
-    }
+	@Override
+	public void init(byte[] bytes, int start, int length) {
+		super.init(bytes, start, length);
+		parsed = false;
+	}
 
-    RecordInfo recordInfo = new LazyUtils.RecordInfo();
-    boolean missingFieldWarned = false;
-    boolean extraFieldWarned = false;
+	RecordInfo recordInfo = new LazyUtils.RecordInfo();
+	boolean missingFieldWarned = false;
+	boolean extraFieldWarned = false;
 
-    /**
-     * Parse the byte[] and fill fieldStart, fieldLength, fieldInited and
-     * fieldIsNull.
-     */
-    private void parse() {
+	/**
+	 * Parse the byte[] and fill fieldStart, fieldLength, fieldInited and
+	 * fieldIsNull.
+	 */
+	private void parse() {
 
-        List<? extends StructField> fieldRefs = ((StructObjectInspector) oi).getAllStructFieldRefs();
+		List<? extends StructField> fieldRefs = ((StructObjectInspector) oi)
+				.getAllStructFieldRefs();
 
-        if (fields == null) {
-            fields = new LazyObject[fieldRefs.size()];
-            for (int i = 0; i < fields.length; i++) {
-                ObjectInspector insp = fieldRefs.get(i).getFieldObjectInspector();
-                fields[i] = insp == null ? null : LazyFactory.createLazyObject(insp);
-            }
-            fieldInited = new boolean[fields.length];
-            fieldIsNull = new boolean[fields.length];
-            fieldStart = new int[fields.length];
-            fieldLength = new int[fields.length];
-        }
+		if (fields == null) {
+			fields = new LazyObject[fieldRefs.size()];
+			for (int i = 0; i < fields.length; i++) {
+				ObjectInspector insp = fieldRefs.get(i)
+						.getFieldObjectInspector();
+				fields[i] = insp == null ? null : LazyFactory
+						.createLazyObject(insp);
+			}
+			fieldInited = new boolean[fields.length];
+			fieldIsNull = new boolean[fields.length];
+			fieldStart = new int[fields.length];
+			fieldLength = new int[fields.length];
+		}
 
-        /**
-         * Please note that one null byte is followed by eight fields, then more
-         * null byte and fields.
-         */
+		/**
+		 * Please note that one null byte is followed by eight fields, then more
+		 * null byte and fields.
+		 */
 
-        int fieldId = 0;
-        int structByteEnd = start + length;
+		int fieldId = 0;
+		int structByteEnd = start + length;
 
-        byte nullByte = bytes[start];
-        int lastFieldByteEnd = start + 1;
-        // Go through all bytes in the byte[]
-        for (int i = 0; i < fields.length; i++) {
-            fieldIsNull[i] = true;
-            if ((nullByte & (1 << (i % 8))) != 0) {
-                fieldIsNull[i] = false;
-                LazyUtils.checkObjectByteInfo(fieldRefs.get(i).getFieldObjectInspector(), bytes, lastFieldByteEnd,
-                        recordInfo);
-                fieldStart[i] = lastFieldByteEnd + recordInfo.elementOffset;
-                fieldLength[i] = recordInfo.elementSize;
-                lastFieldByteEnd = fieldStart[i] + fieldLength[i];
-            }
+		byte nullByte = bytes[start];
+		int lastFieldByteEnd = start + 1;
+		// Go through all bytes in the byte[]
+		for (int i = 0; i < fields.length; i++) {
+			fieldIsNull[i] = true;
+			if ((nullByte & (1 << (i % 8))) != 0) {
+				fieldIsNull[i] = false;
+				LazyUtils.checkObjectByteInfo(fieldRefs.get(i)
+						.getFieldObjectInspector(), bytes, lastFieldByteEnd,
+						recordInfo);
+				fieldStart[i] = lastFieldByteEnd + recordInfo.elementOffset;
+				fieldLength[i] = recordInfo.elementSize;
+				lastFieldByteEnd = fieldStart[i] + fieldLength[i];
+			}
 
-            // count how many fields are there
-            if (lastFieldByteEnd <= structByteEnd) {
-                fieldId++;
-            }
-            // next byte is a null byte if there are more bytes to go
-            if (7 == (i % 8)) {
-                if (lastFieldByteEnd < structByteEnd) {
-                    nullByte = bytes[lastFieldByteEnd];
-                    lastFieldByteEnd++;
-                } else {
-                    // otherwise all null afterwards
-                    nullByte = 0;
-                    lastFieldByteEnd++;
-                }
-            }
-        }
+			// count how many fields are there
+			if (lastFieldByteEnd <= structByteEnd) {
+				fieldId++;
+			}
+			// next byte is a null byte if there are more bytes to go
+			if (7 == (i % 8)) {
+				if (lastFieldByteEnd < structByteEnd) {
+					nullByte = bytes[lastFieldByteEnd];
+					lastFieldByteEnd++;
+				} else {
+					// otherwise all null afterwards
+					nullByte = 0;
+					lastFieldByteEnd++;
+				}
+			}
+		}
 
-        // Extra bytes at the end?
-        if (!extraFieldWarned && lastFieldByteEnd < structByteEnd) {
-            extraFieldWarned = true;
-            LOG.warn("Extra bytes detected at the end of the row! Ignoring similar " + "problems.");
-        }
+		// Extra bytes at the end?
+		if (!extraFieldWarned && lastFieldByteEnd < structByteEnd) {
+			extraFieldWarned = true;
+			LOG.warn("Extra bytes detected at the end of the row! Ignoring similar "
+					+ "problems.");
+		}
 
-        // Missing fields?
-        if (!missingFieldWarned && lastFieldByteEnd > structByteEnd) {
-            missingFieldWarned = true;
-            LOG.warn("Missing fields! Expected " + fields.length + " fields but " + "only got " + fieldId
-                    + "! Ignoring similar problems.");
-        }
+		// Missing fields?
+		if (!missingFieldWarned && lastFieldByteEnd > structByteEnd) {
+			missingFieldWarned = true;
+			LOG.warn("Missing fields! Expected " + fields.length
+					+ " fields but " + "only got " + fieldId
+					+ "! Ignoring similar problems.");
+		}
 
-        Arrays.fill(fieldInited, false);
-        parsed = true;
-    }
+		Arrays.fill(fieldInited, false);
+		parsed = true;
+	}
 
-    /**
-     * Get one field out of the struct.
-     * 
-     * If the field is a primitive field, return the actual object. Otherwise
-     * return the LazyObject. This is because PrimitiveObjectInspector does not
-     * have control over the object used by the user - the user simply directly
-     * use the Object instead of going through Object
-     * PrimitiveObjectInspector.get(Object).
-     * 
-     * @param fieldID
-     *            The field ID
-     * @return The field as a LazyObject
-     */
-    public Object getField(int fieldID) {
-        if (!parsed) {
-            parse();
-        }
-        return uncheckedGetField(fieldID);
-    }
+	/**
+	 * Get one field out of the struct.
+	 * 
+	 * If the field is a primitive field, return the actual object. Otherwise
+	 * return the LazyObject. This is because PrimitiveObjectInspector does not
+	 * have control over the object used by the user - the user simply directly
+	 * use the Object instead of going through Object
+	 * PrimitiveObjectInspector.get(Object).
+	 * 
+	 * @param fieldID
+	 *            The field ID
+	 * @return The field as a LazyObject
+	 */
+	public Object getField(int fieldID) {
+		if (!parsed) {
+			parse();
+		}
+		return uncheckedGetField(fieldID);
+	}
 
-    /**
-     * Get the field out of the row without checking parsed. This is called by
-     * both getField and getFieldsAsList.
-     * 
-     * @param fieldID
-     *            The id of the field starting from 0.
-     * @return The value of the field
-     */
-    private Object uncheckedGetField(int fieldID) {
-        // Test the length first so in most cases we avoid doing a byte[]
-        // comparison.
-        if (fieldIsNull[fieldID]) {
-            return null;
-        }
-        if (!fieldInited[fieldID]) {
-            fieldInited[fieldID] = true;
-            fields[fieldID].init(bytes, fieldStart[fieldID], fieldLength[fieldID]);
-        }
-        return fields[fieldID].getObject();
-    }
+	/**
+	 * Get the field out of the row without checking parsed. This is called by
+	 * both getField and getFieldsAsList.
+	 * 
+	 * @param fieldID
+	 *            The id of the field starting from 0.
+	 * @return The value of the field
+	 */
+	private Object uncheckedGetField(int fieldID) {
+		// Test the length first so in most cases we avoid doing a byte[]
+		// comparison.
+		if (fieldIsNull[fieldID]) {
+			return null;
+		}
+		if (!fieldInited[fieldID]) {
+			fieldInited[fieldID] = true;
+			fields[fieldID].init(bytes, fieldStart[fieldID],
+					fieldLength[fieldID]);
+		}
+		return fields[fieldID].getObject();
+	}
 
-    ArrayList<Object> cachedList;
+	ArrayList<Object> cachedList;
 
-    /**
-     * Get the values of the fields as an ArrayList.
-     * 
-     * @return The values of the fields as an ArrayList.
-     */
-    public ArrayList<Object> getFieldsAsList() {
-        if (!parsed) {
-            parse();
-        }
-        if (cachedList == null) {
-            cachedList = new ArrayList<Object>();
-        } else {
-            cachedList.clear();
-        }
-        for (int i = 0; i < fields.length; i++) {
-            cachedList.add(uncheckedGetField(i));
-        }
-        return cachedList;
-    }
+	/**
+	 * Get the values of the fields as an ArrayList.
+	 * 
+	 * @return The values of the fields as an ArrayList.
+	 */
+	public ArrayList<Object> getFieldsAsList() {
+		if (!parsed) {
+			parse();
+		}
+		if (cachedList == null) {
+			cachedList = new ArrayList<Object>();
+		} else {
+			cachedList.clear();
+		}
+		for (int i = 0; i < fields.length; i++) {
+			cachedList.add(uncheckedGetField(i));
+		}
+		return cachedList;
+	}
 
-    @Override
-    public Object getObject() {
-        return this;
-    }
+	@Override
+	public Object getObject() {
+		return this;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyUtils.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyUtils.java
index d7baf18..d8c40f7 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyUtils.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/LazyUtils.java
@@ -48,462 +48,484 @@
  */
 public final class LazyUtils {
 
-    private static Log LOG = LogFactory.getLog(LazyUtils.class.getName());
+	private static Log LOG = LogFactory.getLog(LazyUtils.class.getName());
 
-    /**
-     * Convert the byte array to an int starting from the given offset. Refer to
-     * code by aeden on DZone Snippets:
-     * 
-     * @param b
-     *            the byte array
-     * @param offset
-     *            the array offset
-     * @return the integer
-     */
-    public static int byteArrayToInt(byte[] b, int offset) {
-        int value = 0;
-        for (int i = 0; i < 4; i++) {
-            int shift = (4 - 1 - i) * 8;
-            value += (b[i + offset] & 0x000000FF) << shift;
-        }
-        return value;
-    }
+	/**
+	 * Convert the byte array to an int starting from the given offset. Refer to
+	 * code by aeden on DZone Snippets:
+	 * 
+	 * @param b
+	 *            the byte array
+	 * @param offset
+	 *            the array offset
+	 * @return the integer
+	 */
+	public static int byteArrayToInt(byte[] b, int offset) {
+		int value = 0;
+		for (int i = 0; i < 4; i++) {
+			int shift = (4 - 1 - i) * 8;
+			value += (b[i + offset] & 0x000000FF) << shift;
+		}
+		return value;
+	}
 
-    /**
-     * Convert the byte array to a long starting from the given offset.
-     * 
-     * @param b
-     *            the byte array
-     * @param offset
-     *            the array offset
-     * @return the long
-     */
-    public static long byteArrayToLong(byte[] b, int offset) {
-        long value = 0;
-        for (int i = 0; i < 8; i++) {
-            int shift = (8 - 1 - i) * 8;
-            value += ((long) (b[i + offset] & 0x00000000000000FF)) << shift;
-        }
-        return value;
-    }
+	/**
+	 * Convert the byte array to a long starting from the given offset.
+	 * 
+	 * @param b
+	 *            the byte array
+	 * @param offset
+	 *            the array offset
+	 * @return the long
+	 */
+	public static long byteArrayToLong(byte[] b, int offset) {
+		long value = 0;
+		for (int i = 0; i < 8; i++) {
+			int shift = (8 - 1 - i) * 8;
+			value += ((long) (b[i + offset] & 0x00000000000000FF)) << shift;
+		}
+		return value;
+	}
 
-    /**
-     * Convert the byte array to a short starting from the given offset.
-     * 
-     * @param b
-     *            the byte array
-     * @param offset
-     *            the array offset
-     * @return the short
-     */
-    public static short byteArrayToShort(byte[] b, int offset) {
-        short value = 0;
-        value += (b[offset] & 0x000000FF) << 8;
-        value += (b[offset + 1] & 0x000000FF);
-        return value;
-    }
+	/**
+	 * Convert the byte array to a short starting from the given offset.
+	 * 
+	 * @param b
+	 *            the byte array
+	 * @param offset
+	 *            the array offset
+	 * @return the short
+	 */
+	public static short byteArrayToShort(byte[] b, int offset) {
+		short value = 0;
+		value += (b[offset] & 0x000000FF) << 8;
+		value += (b[offset + 1] & 0x000000FF);
+		return value;
+	}
 
-    /**
-     * Record is the unit that data is serialized in. A record includes two
-     * parts. The first part stores the size of the element and the second part
-     * stores the real element. size element record ->
-     * |----|-------------------------|
-     * 
-     * A RecordInfo stores two information of a record, the size of the "size"
-     * part which is the element offset and the size of the element part which
-     * is element size.
-     */
-    public static class RecordInfo {
-        public RecordInfo() {
-            elementOffset = 0;
-            elementSize = 0;
-        }
+	/**
+	 * Record is the unit that data is serialized in. A record includes two
+	 * parts. The first part stores the size of the element and the second part
+	 * stores the real element. size element record ->
+	 * |----|-------------------------|
+	 * 
+	 * A RecordInfo stores two information of a record, the size of the "size"
+	 * part which is the element offset and the size of the element part which
+	 * is element size.
+	 */
+	public static class RecordInfo {
+		public RecordInfo() {
+			elementOffset = 0;
+			elementSize = 0;
+		}
 
-        public byte elementOffset;
-        public int elementSize;
+		public byte elementOffset;
+		public int elementSize;
 
-        @Override
-        public String toString() {
-            return "(" + elementOffset + ", " + elementSize + ")";
-        }
-    }
+		@Override
+		public String toString() {
+			return "(" + elementOffset + ", " + elementSize + ")";
+		}
+	}
 
-    static VInt vInt = new LazyUtils.VInt();
+	static VInt vInt = new LazyUtils.VInt();
 
-    /**
-     * Check a particular field and set its size and offset in bytes based on
-     * the field type and the bytes arrays.
-     * 
-     * For void, boolean, byte, short, int, long, float and double, there is no
-     * offset and the size is fixed. For string, map, list, struct, the first
-     * four bytes are used to store the size. So the offset is 4 and the size is
-     * computed by concating the first four bytes together. The first four bytes
-     * are defined with respect to the offset in the bytes arrays.
-     * 
-     * @param objectInspector
-     *            object inspector of the field
-     * @param bytes
-     *            bytes arrays store the table row
-     * @param offset
-     *            offset of this field
-     * @param recordInfo
-     *            modify this byteinfo object and return it
-     */
-    public static void checkObjectByteInfo(ObjectInspector objectInspector, byte[] bytes, int offset,
-            RecordInfo recordInfo) {
-        Category category = objectInspector.getCategory();
-        switch (category) {
-            case PRIMITIVE:
-                PrimitiveCategory primitiveCategory = ((PrimitiveObjectInspector) objectInspector)
-                        .getPrimitiveCategory();
-                switch (primitiveCategory) {
-                    case VOID:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = 0;
-                        break;
-                    case BOOLEAN:
-                    case BYTE:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = 1;
-                        break;
-                    case SHORT:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = 2;
-                        break;
-                    case FLOAT:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = 4;
-                        break;
-                    case DOUBLE:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = 8;
-                        break;
-                    case INT:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = WritableUtils.decodeVIntSize(bytes[offset]);
-                        break;
-                    case LONG:
-                        recordInfo.elementOffset = 0;
-                        recordInfo.elementSize = WritableUtils.decodeVIntSize(bytes[offset]);
-                        break;
-                    case STRING:
-                        // using vint instead of 4 bytes
-                        LazyUtils.readVInt(bytes, offset, vInt);
-                        recordInfo.elementOffset = vInt.length;
-                        recordInfo.elementSize = vInt.value;
-                        break;
-                    default: {
-                        throw new RuntimeException("Unrecognized primitive type: " + primitiveCategory);
-                    }
-                }
-                break;
-            case LIST:
-            case MAP:
-            case STRUCT:
-                recordInfo.elementOffset = 4;
-                recordInfo.elementSize = LazyUtils.byteArrayToInt(bytes, offset);
-                break;
-            default: {
-                throw new RuntimeException("Unrecognized non-primitive type: " + category);
-            }
-        }
-    }
+	/**
+	 * Check a particular field and set its size and offset in bytes based on
+	 * the field type and the bytes arrays.
+	 * 
+	 * For void, boolean, byte, short, int, long, float and double, there is no
+	 * offset and the size is fixed. For string, map, list, struct, the first
+	 * four bytes are used to store the size. So the offset is 4 and the size is
+	 * computed by concating the first four bytes together. The first four bytes
+	 * are defined with respect to the offset in the bytes arrays.
+	 * 
+	 * @param objectInspector
+	 *            object inspector of the field
+	 * @param bytes
+	 *            bytes arrays store the table row
+	 * @param offset
+	 *            offset of this field
+	 * @param recordInfo
+	 *            modify this byteinfo object and return it
+	 */
+	public static void checkObjectByteInfo(ObjectInspector objectInspector,
+			byte[] bytes, int offset, RecordInfo recordInfo) {
+		Category category = objectInspector.getCategory();
+		switch (category) {
+		case PRIMITIVE:
+			PrimitiveCategory primitiveCategory = ((PrimitiveObjectInspector) objectInspector)
+					.getPrimitiveCategory();
+			switch (primitiveCategory) {
+			case VOID:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = 0;
+				break;
+			case BOOLEAN:
+			case BYTE:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = 1;
+				break;
+			case SHORT:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = 2;
+				break;
+			case FLOAT:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = 4;
+				break;
+			case DOUBLE:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = 8;
+				break;
+			case INT:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = WritableUtils
+						.decodeVIntSize(bytes[offset]);
+				break;
+			case LONG:
+				recordInfo.elementOffset = 0;
+				recordInfo.elementSize = WritableUtils
+						.decodeVIntSize(bytes[offset]);
+				break;
+			case STRING:
+				// using vint instead of 4 bytes
+				LazyUtils.readVInt(bytes, offset, vInt);
+				recordInfo.elementOffset = vInt.length;
+				recordInfo.elementSize = vInt.value;
+				break;
+			default: {
+				throw new RuntimeException("Unrecognized primitive type: "
+						+ primitiveCategory);
+			}
+			}
+			break;
+		case LIST:
+		case MAP:
+		case STRUCT:
+			recordInfo.elementOffset = 4;
+			recordInfo.elementSize = LazyUtils.byteArrayToInt(bytes, offset);
+			break;
+		default: {
+			throw new RuntimeException("Unrecognized non-primitive type: "
+					+ category);
+		}
+		}
+	}
 
-    /**
-     * A zero-compressed encoded long.
-     */
-    public static class VLong {
-        public VLong() {
-            value = 0;
-            length = 0;
-        }
+	/**
+	 * A zero-compressed encoded long.
+	 */
+	public static class VLong {
+		public VLong() {
+			value = 0;
+			length = 0;
+		}
 
-        public long value;
-        public byte length;
-    };
+		public long value;
+		public byte length;
+	};
 
-    /**
-     * Reads a zero-compressed encoded long from a byte array and returns it.
-     * 
-     * @param bytes
-     *            the byte array
-     * @param offset
-     *            offset of the array to read from
-     * @param vlong
-     *            storing the deserialized long and its size in byte
-     */
-    public static void readVLong(byte[] bytes, int offset, VLong vlong) {
-        byte firstByte = bytes[offset];
-        vlong.length = (byte) WritableUtils.decodeVIntSize(firstByte);
-        if (vlong.length == 1) {
-            vlong.value = firstByte;
-            return;
-        }
-        long i = 0;
-        for (int idx = 0; idx < vlong.length - 1; idx++) {
-            byte b = bytes[offset + 1 + idx];
-            i = i << 8;
-            i = i | (b & 0xFF);
-        }
-        vlong.value = (WritableUtils.isNegativeVInt(firstByte) ? (i ^ -1L) : i);
-    }
+	/**
+	 * Reads a zero-compressed encoded long from a byte array and returns it.
+	 * 
+	 * @param bytes
+	 *            the byte array
+	 * @param offset
+	 *            offset of the array to read from
+	 * @param vlong
+	 *            storing the deserialized long and its size in byte
+	 */
+	public static void readVLong(byte[] bytes, int offset, VLong vlong) {
+		byte firstByte = bytes[offset];
+		vlong.length = (byte) WritableUtils.decodeVIntSize(firstByte);
+		if (vlong.length == 1) {
+			vlong.value = firstByte;
+			return;
+		}
+		long i = 0;
+		for (int idx = 0; idx < vlong.length - 1; idx++) {
+			byte b = bytes[offset + 1 + idx];
+			i = i << 8;
+			i = i | (b & 0xFF);
+		}
+		vlong.value = (WritableUtils.isNegativeVInt(firstByte) ? (i ^ -1L) : i);
+	}
 
-    /**
-     * A zero-compressed encoded integer.
-     */
-    public static class VInt implements Serializable {
-        public VInt() {
-            value = 0;
-            length = 0;
-        }
+	/**
+	 * A zero-compressed encoded integer.
+	 */
+	public static class VInt implements Serializable {
+		public VInt() {
+			value = 0;
+			length = 0;
+		}
 
-        public int value;
-        public byte length;
-    };
+		public int value;
+		public byte length;
+	};
 
-    /**
-     * Reads a zero-compressed encoded int from a byte array and returns it.
-     * 
-     * @param bytes
-     *            the byte array
-     * @param offset
-     *            offset of the array to read from
-     * @param vInt
-     *            storing the deserialized int and its size in byte
-     */
-    public static void readVInt(byte[] bytes, int offset, VInt vInt) {
-        byte firstByte = bytes[offset];
-        vInt.length = (byte) WritableUtils.decodeVIntSize(firstByte);
-        if (vInt.length == 1) {
-            vInt.value = firstByte;
-            return;
-        }
-        int i = 0;
-        for (int idx = 0; idx < vInt.length - 1; idx++) {
-            byte b = bytes[offset + 1 + idx];
-            i = i << 8;
-            i = i | (b & 0xFF);
-        }
-        vInt.value = (WritableUtils.isNegativeVInt(firstByte) ? (i ^ -1) : i);
-    }
+	/**
+	 * Reads a zero-compressed encoded int from a byte array and returns it.
+	 * 
+	 * @param bytes
+	 *            the byte array
+	 * @param offset
+	 *            offset of the array to read from
+	 * @param vInt
+	 *            storing the deserialized int and its size in byte
+	 */
+	public static void readVInt(byte[] bytes, int offset, VInt vInt) {
+		byte firstByte = bytes[offset];
+		vInt.length = (byte) WritableUtils.decodeVIntSize(firstByte);
+		if (vInt.length == 1) {
+			vInt.value = firstByte;
+			return;
+		}
+		int i = 0;
+		for (int idx = 0; idx < vInt.length - 1; idx++) {
+			byte b = bytes[offset + 1 + idx];
+			i = i << 8;
+			i = i | (b & 0xFF);
+		}
+		vInt.value = (WritableUtils.isNegativeVInt(firstByte) ? (i ^ -1) : i);
+	}
 
-    /**
-     * Writes a zero-compressed encoded int to a byte array.
-     * 
-     * @param byteStream
-     *            the byte array/stream
-     * @param i
-     *            the int
-     */
-    public static void writeVInt(Output byteStream, int i) {
-        writeVLong(byteStream, i);
-    }
+	/**
+	 * Writes a zero-compressed encoded int to a byte array.
+	 * 
+	 * @param byteStream
+	 *            the byte array/stream
+	 * @param i
+	 *            the int
+	 */
+	public static void writeVInt(Output byteStream, int i) {
+		writeVLong(byteStream, i);
+	}
 
-    /**
-     * Write a zero-compressed encoded long to a byte array.
-     * 
-     * @param byteStream
-     *            the byte array/stream
-     * @param l
-     *            the long
-     */
-    public static void writeVLong(Output byteStream, long l) {
-        if (l >= -112 && l <= 127) {
-            byteStream.write((byte) l);
-            return;
-        }
+	/**
+	 * Write a zero-compressed encoded long to a byte array.
+	 * 
+	 * @param byteStream
+	 *            the byte array/stream
+	 * @param l
+	 *            the long
+	 */
+	public static void writeVLong(Output byteStream, long l) {
+		if (l >= -112 && l <= 127) {
+			byteStream.write((byte) l);
+			return;
+		}
 
-        int len = -112;
-        if (l < 0) {
-            l ^= -1L; // take one's complement'
-            len = -120;
-        }
+		int len = -112;
+		if (l < 0) {
+			l ^= -1L; // take one's complement'
+			len = -120;
+		}
 
-        long tmp = l;
-        while (tmp != 0) {
-            tmp = tmp >> 8;
-            len--;
-        }
+		long tmp = l;
+		while (tmp != 0) {
+			tmp = tmp >> 8;
+			len--;
+		}
 
-        byteStream.write((byte) len);
+		byteStream.write((byte) len);
 
-        len = (len < -120) ? -(len + 120) : -(len + 112);
+		len = (len < -120) ? -(len + 120) : -(len + 112);
 
-        for (int idx = len; idx != 0; idx--) {
-            int shiftbits = (idx - 1) * 8;
-            long mask = 0xFFL << shiftbits;
-            byteStream.write((byte) ((l & mask) >> shiftbits));
-        }
-    }
+		for (int idx = len; idx != 0; idx--) {
+			int shiftbits = (idx - 1) * 8;
+			long mask = 0xFFL << shiftbits;
+			byteStream.write((byte) ((l & mask) >> shiftbits));
+		}
+	}
 
-    static Map<TypeInfo, ObjectInspector> cachedLazyObjectInspector = new ConcurrentHashMap<TypeInfo, ObjectInspector>();
+	static Map<TypeInfo, ObjectInspector> cachedLazyObjectInspector = new ConcurrentHashMap<TypeInfo, ObjectInspector>();
 
-    /**
-     * Returns the lazy binary object inspector that can be used to inspect an
-     * lazy binary object of that typeInfo
-     * 
-     * For primitive types, we use the standard writable object inspector.
-     */
-    public static ObjectInspector getLazyObjectInspectorFromTypeInfo(TypeInfo typeInfo, boolean topLevel) {
-        if (typeInfo == null)
-            throw new IllegalStateException("illegal type null ");
-        ObjectInspector result = cachedLazyObjectInspector.get(typeInfo);
-        if (result == null) {
-            switch (typeInfo.getCategory()) {
-                case PRIMITIVE: {
-                    result = PrimitiveObjectInspectorFactory
-                            .getPrimitiveLazyObjectInspector(((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory());
-                    break;
-                }
-                case LIST: {
-                    ObjectInspector elementObjectInspector = getLazyObjectInspectorFromTypeInfo(
-                            ((ListTypeInfo) typeInfo).getListElementTypeInfo(), false);
-                    result = LazyObjectInspectorFactory.getLazyListObjectInspector(elementObjectInspector);
-                    break;
-                }
-                case MAP: {
-                    MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo;
-                    ObjectInspector keyObjectInspector = getLazyObjectInspectorFromTypeInfo(
-                            mapTypeInfo.getMapKeyTypeInfo(), false);
-                    ObjectInspector valueObjectInspector = getLazyObjectInspectorFromTypeInfo(
-                            mapTypeInfo.getMapValueTypeInfo(), false);
-                    result = LazyObjectInspectorFactory.getLazyMapObjectInspector(keyObjectInspector,
-                            valueObjectInspector);
-                    break;
-                }
-                case STRUCT: {
-                    StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
-                    List<String> fieldNames = structTypeInfo.getAllStructFieldNames();
-                    List<TypeInfo> fieldTypeInfos = structTypeInfo.getAllStructFieldTypeInfos();
-                    List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(fieldTypeInfos.size());
+	/**
+	 * Returns the lazy binary object inspector that can be used to inspect an
+	 * lazy binary object of that typeInfo
+	 * 
+	 * For primitive types, we use the standard writable object inspector.
+	 */
+	public static ObjectInspector getLazyObjectInspectorFromTypeInfo(
+			TypeInfo typeInfo, boolean topLevel) {
+		if (typeInfo == null)
+			throw new IllegalStateException("illegal type null ");
+		ObjectInspector result = cachedLazyObjectInspector.get(typeInfo);
+		if (result == null) {
+			switch (typeInfo.getCategory()) {
+			case PRIMITIVE: {
+				result = PrimitiveObjectInspectorFactory
+						.getPrimitiveLazyObjectInspector(((PrimitiveTypeInfo) typeInfo)
+								.getPrimitiveCategory());
+				break;
+			}
+			case LIST: {
+				ObjectInspector elementObjectInspector = getLazyObjectInspectorFromTypeInfo(
+						((ListTypeInfo) typeInfo).getListElementTypeInfo(),
+						false);
+				result = LazyObjectInspectorFactory
+						.getLazyListObjectInspector(elementObjectInspector);
+				break;
+			}
+			case MAP: {
+				MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo;
+				ObjectInspector keyObjectInspector = getLazyObjectInspectorFromTypeInfo(
+						mapTypeInfo.getMapKeyTypeInfo(), false);
+				ObjectInspector valueObjectInspector = getLazyObjectInspectorFromTypeInfo(
+						mapTypeInfo.getMapValueTypeInfo(), false);
+				result = LazyObjectInspectorFactory.getLazyMapObjectInspector(
+						keyObjectInspector, valueObjectInspector);
+				break;
+			}
+			case STRUCT: {
+				StructTypeInfo structTypeInfo = (StructTypeInfo) typeInfo;
+				List<String> fieldNames = structTypeInfo
+						.getAllStructFieldNames();
+				List<TypeInfo> fieldTypeInfos = structTypeInfo
+						.getAllStructFieldTypeInfos();
+				List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(
+						fieldTypeInfos.size());
 
-                    for (int i = 0; i < fieldTypeInfos.size(); i++) {
-                        fieldObjectInspectors.add(getLazyObjectInspectorFromTypeInfo(fieldTypeInfos.get(i), false));
-                    }
+				for (int i = 0; i < fieldTypeInfos.size(); i++) {
+					fieldObjectInspectors
+							.add(getLazyObjectInspectorFromTypeInfo(
+									fieldTypeInfos.get(i), false));
+				}
 
-                    // if it is top level then create columnar
-                    if (topLevel)
-                        result = LazyObjectInspectorFactory.getLazyColumnarObjectInspector(fieldNames,
-                                fieldObjectInspectors);
-                    // if it is not top level then create struct
-                    else
-                        result = LazyObjectInspectorFactory.getLazyStructObjectInspector(fieldNames,
-                                fieldObjectInspectors);
+				// if it is top level then create columnar
+				if (topLevel)
+					result = LazyObjectInspectorFactory
+							.getLazyColumnarObjectInspector(fieldNames,
+									fieldObjectInspectors);
+				// if it is not top level then create struct
+				else
+					result = LazyObjectInspectorFactory
+							.getLazyStructObjectInspector(fieldNames,
+									fieldObjectInspectors);
 
-                    break;
-                }
-                default: {
-                    result = null;
-                }
-            }
-            cachedLazyObjectInspector.put(typeInfo, result);
-        }
-        return result;
-    }
+				break;
+			}
+			default: {
+				result = null;
+			}
+			}
+			cachedLazyObjectInspector.put(typeInfo, result);
+		}
+		return result;
+	}
 
-    /**
-     * get top-level lazy object inspector
-     * 
-     * @param fieldNames
-     * @param fieldTypeInfos
-     * @return
-     */
-    public static ObjectInspector getLazyObjectInspector(List<String> fieldNames, List<TypeInfo> fieldTypeInfos) {
-        List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(fieldTypeInfos.size());
-        for (int i = 0; i < fieldTypeInfos.size(); i++) {
-            fieldObjectInspectors.add(getLazyObjectInspectorFromTypeInfo(fieldTypeInfos.get(i), false));
-        }
+	/**
+	 * get top-level lazy object inspector
+	 * 
+	 * @param fieldNames
+	 * @param fieldTypeInfos
+	 * @return
+	 */
+	public static ObjectInspector getLazyObjectInspector(
+			List<String> fieldNames, List<TypeInfo> fieldTypeInfos) {
+		List<ObjectInspector> fieldObjectInspectors = new ArrayList<ObjectInspector>(
+				fieldTypeInfos.size());
+		for (int i = 0; i < fieldTypeInfos.size(); i++) {
+			fieldObjectInspectors.add(getLazyObjectInspectorFromTypeInfo(
+					fieldTypeInfos.get(i), false));
+		}
 
-        return LazyObjectInspectorFactory.getLazyColumnarObjectInspector(fieldNames, fieldObjectInspectors);
-    }
+		return LazyObjectInspectorFactory.getLazyColumnarObjectInspector(
+				fieldNames, fieldObjectInspectors);
+	}
 
-    private LazyUtils() {
-        // prevent instantiation
-    }
+	private LazyUtils() {
+		// prevent instantiation
+	}
 
-    /**
-     * Returns -1 if the first byte sequence is lexicographically less than the
-     * second; returns +1 if the second byte sequence is lexicographically less
-     * than the first; otherwise return 0.
-     */
-    public static int compare(byte[] b1, int start1, int length1, byte[] b2, int start2, int length2) {
+	/**
+	 * Returns -1 if the first byte sequence is lexicographically less than the
+	 * second; returns +1 if the second byte sequence is lexicographically less
+	 * than the first; otherwise return 0.
+	 */
+	public static int compare(byte[] b1, int start1, int length1, byte[] b2,
+			int start2, int length2) {
 
-        int min = Math.min(length1, length2);
+		int min = Math.min(length1, length2);
 
-        for (int i = 0; i < min; i++) {
-            if (b1[start1 + i] == b2[start2 + i]) {
-                continue;
-            }
-            if (b1[start1 + i] < b2[start2 + i]) {
-                return -1;
-            } else {
-                return 1;
-            }
-        }
+		for (int i = 0; i < min; i++) {
+			if (b1[start1 + i] == b2[start2 + i]) {
+				continue;
+			}
+			if (b1[start1 + i] < b2[start2 + i]) {
+				return -1;
+			} else {
+				return 1;
+			}
+		}
 
-        if (length1 < length2) {
-            return -1;
-        }
-        if (length1 > length2) {
-            return 1;
-        }
-        return 0;
-    }
+		if (length1 < length2) {
+			return -1;
+		}
+		if (length1 > length2) {
+			return 1;
+		}
+		return 0;
+	}
 
-    public static int hashBytes(byte[] data, int start, int len) {
-        int hash = 1;
-        for (int i = start; i < len; i++) {
-            hash = (31 * hash) + data[i];
-        }
-        return hash;
-    }
+	public static int hashBytes(byte[] data, int start, int len) {
+		int hash = 1;
+		for (int i = start; i < len; i++) {
+			hash = (31 * hash) + data[i];
+		}
+		return hash;
+	}
 
-    /**
-     * Writes a zero-compressed encoded int to a byte array.
-     * 
-     * @param byteStream
-     *            the byte array/stream
-     * @param i
-     *            the int
-     */
-    public static void writeVInt(DataOutput byteStream, int i) throws IOException {
-        writeVLong(byteStream, i);
-    }
+	/**
+	 * Writes a zero-compressed encoded int to a byte array.
+	 * 
+	 * @param byteStream
+	 *            the byte array/stream
+	 * @param i
+	 *            the int
+	 */
+	public static void writeVInt(DataOutput byteStream, int i)
+			throws IOException {
+		writeVLong(byteStream, i);
+	}
 
-    /**
-     * Write a zero-compressed encoded long to a byte array.
-     * 
-     * @param byteStream
-     *            the byte array/stream
-     * @param l
-     *            the long
-     */
-    public static void writeVLong(DataOutput byteStream, long l) throws IOException {
-        if (l >= -112 && l <= 127) {
-            byteStream.write((byte) l);
-            return;
-        }
+	/**
+	 * Write a zero-compressed encoded long to a byte array.
+	 * 
+	 * @param byteStream
+	 *            the byte array/stream
+	 * @param l
+	 *            the long
+	 */
+	public static void writeVLong(DataOutput byteStream, long l)
+			throws IOException {
+		if (l >= -112 && l <= 127) {
+			byteStream.write((byte) l);
+			return;
+		}
 
-        int len = -112;
-        if (l < 0) {
-            l ^= -1L; // take one's complement'
-            len = -120;
-        }
+		int len = -112;
+		if (l < 0) {
+			l ^= -1L; // take one's complement'
+			len = -120;
+		}
 
-        long tmp = l;
-        while (tmp != 0) {
-            tmp = tmp >> 8;
-            len--;
-        }
+		long tmp = l;
+		while (tmp != 0) {
+			tmp = tmp >> 8;
+			len--;
+		}
 
-        byteStream.write((byte) len);
+		byteStream.write((byte) len);
 
-        len = (len < -120) ? -(len + 120) : -(len + 112);
+		len = (len < -120) ? -(len + 120) : -(len + 112);
 
-        for (int idx = len; idx != 0; idx--) {
-            int shiftbits = (idx - 1) * 8;
-            long mask = 0xFFL << shiftbits;
-            byteStream.write((byte) ((l & mask) >> shiftbits));
-        }
-    }
+		for (int idx = len; idx != 0; idx--) {
+			int shiftbits = (idx - 1) * 8;
+			long mask = 0xFFL << shiftbits;
+			byteStream.write((byte) ((l & mask) >> shiftbits));
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyColumnarObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyColumnarObjectInspector.java
index b1ca622..b20f185 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyColumnarObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyColumnarObjectInspector.java
@@ -31,47 +31,50 @@
  * 
  * @see LazyColumnar
  */
-public class LazyColumnarObjectInspector extends StandardStructObjectInspector implements Serializable {
+public class LazyColumnarObjectInspector extends StandardStructObjectInspector
+		implements Serializable {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    public LazyColumnarObjectInspector(List<String> structFieldNames, List<ObjectInspector> structFieldObjectInspectors) {
-        super(structFieldNames, structFieldObjectInspectors);
-    }
+	public LazyColumnarObjectInspector(List<String> structFieldNames,
+			List<ObjectInspector> structFieldObjectInspectors) {
+		super(structFieldNames, structFieldObjectInspectors);
+	}
 
-    public LazyColumnarObjectInspector(List<StructField> fields) {
-        super(fields);
-    }
+	public LazyColumnarObjectInspector(List<StructField> fields) {
+		super(fields);
+	}
 
-    @Override
-    public Object getStructFieldData(Object data, StructField fieldRef) {
-        if (data == null) {
-            return null;
-        }
-        LazyColumnar struct = (LazyColumnar) data;
-        MyField f = (MyField) fieldRef;
+	@Override
+	public Object getStructFieldData(Object data, StructField fieldRef) {
+		if (data == null) {
+			return null;
+		}
+		LazyColumnar struct = (LazyColumnar) data;
+		MyField f = (MyField) fieldRef;
 
-        int fieldID = f.getFieldID();
-        assert (fieldID >= 0 && fieldID < fields.size());
+		int fieldID = f.getFieldID();
+		assert (fieldID >= 0 && fieldID < fields.size());
 
-        Object column = struct.getField(fieldID);
-        return column;
-    }
+		Object column = struct.getField(fieldID);
+		return column;
+	}
 
-    @Override
-    public List<Object> getStructFieldsDataAsList(Object data) {
-        if (data == null) {
-            return null;
-        }
-        LazyColumnar struct = (LazyColumnar) data;
-        return struct.getFieldsAsList();
-    }
+	@Override
+	public List<Object> getStructFieldsDataAsList(Object data) {
+		if (data == null) {
+			return null;
+		}
+		LazyColumnar struct = (LazyColumnar) data;
+		return struct.getFieldsAsList();
+	}
 
-    public String toString() {
-        String str = "";
-        for (MyField f : fields) {
-            str += f.getFieldName() + ":" + f.getFieldObjectInspector().getTypeName() + "  ";
-        }
-        return str;
-    }
+	public String toString() {
+		String str = "";
+		for (MyField f : fields) {
+			str += f.getFieldName() + ":"
+					+ f.getFieldObjectInspector().getTypeName() + "  ";
+		}
+		return str;
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyListObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyListObjectInspector.java
index aaa5d66..dc4e85b 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyListObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyListObjectInspector.java
@@ -29,34 +29,34 @@
  */
 public class LazyListObjectInspector extends StandardListObjectInspector {
 
-    protected LazyListObjectInspector(ObjectInspector listElementObjectInspector) {
-        super(listElementObjectInspector);
-    }
+	protected LazyListObjectInspector(ObjectInspector listElementObjectInspector) {
+		super(listElementObjectInspector);
+	}
 
-    @Override
-    public List<?> getList(Object data) {
-        if (data == null) {
-            return null;
-        }
-        LazyArray array = (LazyArray) data;
-        return array.getList();
-    }
+	@Override
+	public List<?> getList(Object data) {
+		if (data == null) {
+			return null;
+		}
+		LazyArray array = (LazyArray) data;
+		return array.getList();
+	}
 
-    @Override
-    public Object getListElement(Object data, int index) {
-        if (data == null) {
-            return null;
-        }
-        LazyArray array = (LazyArray) data;
-        return array.getListElementObject(index);
-    }
+	@Override
+	public Object getListElement(Object data, int index) {
+		if (data == null) {
+			return null;
+		}
+		LazyArray array = (LazyArray) data;
+		return array.getListElementObject(index);
+	}
 
-    @Override
-    public int getListLength(Object data) {
-        if (data == null) {
-            return -1;
-        }
-        LazyArray array = (LazyArray) data;
-        return array.getListLength();
-    }
+	@Override
+	public int getListLength(Object data) {
+		if (data == null) {
+			return -1;
+		}
+		LazyArray array = (LazyArray) data;
+		return array.getListLength();
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyMapObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyMapObjectInspector.java
index 1b0c412..a3be142 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyMapObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyMapObjectInspector.java
@@ -31,31 +31,32 @@
  */
 public class LazyMapObjectInspector extends StandardMapObjectInspector {
 
-    protected LazyMapObjectInspector(ObjectInspector mapKeyObjectInspector, ObjectInspector mapValueObjectInspector) {
-        super(mapKeyObjectInspector, mapValueObjectInspector);
-    }
+	protected LazyMapObjectInspector(ObjectInspector mapKeyObjectInspector,
+			ObjectInspector mapValueObjectInspector) {
+		super(mapKeyObjectInspector, mapValueObjectInspector);
+	}
 
-    @Override
-    public Map<?, ?> getMap(Object data) {
-        if (data == null) {
-            return null;
-        }
-        return ((LazyMap) data).getMap();
-    }
+	@Override
+	public Map<?, ?> getMap(Object data) {
+		if (data == null) {
+			return null;
+		}
+		return ((LazyMap) data).getMap();
+	}
 
-    @Override
-    public int getMapSize(Object data) {
-        if (data == null) {
-            return -1;
-        }
-        return ((LazyMap) data).getMapSize();
-    }
+	@Override
+	public int getMapSize(Object data) {
+		if (data == null) {
+			return -1;
+		}
+		return ((LazyMap) data).getMapSize();
+	}
 
-    @Override
-    public Object getMapValueElement(Object data, Object key) {
-        if (data == null) {
-            return -1;
-        }
-        return ((LazyMap) data).getMapValueElement(key);
-    }
+	@Override
+	public Object getMapValueElement(Object data, Object key) {
+		if (data == null) {
+			return -1;
+		}
+		return ((LazyMap) data).getMapValueElement(key);
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyObjectInspectorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyObjectInspectorFactory.java
index f57f6d9..439b130 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyObjectInspectorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyObjectInspectorFactory.java
@@ -20,65 +20,74 @@
 
 public final class LazyObjectInspectorFactory {
 
-    static ConcurrentHashMap<ArrayList<Object>, LazyColumnarObjectInspector> cachedLazyColumnarObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyColumnarObjectInspector>();
+	static ConcurrentHashMap<ArrayList<Object>, LazyColumnarObjectInspector> cachedLazyColumnarObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyColumnarObjectInspector>();
 
-    static ConcurrentHashMap<ArrayList<Object>, LazyStructObjectInspector> cachedLazyStructObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyStructObjectInspector>();
+	static ConcurrentHashMap<ArrayList<Object>, LazyStructObjectInspector> cachedLazyStructObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyStructObjectInspector>();
 
-    static ConcurrentHashMap<ArrayList<Object>, LazyListObjectInspector> cachedLazyListObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyListObjectInspector>();
+	static ConcurrentHashMap<ArrayList<Object>, LazyListObjectInspector> cachedLazyListObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyListObjectInspector>();
 
-    static ConcurrentHashMap<ArrayList<Object>, LazyMapObjectInspector> cachedLazyMapObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyMapObjectInspector>();
+	static ConcurrentHashMap<ArrayList<Object>, LazyMapObjectInspector> cachedLazyMapObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyMapObjectInspector>();
 
-    public static LazyColumnarObjectInspector getLazyColumnarObjectInspector(List<String> structFieldNames,
-            List<ObjectInspector> structFieldObjectInspectors) {
-        ArrayList<Object> signature = new ArrayList<Object>();
-        signature.add(structFieldNames);
-        signature.add(structFieldObjectInspectors);
-        LazyColumnarObjectInspector result = cachedLazyColumnarObjectInspector.get(signature);
-        if (result == null) {
-            result = new LazyColumnarObjectInspector(structFieldNames, structFieldObjectInspectors);
-            cachedLazyColumnarObjectInspector.put(signature, result);
-        }
-        return result;
-    }
+	public static LazyColumnarObjectInspector getLazyColumnarObjectInspector(
+			List<String> structFieldNames,
+			List<ObjectInspector> structFieldObjectInspectors) {
+		ArrayList<Object> signature = new ArrayList<Object>();
+		signature.add(structFieldNames);
+		signature.add(structFieldObjectInspectors);
+		LazyColumnarObjectInspector result = cachedLazyColumnarObjectInspector
+				.get(signature);
+		if (result == null) {
+			result = new LazyColumnarObjectInspector(structFieldNames,
+					structFieldObjectInspectors);
+			cachedLazyColumnarObjectInspector.put(signature, result);
+		}
+		return result;
+	}
 
-    public static LazyStructObjectInspector getLazyStructObjectInspector(List<String> structFieldNames,
-            List<ObjectInspector> structFieldObjectInspectors) {
-        ArrayList<Object> signature = new ArrayList<Object>();
-        signature.add(structFieldNames);
-        signature.add(structFieldObjectInspectors);
-        LazyStructObjectInspector result = cachedLazyStructObjectInspector.get(signature);
-        if (result == null) {
-            result = new LazyStructObjectInspector(structFieldNames, structFieldObjectInspectors);
-            cachedLazyStructObjectInspector.put(signature, result);
-        }
-        return result;
-    }
+	public static LazyStructObjectInspector getLazyStructObjectInspector(
+			List<String> structFieldNames,
+			List<ObjectInspector> structFieldObjectInspectors) {
+		ArrayList<Object> signature = new ArrayList<Object>();
+		signature.add(structFieldNames);
+		signature.add(structFieldObjectInspectors);
+		LazyStructObjectInspector result = cachedLazyStructObjectInspector
+				.get(signature);
+		if (result == null) {
+			result = new LazyStructObjectInspector(structFieldNames,
+					structFieldObjectInspectors);
+			cachedLazyStructObjectInspector.put(signature, result);
+		}
+		return result;
+	}
 
-    public static LazyListObjectInspector getLazyListObjectInspector(ObjectInspector listElementInspector) {
-        ArrayList<Object> signature = new ArrayList<Object>();
-        signature.add(listElementInspector);
-        LazyListObjectInspector result = cachedLazyListObjectInspector.get(signature);
-        if (result == null) {
-            result = new LazyListObjectInspector(listElementInspector);
-            cachedLazyListObjectInspector.put(signature, result);
-        }
-        return result;
-    }
+	public static LazyListObjectInspector getLazyListObjectInspector(
+			ObjectInspector listElementInspector) {
+		ArrayList<Object> signature = new ArrayList<Object>();
+		signature.add(listElementInspector);
+		LazyListObjectInspector result = cachedLazyListObjectInspector
+				.get(signature);
+		if (result == null) {
+			result = new LazyListObjectInspector(listElementInspector);
+			cachedLazyListObjectInspector.put(signature, result);
+		}
+		return result;
+	}
 
-    public static LazyMapObjectInspector getLazyMapObjectInspector(ObjectInspector keyInspector,
-            ObjectInspector valueInspector) {
-        ArrayList<Object> signature = new ArrayList<Object>();
-        signature.add(keyInspector);
-        signature.add(valueInspector);
-        LazyMapObjectInspector result = cachedLazyMapObjectInspector.get(signature);
-        if (result == null) {
-            result = new LazyMapObjectInspector(keyInspector, valueInspector);
-            cachedLazyMapObjectInspector.put(signature, result);
-        }
-        return result;
-    }
+	public static LazyMapObjectInspector getLazyMapObjectInspector(
+			ObjectInspector keyInspector, ObjectInspector valueInspector) {
+		ArrayList<Object> signature = new ArrayList<Object>();
+		signature.add(keyInspector);
+		signature.add(valueInspector);
+		LazyMapObjectInspector result = cachedLazyMapObjectInspector
+				.get(signature);
+		if (result == null) {
+			result = new LazyMapObjectInspector(keyInspector, valueInspector);
+			cachedLazyMapObjectInspector.put(signature, result);
+		}
+		return result;
+	}
 
-    private LazyObjectInspectorFactory() {
-        // prevent instantiation
-    }
+	private LazyObjectInspectorFactory() {
+		// prevent instantiation
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyStructObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyStructObjectInspector.java
index ad70d4c..1a50233 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyStructObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/LazyStructObjectInspector.java
@@ -32,34 +32,35 @@
  */
 public class LazyStructObjectInspector extends StandardStructObjectInspector {
 
-    protected LazyStructObjectInspector(List<String> structFieldNames, List<ObjectInspector> structFieldObjectInspectors) {
-        super(structFieldNames, structFieldObjectInspectors);
-    }
+	protected LazyStructObjectInspector(List<String> structFieldNames,
+			List<ObjectInspector> structFieldObjectInspectors) {
+		super(structFieldNames, structFieldObjectInspectors);
+	}
 
-    protected LazyStructObjectInspector(List<StructField> fields) {
-        super(fields);
-    }
+	protected LazyStructObjectInspector(List<StructField> fields) {
+		super(fields);
+	}
 
-    @Override
-    public Object getStructFieldData(Object data, StructField fieldRef) {
-        if (data == null) {
-            return null;
-        }
-        LazyStruct struct = (LazyStruct) data;
-        MyField f = (MyField) fieldRef;
+	@Override
+	public Object getStructFieldData(Object data, StructField fieldRef) {
+		if (data == null) {
+			return null;
+		}
+		LazyStruct struct = (LazyStruct) data;
+		MyField f = (MyField) fieldRef;
 
-        int fieldID = f.getFieldID();
-        assert (fieldID >= 0 && fieldID < fields.size());
+		int fieldID = f.getFieldID();
+		assert (fieldID >= 0 && fieldID < fields.size());
 
-        return struct.getField(fieldID);
-    }
+		return struct.getField(fieldID);
+	}
 
-    @Override
-    public List<Object> getStructFieldsDataAsList(Object data) {
-        if (data == null) {
-            return null;
-        }
-        LazyStruct struct = (LazyStruct) data;
-        return struct.getFieldsAsList();
-    }
+	@Override
+	public List<Object> getStructFieldsDataAsList(Object data) {
+		if (data == null) {
+			return null;
+		}
+		LazyStruct struct = (LazyStruct) data;
+		return struct.getFieldsAsList();
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/AbstractPrimitiveLazyObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/AbstractPrimitiveLazyObjectInspector.java
index 6c19a73..6855895 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/AbstractPrimitiveLazyObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/AbstractPrimitiveLazyObjectInspector.java
@@ -26,22 +26,23 @@
 /**
  * An AbstractPrimitiveLazyObjectInspector for a LazyPrimitive object.
  */
-public abstract class AbstractPrimitiveLazyObjectInspector<T extends Writable> extends AbstractPrimitiveObjectInspector {
+public abstract class AbstractPrimitiveLazyObjectInspector<T extends Writable>
+		extends AbstractPrimitiveObjectInspector {
 
-    protected AbstractPrimitiveLazyObjectInspector(PrimitiveTypeEntry typeEntry) {
-        super(typeEntry);
-    }
+	protected AbstractPrimitiveLazyObjectInspector(PrimitiveTypeEntry typeEntry) {
+		super(typeEntry);
+	}
 
-    @Override
-    public T getPrimitiveWritableObject(Object o) {
-        if(o==null)
-            System.out.println("sth. wrong");
-        return o == null ? null : ((LazyPrimitive<?, T>) o).getWritableObject();
-    }
+	@Override
+	public T getPrimitiveWritableObject(Object o) {
+		if (o == null)
+			System.out.println("sth. wrong");
+		return o == null ? null : ((LazyPrimitive<?, T>) o).getWritableObject();
+	}
 
-    @Override
-    public boolean preferWritable() {
-        return true;
-    }
+	@Override
+	public boolean preferWritable() {
+		return true;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyBooleanObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyBooleanObjectInspector.java
index 7927c1e..472dce0 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyBooleanObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyBooleanObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableBooleanObjectInspector inspects a BooleanWritable Object.
  */
-public class LazyBooleanObjectInspector extends AbstractPrimitiveLazyObjectInspector<BooleanWritable> implements
-        BooleanObjectInspector {
+public class LazyBooleanObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<BooleanWritable> implements
+		BooleanObjectInspector {
 
-    LazyBooleanObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.booleanTypeEntry);
-    }
+	LazyBooleanObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.booleanTypeEntry);
+	}
 
-    @Override
-    public boolean get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public boolean get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyBoolean((LazyBoolean) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyBoolean((LazyBoolean) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Boolean.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Boolean.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyByteObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyByteObjectInspector.java
index 10a881c..e631fc7 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyByteObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyByteObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableByteObjectInspector inspects a ByteWritable Object.
  */
-public class LazyByteObjectInspector extends AbstractPrimitiveLazyObjectInspector<ByteWritable> implements
-        ByteObjectInspector {
+public class LazyByteObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<ByteWritable> implements
+		ByteObjectInspector {
 
-    LazyByteObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.byteTypeEntry);
-    }
+	LazyByteObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.byteTypeEntry);
+	}
 
-    @Override
-    public byte get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public byte get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyByte((LazyByte) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyByte((LazyByte) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Byte.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Byte.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyDoubleObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyDoubleObjectInspector.java
index 9f98b56..1257f11 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyDoubleObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyDoubleObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableDoubleObjectInspector inspects a DoubleWritable Object.
  */
-public class LazyDoubleObjectInspector extends AbstractPrimitiveLazyObjectInspector<DoubleWritable> implements
-        DoubleObjectInspector {
+public class LazyDoubleObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<DoubleWritable> implements
+		DoubleObjectInspector {
 
-    LazyDoubleObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.doubleTypeEntry);
-    }
+	LazyDoubleObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.doubleTypeEntry);
+	}
 
-    @Override
-    public double get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public double get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyDouble((LazyDouble) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyDouble((LazyDouble) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Double.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Double.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyFloatObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyFloatObjectInspector.java
index bf3e9a2..c66a06f 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyFloatObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyFloatObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A FloatObjectInspector inspects a FloatWritable Object.
  */
-public class LazyFloatObjectInspector extends AbstractPrimitiveLazyObjectInspector<FloatWritable> implements
-        FloatObjectInspector {
+public class LazyFloatObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<FloatWritable> implements
+		FloatObjectInspector {
 
-    LazyFloatObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.floatTypeEntry);
-    }
+	LazyFloatObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.floatTypeEntry);
+	}
 
-    @Override
-    public float get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public float get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyFloat((LazyFloat) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyFloat((LazyFloat) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Float.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Float.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyIntObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyIntObjectInspector.java
index 87bcb0d..b2159e0 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyIntObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyIntObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableIntObjectInspector inspects a IntWritable Object.
  */
-public class LazyIntObjectInspector extends AbstractPrimitiveLazyObjectInspector<IntWritable> implements
-        IntObjectInspector {
+public class LazyIntObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<IntWritable> implements
+		IntObjectInspector {
 
-    LazyIntObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.intTypeEntry);
-    }
+	LazyIntObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.intTypeEntry);
+	}
 
-    @Override
-    public int get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public int get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyInteger((LazyInteger) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyInteger((LazyInteger) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Integer.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Integer.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyLongObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyLongObjectInspector.java
index 06b5d3c..1fc2d53 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyLongObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyLongObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableLongObjectInspector inspects a LongWritable Object.
  */
-public class LazyLongObjectInspector extends AbstractPrimitiveLazyObjectInspector<LongWritable> implements
-        LongObjectInspector {
+public class LazyLongObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<LongWritable> implements
+		LongObjectInspector {
 
-    LazyLongObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.longTypeEntry);
-    }
+	LazyLongObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.longTypeEntry);
+	}
 
-    @Override
-    public long get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public long get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyLong((LazyLong) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyLong((LazyLong) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Long.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Long.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java
index c13b547..134dc5a 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyPrimitiveObjectInspectorFactory.java
@@ -37,58 +37,63 @@
  */
 public final class LazyPrimitiveObjectInspectorFactory {
 
-    public static final LazyBooleanObjectInspector LAZY_BOOLEAN_OBJECT_INSPECTOR = new LazyBooleanObjectInspector();
-    public static final LazyByteObjectInspector LAZY_BYTE_OBJECT_INSPECTOR = new LazyByteObjectInspector();
-    public static final LazyShortObjectInspector LAZY_SHORT_OBJECT_INSPECTOR = new LazyShortObjectInspector();
-    public static final LazyIntObjectInspector LAZY_INT_OBJECT_INSPECTOR = new LazyIntObjectInspector();
-    public static final LazyLongObjectInspector LAZY_LONG_OBJECT_INSPECTOR = new LazyLongObjectInspector();
-    public static final LazyFloatObjectInspector LAZY_FLOAT_OBJECT_INSPECTOR = new LazyFloatObjectInspector();
-    public static final LazyDoubleObjectInspector LAZY_DOUBLE_OBJECT_INSPECTOR = new LazyDoubleObjectInspector();
-    public static final LazyVoidObjectInspector LAZY_VOID_OBJECT_INSPECTOR = new LazyVoidObjectInspector();
+	public static final LazyBooleanObjectInspector LAZY_BOOLEAN_OBJECT_INSPECTOR = new LazyBooleanObjectInspector();
+	public static final LazyByteObjectInspector LAZY_BYTE_OBJECT_INSPECTOR = new LazyByteObjectInspector();
+	public static final LazyShortObjectInspector LAZY_SHORT_OBJECT_INSPECTOR = new LazyShortObjectInspector();
+	public static final LazyIntObjectInspector LAZY_INT_OBJECT_INSPECTOR = new LazyIntObjectInspector();
+	public static final LazyLongObjectInspector LAZY_LONG_OBJECT_INSPECTOR = new LazyLongObjectInspector();
+	public static final LazyFloatObjectInspector LAZY_FLOAT_OBJECT_INSPECTOR = new LazyFloatObjectInspector();
+	public static final LazyDoubleObjectInspector LAZY_DOUBLE_OBJECT_INSPECTOR = new LazyDoubleObjectInspector();
+	public static final LazyVoidObjectInspector LAZY_VOID_OBJECT_INSPECTOR = new LazyVoidObjectInspector();
 
-    static ConcurrentHashMap<ArrayList<Object>, LazyStringObjectInspector> cachedLazyStringObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyStringObjectInspector>();
+	static ConcurrentHashMap<ArrayList<Object>, LazyStringObjectInspector> cachedLazyStringObjectInspector = new ConcurrentHashMap<ArrayList<Object>, LazyStringObjectInspector>();
 
-    public static LazyStringObjectInspector getLazyStringObjectInspector(boolean escaped, byte escapeChar) {
-        ArrayList<Object> signature = new ArrayList<Object>();
-        signature.add(Boolean.valueOf(escaped));
-        signature.add(Byte.valueOf(escapeChar));
-        LazyStringObjectInspector result = cachedLazyStringObjectInspector.get(signature);
-        if (result == null) {
-            result = new LazyStringObjectInspector(escaped, escapeChar);
-            cachedLazyStringObjectInspector.put(signature, result);
-        }
-        return result;
-    }
+	public static LazyStringObjectInspector getLazyStringObjectInspector(
+			boolean escaped, byte escapeChar) {
+		ArrayList<Object> signature = new ArrayList<Object>();
+		signature.add(Boolean.valueOf(escaped));
+		signature.add(Byte.valueOf(escapeChar));
+		LazyStringObjectInspector result = cachedLazyStringObjectInspector
+				.get(signature);
+		if (result == null) {
+			result = new LazyStringObjectInspector(escaped, escapeChar);
+			cachedLazyStringObjectInspector.put(signature, result);
+		}
+		return result;
+	}
 
-    public static AbstractPrimitiveLazyObjectInspector<?> getLazyObjectInspector(PrimitiveCategory primitiveCategory,
-            boolean escaped, byte escapeChar) {
+	public static AbstractPrimitiveLazyObjectInspector<?> getLazyObjectInspector(
+			PrimitiveCategory primitiveCategory, boolean escaped,
+			byte escapeChar) {
 
-        switch (primitiveCategory) {
-            case BOOLEAN:
-                return LAZY_BOOLEAN_OBJECT_INSPECTOR;
-            case BYTE:
-                return LAZY_BYTE_OBJECT_INSPECTOR;
-            case SHORT:
-                return LAZY_SHORT_OBJECT_INSPECTOR;
-            case INT:
-                return LAZY_INT_OBJECT_INSPECTOR;
-            case LONG:
-                return LAZY_LONG_OBJECT_INSPECTOR;
-            case FLOAT:
-                return LAZY_FLOAT_OBJECT_INSPECTOR;
-            case DOUBLE:
-                return LAZY_DOUBLE_OBJECT_INSPECTOR;
-            case STRING:
-                return getLazyStringObjectInspector(escaped, escapeChar);
-            case VOID:
-                return LAZY_VOID_OBJECT_INSPECTOR;
-            default:
-                throw new RuntimeException("Internal error: Cannot find ObjectInspector " + " for " + primitiveCategory);
-        }
-    }
+		switch (primitiveCategory) {
+		case BOOLEAN:
+			return LAZY_BOOLEAN_OBJECT_INSPECTOR;
+		case BYTE:
+			return LAZY_BYTE_OBJECT_INSPECTOR;
+		case SHORT:
+			return LAZY_SHORT_OBJECT_INSPECTOR;
+		case INT:
+			return LAZY_INT_OBJECT_INSPECTOR;
+		case LONG:
+			return LAZY_LONG_OBJECT_INSPECTOR;
+		case FLOAT:
+			return LAZY_FLOAT_OBJECT_INSPECTOR;
+		case DOUBLE:
+			return LAZY_DOUBLE_OBJECT_INSPECTOR;
+		case STRING:
+			return getLazyStringObjectInspector(escaped, escapeChar);
+		case VOID:
+			return LAZY_VOID_OBJECT_INSPECTOR;
+		default:
+			throw new RuntimeException(
+					"Internal error: Cannot find ObjectInspector " + " for "
+							+ primitiveCategory);
+		}
+	}
 
-    private LazyPrimitiveObjectInspectorFactory() {
-        // prevent instantiation
-    }
+	private LazyPrimitiveObjectInspectorFactory() {
+		// prevent instantiation
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyShortObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyShortObjectInspector.java
index b02d9bc..cb06dfd 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyShortObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyShortObjectInspector.java
@@ -26,25 +26,26 @@
 /**
  * A WritableShortObjectInspector inspects a ShortWritable Object.
  */
-public class LazyShortObjectInspector extends AbstractPrimitiveLazyObjectInspector<ShortWritable> implements
-        ShortObjectInspector {
+public class LazyShortObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<ShortWritable> implements
+		ShortObjectInspector {
 
-    LazyShortObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.shortTypeEntry);
-    }
+	LazyShortObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.shortTypeEntry);
+	}
 
-    @Override
-    public short get(Object o) {
-        return getPrimitiveWritableObject(o).get();
-    }
+	@Override
+	public short get(Object o) {
+		return getPrimitiveWritableObject(o).get();
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyShort((LazyShort) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyShort((LazyShort) o);
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        return o == null ? null : Short.valueOf(get(o));
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		return o == null ? null : Short.valueOf(get(o));
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyStringObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyStringObjectInspector.java
index 4d649dc..5832f34 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyStringObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyStringObjectInspector.java
@@ -26,39 +26,41 @@
 /**
  * A WritableStringObjectInspector inspects a Text Object.
  */
-public class LazyStringObjectInspector extends AbstractPrimitiveLazyObjectInspector<Text> implements
-        StringObjectInspector {
+public class LazyStringObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<Text> implements
+		StringObjectInspector {
 
-    boolean escaped;
-    byte escapeChar;
+	boolean escaped;
+	byte escapeChar;
 
-    LazyStringObjectInspector(boolean escaped, byte escapeChar) {
-        super(PrimitiveObjectInspectorUtils.stringTypeEntry);
-        this.escaped = escaped;
-        this.escapeChar = escapeChar;
-    }
+	LazyStringObjectInspector(boolean escaped, byte escapeChar) {
+		super(PrimitiveObjectInspectorUtils.stringTypeEntry);
+		this.escaped = escaped;
+		this.escapeChar = escapeChar;
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o == null ? null : new LazyString((LazyString) o);
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o == null ? null : new LazyString((LazyString) o);
+	}
 
-    @Override
-    public Text getPrimitiveWritableObject(Object o) {
-        return o == null ? null : ((LazyString) o).getWritableObject();
-    }
+	@Override
+	public Text getPrimitiveWritableObject(Object o) {
+		return o == null ? null : ((LazyString) o).getWritableObject();
+	}
 
-    @Override
-    public String getPrimitiveJavaObject(Object o) {
-        return o == null ? null : ((LazyString) o).getWritableObject().toString();
-    }
+	@Override
+	public String getPrimitiveJavaObject(Object o) {
+		return o == null ? null : ((LazyString) o).getWritableObject()
+				.toString();
+	}
 
-    public boolean isEscaped() {
-        return escaped;
-    }
+	public boolean isEscaped() {
+		return escaped;
+	}
 
-    public byte getEscapeChar() {
-        return escapeChar;
-    }
+	public byte getEscapeChar() {
+		return escapeChar;
+	}
 
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyVoidObjectInspector.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyVoidObjectInspector.java
index c916191..a30f1af 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyVoidObjectInspector.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/LazyVoidObjectInspector.java
@@ -24,20 +24,21 @@
 /**
  * A WritableVoidObjectInspector inspects a NullWritable Object.
  */
-public class LazyVoidObjectInspector extends AbstractPrimitiveLazyObjectInspector<NullWritable> implements
-        VoidObjectInspector {
+public class LazyVoidObjectInspector extends
+		AbstractPrimitiveLazyObjectInspector<NullWritable> implements
+		VoidObjectInspector {
 
-    LazyVoidObjectInspector() {
-        super(PrimitiveObjectInspectorUtils.voidTypeEntry);
-    }
+	LazyVoidObjectInspector() {
+		super(PrimitiveObjectInspectorUtils.voidTypeEntry);
+	}
 
-    @Override
-    public Object copyObject(Object o) {
-        return o;
-    }
+	@Override
+	public Object copyObject(Object o) {
+		return o;
+	}
 
-    @Override
-    public Object getPrimitiveJavaObject(Object o) {
-        throw new RuntimeException("Internal error: cannot create Void object.");
-    }
+	@Override
+	public Object getPrimitiveJavaObject(Object o) {
+		throw new RuntimeException("Internal error: cannot create Void object.");
+	}
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/PrimitiveObjectInspectorFactory.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
index dbb766a..e70bdb9 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/lazy/objectinspector/primitive/PrimitiveObjectInspectorFactory.java
@@ -32,46 +32,58 @@
  */

 public final class PrimitiveObjectInspectorFactory {

 

-    public static final LazyBooleanObjectInspector LazyBooleanObjectInspector = new LazyBooleanObjectInspector();

-    public static final LazyByteObjectInspector LazyByteObjectInspector = new LazyByteObjectInspector();

-    public static final LazyShortObjectInspector LazyShortObjectInspector = new LazyShortObjectInspector();

-    public static final LazyIntObjectInspector LazyIntObjectInspector = new LazyIntObjectInspector();

-    public static final LazyLongObjectInspector LazyLongObjectInspector = new LazyLongObjectInspector();

-    public static final LazyFloatObjectInspector LazyFloatObjectInspector = new LazyFloatObjectInspector();

-    public static final LazyDoubleObjectInspector LazyDoubleObjectInspector = new LazyDoubleObjectInspector();

-    public static final LazyStringObjectInspector LazyStringObjectInspector = new LazyStringObjectInspector(false,

-            (byte) '\\');

-    public static final LazyVoidObjectInspector LazyVoidObjectInspector = new LazyVoidObjectInspector();

+	public static final LazyBooleanObjectInspector LazyBooleanObjectInspector = new LazyBooleanObjectInspector();

+	public static final LazyByteObjectInspector LazyByteObjectInspector = new LazyByteObjectInspector();

+	public static final LazyShortObjectInspector LazyShortObjectInspector = new LazyShortObjectInspector();

+	public static final LazyIntObjectInspector LazyIntObjectInspector = new LazyIntObjectInspector();

+	public static final LazyLongObjectInspector LazyLongObjectInspector = new LazyLongObjectInspector();

+	public static final LazyFloatObjectInspector LazyFloatObjectInspector = new LazyFloatObjectInspector();

+	public static final LazyDoubleObjectInspector LazyDoubleObjectInspector = new LazyDoubleObjectInspector();

+	public static final LazyStringObjectInspector LazyStringObjectInspector = new LazyStringObjectInspector(

+			false, (byte) '\\');

+	public static final LazyVoidObjectInspector LazyVoidObjectInspector = new LazyVoidObjectInspector();

 

-    private static HashMap<PrimitiveCategory, AbstractPrimitiveLazyObjectInspector<?>> cachedPrimitiveLazyInspectorCache = new HashMap<PrimitiveCategory, AbstractPrimitiveLazyObjectInspector<?>>();

+	private static HashMap<PrimitiveCategory, AbstractPrimitiveLazyObjectInspector<?>> cachedPrimitiveLazyInspectorCache = new HashMap<PrimitiveCategory, AbstractPrimitiveLazyObjectInspector<?>>();

 

-    static {

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.BOOLEAN, LazyBooleanObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.BYTE, LazyByteObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.SHORT, LazyShortObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.INT, LazyIntObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.LONG, LazyLongObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.FLOAT, LazyFloatObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.DOUBLE, LazyDoubleObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.STRING, LazyStringObjectInspector);

-        cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.VOID, LazyVoidObjectInspector);

-    }

+	static {

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.BOOLEAN,

+				LazyBooleanObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.BYTE,

+				LazyByteObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.SHORT,

+				LazyShortObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.INT,

+				LazyIntObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.LONG,

+				LazyLongObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.FLOAT,

+				LazyFloatObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.DOUBLE,

+				LazyDoubleObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.STRING,

+				LazyStringObjectInspector);

+		cachedPrimitiveLazyInspectorCache.put(PrimitiveCategory.VOID,

+				LazyVoidObjectInspector);

+	}

 

-    /**

-     * Returns the PrimitiveWritableObjectInspector for the PrimitiveCategory.

-     * 

-     * @param primitiveCategory

-     */

-    public static AbstractPrimitiveLazyObjectInspector<?> getPrimitiveLazyObjectInspector(

-            PrimitiveCategory primitiveCategory) {

-        AbstractPrimitiveLazyObjectInspector<?> result = cachedPrimitiveLazyInspectorCache.get(primitiveCategory);

-        if (result == null) {

-            throw new RuntimeException("Internal error: Cannot find ObjectInspector " + " for " + primitiveCategory);

-        }

-        return result;

-    }

+	/**

+	 * Returns the PrimitiveWritableObjectInspector for the PrimitiveCategory.

+	 * 

+	 * @param primitiveCategory

+	 */

+	public static AbstractPrimitiveLazyObjectInspector<?> getPrimitiveLazyObjectInspector(

+			PrimitiveCategory primitiveCategory) {

+		AbstractPrimitiveLazyObjectInspector<?> result = cachedPrimitiveLazyInspectorCache

+				.get(primitiveCategory);

+		if (result == null) {

+			throw new RuntimeException(

+					"Internal error: Cannot find ObjectInspector " + " for "

+							+ primitiveCategory);

+		}

+		return result;

+	}

 

-    private PrimitiveObjectInspectorFactory() {

-        // prevent instantiation

-    }

+	private PrimitiveObjectInspectorFactory() {

+		// prevent instantiation

+	}

 }

diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/IHiveParser.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/IHiveParser.java
index 7830c52..aeea68f 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/IHiveParser.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/IHiveParser.java
@@ -5,12 +5,13 @@
 import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public interface IHiveParser {
-    /**
-     * parse one hive rwo into
-     * 
-     * @param row
-     * @param objectInspector
-     * @param tb
-     */
-    public void parse(byte[] data, int start, int length, ArrayTupleBuilder tb) throws IOException;
+	/**
+	 * parse one hive rwo into
+	 * 
+	 * @param row
+	 * @param objectInspector
+	 * @param tb
+	 */
+	public void parse(byte[] data, int start, int length, ArrayTupleBuilder tb)
+			throws IOException;
 }
diff --git a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/TextToBinaryTupleParser.java b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/TextToBinaryTupleParser.java
index 38e1b36..3aeb058 100644
--- a/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/TextToBinaryTupleParser.java
+++ b/hivesterix/src/main/java/edu/uci/ics/hivesterix/serde/parser/TextToBinaryTupleParser.java
@@ -19,156 +19,166 @@
 import edu.uci.ics.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
 
 public class TextToBinaryTupleParser implements IHiveParser {
-    private int[] invertedIndex;
-    private int[] fieldEnds;
-    private int lastNecessaryFieldIndex;
-    private LazySimpleStructObjectInspector inputObjectInspector;
-    private List<? extends StructField> fieldRefs;
+	private int[] invertedIndex;
+	private int[] fieldEnds;
+	private int lastNecessaryFieldIndex;
+	private LazySimpleStructObjectInspector inputObjectInspector;
+	private List<? extends StructField> fieldRefs;
 
-    public TextToBinaryTupleParser(int[] outputColumnsOffset, ObjectInspector structInspector) {
-        int size = 0;
-        for (int i = 0; i < outputColumnsOffset.length; i++)
-            if (outputColumnsOffset[i] >= 0)
-                size++;
-        invertedIndex = new int[size];
-        for (int i = 0; i < outputColumnsOffset.length; i++)
-            if (outputColumnsOffset[i] >= 0) {
-                invertedIndex[outputColumnsOffset[i]] = i;
-                lastNecessaryFieldIndex = i;
-            }
-        fieldEnds = new int[outputColumnsOffset.length];
-        for (int i = 0; i < fieldEnds.length; i++)
-            fieldEnds[i] = 0;
-        inputObjectInspector = (LazySimpleStructObjectInspector) structInspector;
-        fieldRefs = inputObjectInspector.getAllStructFieldRefs();
-    }
+	public TextToBinaryTupleParser(int[] outputColumnsOffset,
+			ObjectInspector structInspector) {
+		int size = 0;
+		for (int i = 0; i < outputColumnsOffset.length; i++)
+			if (outputColumnsOffset[i] >= 0)
+				size++;
+		invertedIndex = new int[size];
+		for (int i = 0; i < outputColumnsOffset.length; i++)
+			if (outputColumnsOffset[i] >= 0) {
+				invertedIndex[outputColumnsOffset[i]] = i;
+				lastNecessaryFieldIndex = i;
+			}
+		fieldEnds = new int[outputColumnsOffset.length];
+		for (int i = 0; i < fieldEnds.length; i++)
+			fieldEnds[i] = 0;
+		inputObjectInspector = (LazySimpleStructObjectInspector) structInspector;
+		fieldRefs = inputObjectInspector.getAllStructFieldRefs();
+	}
 
-    @Override
-    public void parse(byte[] bytes, int start, int length, ArrayTupleBuilder tb) throws IOException {
-        byte separator = inputObjectInspector.getSeparator();
-        boolean lastColumnTakesRest = inputObjectInspector.getLastColumnTakesRest();
-        boolean isEscaped = inputObjectInspector.isEscaped();
-        byte escapeChar = inputObjectInspector.getEscapeChar();
-        DataOutput output = tb.getDataOutput();
+	@Override
+	public void parse(byte[] bytes, int start, int length, ArrayTupleBuilder tb)
+			throws IOException {
+		byte separator = inputObjectInspector.getSeparator();
+		boolean lastColumnTakesRest = inputObjectInspector
+				.getLastColumnTakesRest();
+		boolean isEscaped = inputObjectInspector.isEscaped();
+		byte escapeChar = inputObjectInspector.getEscapeChar();
+		DataOutput output = tb.getDataOutput();
 
-        int structByteEnd = start + length - 1;
-        int fieldId = 0;
-        int fieldByteEnd = start;
+		int structByteEnd = start + length - 1;
+		int fieldId = 0;
+		int fieldByteEnd = start;
 
-        // Go through all bytes in the byte[]
-        while (fieldByteEnd <= structByteEnd && fieldId <= lastNecessaryFieldIndex) {
-            if (fieldByteEnd == structByteEnd || bytes[fieldByteEnd] == separator) {
-                // Reached the end of a field?
-                if (lastColumnTakesRest && fieldId == fieldEnds.length - 1) {
-                    fieldByteEnd = structByteEnd;
-                }
-                fieldEnds[fieldId] = fieldByteEnd;
-                if (fieldId == fieldEnds.length - 1 || fieldByteEnd == structByteEnd) {
-                    // for the case of null fields
-                    for (int i = fieldId; i < fieldEnds.length; i++) {
-                        fieldEnds[i] = fieldByteEnd;
-                    }
-                    break;
-                }
-                fieldByteEnd++;
-                fieldId++;
-            } else {
-                if (isEscaped && bytes[fieldByteEnd] == escapeChar && fieldByteEnd + 1 < structByteEnd) {
-                    // ignore the char after escape_char
-                    fieldByteEnd += 2;
-                } else {
-                    fieldByteEnd++;
-                }
-            }
-        }
+		// Go through all bytes in the byte[]
+		while (fieldByteEnd <= structByteEnd
+				&& fieldId <= lastNecessaryFieldIndex) {
+			if (fieldByteEnd == structByteEnd
+					|| bytes[fieldByteEnd] == separator) {
+				// Reached the end of a field?
+				if (lastColumnTakesRest && fieldId == fieldEnds.length - 1) {
+					fieldByteEnd = structByteEnd;
+				}
+				fieldEnds[fieldId] = fieldByteEnd;
+				if (fieldId == fieldEnds.length - 1
+						|| fieldByteEnd == structByteEnd) {
+					// for the case of null fields
+					for (int i = fieldId; i < fieldEnds.length; i++) {
+						fieldEnds[i] = fieldByteEnd;
+					}
+					break;
+				}
+				fieldByteEnd++;
+				fieldId++;
+			} else {
+				if (isEscaped && bytes[fieldByteEnd] == escapeChar
+						&& fieldByteEnd + 1 < structByteEnd) {
+					// ignore the char after escape_char
+					fieldByteEnd += 2;
+				} else {
+					fieldByteEnd++;
+				}
+			}
+		}
 
-        for (int i = 0; i < invertedIndex.length; i++) {
-            int index = invertedIndex[i];
-            StructField fieldRef = fieldRefs.get(index);
-            ObjectInspector inspector = fieldRef.getFieldObjectInspector();
-            Category category = inspector.getCategory();
-            int fieldStart = index == 0 ? 0 : fieldEnds[index - 1] + 1;
-            int fieldEnd = fieldEnds[index];
-            if (bytes[fieldEnd] == separator)
-                fieldEnd--;
-            int fieldLen = fieldEnd - fieldStart + 1;
-            switch (category) {
-                case PRIMITIVE:
-                    PrimitiveObjectInspector poi = (PrimitiveObjectInspector) inspector;
-                    switch (poi.getPrimitiveCategory()) {
-                        case VOID: {
-                            break;
-                        }
-                        case BOOLEAN: {
-                            output.write(bytes[fieldStart]);
-                            break;
-                        }
-                        case BYTE: {
-                            output.write(bytes[fieldStart]);
-                            break;
-                        }
-                        case SHORT: {
-                            short v = LazyShort.parseShort(bytes, fieldStart, fieldLen);
-                            output.write((byte) (v >> 8));
-                            output.write((byte) (v));
-                            break;
-                        }
-                        case INT: {
-                            int v = LazyInteger.parseInt(bytes, fieldStart, fieldLen);
-                            LazyUtils.writeVInt(output, v);
-                            break;
-                        }
-                        case LONG: {
-                            long v = LazyLong.parseLong(bytes, fieldStart, fieldLen);
-                            LazyUtils.writeVLong(output, v);
-                            break;
-                        }
-                        case FLOAT: {
-                            float value = Float.parseFloat(Text.decode(bytes, fieldStart, fieldLen));
-                            int v = Float.floatToIntBits(value);
-                            output.write((byte) (v >> 24));
-                            output.write((byte) (v >> 16));
-                            output.write((byte) (v >> 8));
-                            output.write((byte) (v));
-                            break;
-                        }
-                        case DOUBLE: {
-                            try {
-                                double value = Double.parseDouble(Text.decode(bytes, fieldStart, fieldLen));
-                                long v = Double.doubleToLongBits(value);
-                                output.write((byte) (v >> 56));
-                                output.write((byte) (v >> 48));
-                                output.write((byte) (v >> 40));
-                                output.write((byte) (v >> 32));
-                                output.write((byte) (v >> 24));
-                                output.write((byte) (v >> 16));
-                                output.write((byte) (v >> 8));
-                                output.write((byte) (v));
-                            } catch (NumberFormatException e) {
-                                throw e;
-                            }
-                            break;
-                        }
-                        case STRING: {
-                            LazyUtils.writeVInt(output, fieldLen);
-                            output.write(bytes, fieldStart, fieldLen);
-                            break;
-                        }
-                        default: {
-                            throw new RuntimeException("Unrecognized type: " + poi.getPrimitiveCategory());
-                        }
-                    }
-                    break;
-                case STRUCT:
-                    throw new NotImplementedException("Unrecognized type: struct ");
-                case LIST:
-                    throw new NotImplementedException("Unrecognized type: struct ");
-                case MAP:
-                    throw new NotImplementedException("Unrecognized type: struct ");
-                case UNION:
-                    throw new NotImplementedException("Unrecognized type: struct ");
-            }
-            tb.addFieldEndOffset();
-        }
-    }
+		for (int i = 0; i < invertedIndex.length; i++) {
+			int index = invertedIndex[i];
+			StructField fieldRef = fieldRefs.get(index);
+			ObjectInspector inspector = fieldRef.getFieldObjectInspector();
+			Category category = inspector.getCategory();
+			int fieldStart = index == 0 ? 0 : fieldEnds[index - 1] + 1;
+			int fieldEnd = fieldEnds[index];
+			if (bytes[fieldEnd] == separator)
+				fieldEnd--;
+			int fieldLen = fieldEnd - fieldStart + 1;
+			switch (category) {
+			case PRIMITIVE:
+				PrimitiveObjectInspector poi = (PrimitiveObjectInspector) inspector;
+				switch (poi.getPrimitiveCategory()) {
+				case VOID: {
+					break;
+				}
+				case BOOLEAN: {
+					output.write(bytes[fieldStart]);
+					break;
+				}
+				case BYTE: {
+					output.write(bytes[fieldStart]);
+					break;
+				}
+				case SHORT: {
+					short v = LazyShort.parseShort(bytes, fieldStart, fieldLen);
+					output.write((byte) (v >> 8));
+					output.write((byte) (v));
+					break;
+				}
+				case INT: {
+					int v = LazyInteger.parseInt(bytes, fieldStart, fieldLen);
+					LazyUtils.writeVInt(output, v);
+					break;
+				}
+				case LONG: {
+					long v = LazyLong.parseLong(bytes, fieldStart, fieldLen);
+					LazyUtils.writeVLong(output, v);
+					break;
+				}
+				case FLOAT: {
+					float value = Float.parseFloat(Text.decode(bytes,
+							fieldStart, fieldLen));
+					int v = Float.floatToIntBits(value);
+					output.write((byte) (v >> 24));
+					output.write((byte) (v >> 16));
+					output.write((byte) (v >> 8));
+					output.write((byte) (v));
+					break;
+				}
+				case DOUBLE: {
+					try {
+						double value = Double.parseDouble(Text.decode(bytes,
+								fieldStart, fieldLen));
+						long v = Double.doubleToLongBits(value);
+						output.write((byte) (v >> 56));
+						output.write((byte) (v >> 48));
+						output.write((byte) (v >> 40));
+						output.write((byte) (v >> 32));
+						output.write((byte) (v >> 24));
+						output.write((byte) (v >> 16));
+						output.write((byte) (v >> 8));
+						output.write((byte) (v));
+					} catch (NumberFormatException e) {
+						throw e;
+					}
+					break;
+				}
+				case STRING: {
+					LazyUtils.writeVInt(output, fieldLen);
+					output.write(bytes, fieldStart, fieldLen);
+					break;
+				}
+				default: {
+					throw new RuntimeException("Unrecognized type: "
+							+ poi.getPrimitiveCategory());
+				}
+				}
+				break;
+			case STRUCT:
+				throw new NotImplementedException("Unrecognized type: struct ");
+			case LIST:
+				throw new NotImplementedException("Unrecognized type: struct ");
+			case MAP:
+				throw new NotImplementedException("Unrecognized type: struct ");
+			case UNION:
+				throw new NotImplementedException("Unrecognized type: struct ");
+			}
+			tb.addFieldEndOffset();
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/Driver.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/Driver.java
index de21cf9..2bfb797 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/Driver.java
@@ -115,1197 +115,1328 @@
 
 public class Driver implements CommandProcessor {
 
-    static final private Log LOG = LogFactory.getLog(Driver.class.getName());
-    static final private LogHelper console = new LogHelper(LOG);
+	static final private Log LOG = LogFactory.getLog(Driver.class.getName());
+	static final private LogHelper console = new LogHelper(LOG);
 
-    // hive-sterix
-    private IExecutionEngine engine;
-    private boolean hivesterix = false;
-    private PrintWriter planPrinter;
+	// hive-sterix
+	private IExecutionEngine engine;
+	private boolean hivesterix = false;
+	private PrintWriter planPrinter;
 
-    private int maxRows = 100;
-    ByteStream.Output bos = new ByteStream.Output();
+	private int maxRows = 100;
+	ByteStream.Output bos = new ByteStream.Output();
 
-    private HiveConf conf;
-    private DataInput resStream;
-    private Context ctx;
-    private QueryPlan plan;
-    private Schema schema;
-    private HiveLockManager hiveLockMgr;
+	private HiveConf conf;
+	private DataInput resStream;
+	private Context ctx;
+	private QueryPlan plan;
+	private Schema schema;
+	private HiveLockManager hiveLockMgr;
 
-    private String errorMessage;
-    private String SQLState;
+	private String errorMessage;
+	private String SQLState;
 
-    // A limit on the number of threads that can be launched
-    private int maxthreads;
-    private final int sleeptime = 2000;
+	// A limit on the number of threads that can be launched
+	private int maxthreads;
+	private final int sleeptime = 2000;
 
-    protected int tryCount = Integer.MAX_VALUE;
+	protected int tryCount = Integer.MAX_VALUE;
 
-    private int checkLockManager() {
-        boolean supportConcurrency = conf.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
-        if (supportConcurrency && (hiveLockMgr == null)) {
-            try {
-                setLockManager();
-            } catch (SemanticException e) {
-                errorMessage = "FAILED: Error in semantic analysis: " + e.getMessage();
-                SQLState = ErrorMsg.findSQLState(e.getMessage());
-                console.printError(errorMessage, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-                return (12);
-            }
-        }
-        return (0);
-    }
+	private int checkLockManager() {
+		boolean supportConcurrency = conf
+				.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
+		if (supportConcurrency && (hiveLockMgr == null)) {
+			try {
+				setLockManager();
+			} catch (SemanticException e) {
+				errorMessage = "FAILED: Error in semantic analysis: "
+						+ e.getMessage();
+				SQLState = ErrorMsg.findSQLState(e.getMessage());
+				console.printError(
+						errorMessage,
+						"\n"
+								+ org.apache.hadoop.util.StringUtils
+										.stringifyException(e));
+				return (12);
+			}
+		}
+		return (0);
+	}
 
-    private void setLockManager() throws SemanticException {
-        boolean supportConcurrency = conf.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
-        if (supportConcurrency) {
-            String lockMgr = conf.getVar(HiveConf.ConfVars.HIVE_LOCK_MANAGER);
-            if ((lockMgr == null) || (lockMgr.isEmpty())) {
-                throw new SemanticException(ErrorMsg.LOCKMGR_NOT_SPECIFIED.getMsg());
-            }
+	private void setLockManager() throws SemanticException {
+		boolean supportConcurrency = conf
+				.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
+		if (supportConcurrency) {
+			String lockMgr = conf.getVar(HiveConf.ConfVars.HIVE_LOCK_MANAGER);
+			if ((lockMgr == null) || (lockMgr.isEmpty())) {
+				throw new SemanticException(
+						ErrorMsg.LOCKMGR_NOT_SPECIFIED.getMsg());
+			}
 
-            try {
-                hiveLockMgr = (HiveLockManager) ReflectionUtils.newInstance(conf.getClassByName(lockMgr), conf);
-                hiveLockMgr.setContext(new HiveLockManagerCtx(conf));
-            } catch (Exception e) {
-                throw new SemanticException(ErrorMsg.LOCKMGR_NOT_INITIALIZED.getMsg() + e.getMessage());
-            }
-        }
-    }
+			try {
+				hiveLockMgr = (HiveLockManager) ReflectionUtils.newInstance(
+						conf.getClassByName(lockMgr), conf);
+				hiveLockMgr.setContext(new HiveLockManagerCtx(conf));
+			} catch (Exception e) {
+				throw new SemanticException(
+						ErrorMsg.LOCKMGR_NOT_INITIALIZED.getMsg()
+								+ e.getMessage());
+			}
+		}
+	}
 
-    public void init() {
-        Operator.resetId();
-    }
+	public void init() {
+		Operator.resetId();
+	}
 
-    /**
-     * Return the status information about the Map-Reduce cluster
-     */
-    public ClusterStatus getClusterStatus() throws Exception {
-        ClusterStatus cs;
-        try {
-            JobConf job = new JobConf(conf, ExecDriver.class);
-            JobClient jc = new JobClient(job);
-            cs = jc.getClusterStatus();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw e;
-        }
-        LOG.info("Returning cluster status: " + cs.toString());
-        return cs;
-    }
+	/**
+	 * Return the status information about the Map-Reduce cluster
+	 */
+	public ClusterStatus getClusterStatus() throws Exception {
+		ClusterStatus cs;
+		try {
+			JobConf job = new JobConf(conf, ExecDriver.class);
+			JobClient jc = new JobClient(job);
+			cs = jc.getClusterStatus();
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+		LOG.info("Returning cluster status: " + cs.toString());
+		return cs;
+	}
 
-    public Schema getSchema() {
-        return schema;
-    }
+	public Schema getSchema() {
+		return schema;
+	}
 
-    /**
-     * Get a Schema with fields represented with native Hive types
-     */
-    public static Schema getSchema(BaseSemanticAnalyzer sem, HiveConf conf) {
-        Schema schema = null;
+	/**
+	 * Get a Schema with fields represented with native Hive types
+	 */
+	public static Schema getSchema(BaseSemanticAnalyzer sem, HiveConf conf) {
+		Schema schema = null;
 
-        // If we have a plan, prefer its logical result schema if it's
-        // available; otherwise, try digging out a fetch task; failing that,
-        // give up.
-        if (sem == null) {
-            // can't get any info without a plan
-        } else if (sem.getResultSchema() != null) {
-            List<FieldSchema> lst = sem.getResultSchema();
-            schema = new Schema(lst, null);
-        } else if (sem.getFetchTask() != null) {
-            FetchTask ft = sem.getFetchTask();
-            TableDesc td = ft.getTblDesc();
-            // partitioned tables don't have tableDesc set on the FetchTask.
-            // Instead
-            // they have a list of PartitionDesc objects, each with a table
-            // desc.
-            // Let's
-            // try to fetch the desc for the first partition and use it's
-            // deserializer.
-            if (td == null && ft.getWork() != null && ft.getWork().getPartDesc() != null) {
-                if (ft.getWork().getPartDesc().size() > 0) {
-                    td = ft.getWork().getPartDesc().get(0).getTableDesc();
-                }
-            }
+		// If we have a plan, prefer its logical result schema if it's
+		// available; otherwise, try digging out a fetch task; failing that,
+		// give up.
+		if (sem == null) {
+			// can't get any info without a plan
+		} else if (sem.getResultSchema() != null) {
+			List<FieldSchema> lst = sem.getResultSchema();
+			schema = new Schema(lst, null);
+		} else if (sem.getFetchTask() != null) {
+			FetchTask ft = sem.getFetchTask();
+			TableDesc td = ft.getTblDesc();
+			// partitioned tables don't have tableDesc set on the FetchTask.
+			// Instead
+			// they have a list of PartitionDesc objects, each with a table
+			// desc.
+			// Let's
+			// try to fetch the desc for the first partition and use it's
+			// deserializer.
+			if (td == null && ft.getWork() != null
+					&& ft.getWork().getPartDesc() != null) {
+				if (ft.getWork().getPartDesc().size() > 0) {
+					td = ft.getWork().getPartDesc().get(0).getTableDesc();
+				}
+			}
 
-            if (td == null) {
-                LOG.info("No returning schema.");
-            } else {
-                String tableName = "result";
-                List<FieldSchema> lst = null;
-                try {
-                    lst = MetaStoreUtils.getFieldsFromDeserializer(tableName, td.getDeserializer());
-                } catch (Exception e) {
-                    LOG.warn("Error getting schema: " + org.apache.hadoop.util.StringUtils.stringifyException(e));
-                }
-                if (lst != null) {
-                    schema = new Schema(lst, null);
-                }
-            }
-        }
-        if (schema == null) {
-            schema = new Schema();
-        }
-        LOG.info("Returning Hive schema: " + schema);
-        return schema;
-    }
+			if (td == null) {
+				LOG.info("No returning schema.");
+			} else {
+				String tableName = "result";
+				List<FieldSchema> lst = null;
+				try {
+					lst = MetaStoreUtils.getFieldsFromDeserializer(tableName,
+							td.getDeserializer());
+				} catch (Exception e) {
+					LOG.warn("Error getting schema: "
+							+ org.apache.hadoop.util.StringUtils
+									.stringifyException(e));
+				}
+				if (lst != null) {
+					schema = new Schema(lst, null);
+				}
+			}
+		}
+		if (schema == null) {
+			schema = new Schema();
+		}
+		LOG.info("Returning Hive schema: " + schema);
+		return schema;
+	}
 
-    /**
-     * Get a Schema with fields represented with Thrift DDL types
-     */
-    public Schema getThriftSchema() throws Exception {
-        Schema schema;
-        try {
-            schema = getSchema();
-            if (schema != null) {
-                List<FieldSchema> lst = schema.getFieldSchemas();
-                // Go over the schema and convert type to thrift type
-                if (lst != null) {
-                    for (FieldSchema f : lst) {
-                        f.setType(MetaStoreUtils.typeToThriftType(f.getType()));
-                    }
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw e;
-        }
-        LOG.info("Returning Thrift schema: " + schema);
-        return schema;
-    }
+	/**
+	 * Get a Schema with fields represented with Thrift DDL types
+	 */
+	public Schema getThriftSchema() throws Exception {
+		Schema schema;
+		try {
+			schema = getSchema();
+			if (schema != null) {
+				List<FieldSchema> lst = schema.getFieldSchemas();
+				// Go over the schema and convert type to thrift type
+				if (lst != null) {
+					for (FieldSchema f : lst) {
+						f.setType(MetaStoreUtils.typeToThriftType(f.getType()));
+					}
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+		LOG.info("Returning Thrift schema: " + schema);
+		return schema;
+	}
 
-    /**
-     * Return the maximum number of rows returned by getResults
-     */
-    public int getMaxRows() {
-        return maxRows;
-    }
+	/**
+	 * Return the maximum number of rows returned by getResults
+	 */
+	public int getMaxRows() {
+		return maxRows;
+	}
 
-    /**
-     * Set the maximum number of rows returned by getResults
-     */
-    public void setMaxRows(int maxRows) {
-        this.maxRows = maxRows;
-    }
+	/**
+	 * Set the maximum number of rows returned by getResults
+	 */
+	public void setMaxRows(int maxRows) {
+		this.maxRows = maxRows;
+	}
 
-    public boolean hasReduceTasks(List<Task<? extends Serializable>> tasks) {
-        if (tasks == null) {
-            return false;
-        }
+	public boolean hasReduceTasks(List<Task<? extends Serializable>> tasks) {
+		if (tasks == null) {
+			return false;
+		}
 
-        boolean hasReduce = false;
-        for (Task<? extends Serializable> task : tasks) {
-            if (task.hasReduce()) {
-                return true;
-            }
+		boolean hasReduce = false;
+		for (Task<? extends Serializable> task : tasks) {
+			if (task.hasReduce()) {
+				return true;
+			}
 
-            hasReduce = (hasReduce || hasReduceTasks(task.getChildTasks()));
-        }
-        return hasReduce;
-    }
+			hasReduce = (hasReduce || hasReduceTasks(task.getChildTasks()));
+		}
+		return hasReduce;
+	}
 
-    /**
-     * for backwards compatibility with current tests
-     */
-    public Driver(HiveConf conf) {
-        this.conf = conf;
+	/**
+	 * for backwards compatibility with current tests
+	 */
+	public Driver(HiveConf conf) {
+		this.conf = conf;
 
-        // hivesterix
-        engine = new HyracksExecutionEngine(conf);
-    }
+		// hivesterix
+		engine = new HyracksExecutionEngine(conf);
+	}
 
-    public Driver() {
-        if (SessionState.get() != null) {
-            conf = SessionState.get().getConf();
-        }
+	public Driver() {
+		if (SessionState.get() != null) {
+			conf = SessionState.get().getConf();
+		}
 
-        // hivesterix
-        engine = new HyracksExecutionEngine(conf);
-    }
+		// hivesterix
+		engine = new HyracksExecutionEngine(conf);
+	}
 
-    // hivesterix: plan printer
-    public Driver(HiveConf conf, PrintWriter planPrinter) {
-        this.conf = conf;
-        engine = new HyracksExecutionEngine(conf, planPrinter);
-        this.planPrinter = planPrinter;
-    }
+	// hivesterix: plan printer
+	public Driver(HiveConf conf, PrintWriter planPrinter) {
+		this.conf = conf;
+		engine = new HyracksExecutionEngine(conf, planPrinter);
+		this.planPrinter = planPrinter;
+	}
 
-    public void clear() {
-        this.hivesterix = false;
-    }
+	public void clear() {
+		this.hivesterix = false;
+	}
 
-    /**
-     * Compile a new query. Any currently-planned query associated with this
-     * Driver is discarded.
-     * 
-     * @param command
-     *            The SQL query to compile.
-     */
-    public int compile(String command) {
-        if (plan != null) {
-            close();
-            plan = null;
-        }
+	/**
+	 * Compile a new query. Any currently-planned query associated with this
+	 * Driver is discarded.
+	 * 
+	 * @param command
+	 *            The SQL query to compile.
+	 */
+	public int compile(String command) {
+		if (plan != null) {
+			close();
+			plan = null;
+		}
 
-        TaskFactory.resetId();
+		TaskFactory.resetId();
 
-        try {
-            command = new VariableSubstitution().substitute(conf, command);
-            ctx = new Context(conf);
+		try {
+			command = new VariableSubstitution().substitute(conf, command);
+			ctx = new Context(conf);
 
-            ParseDriver pd = new ParseDriver();
-            ASTNode tree = pd.parse(command, ctx);
-            tree = ParseUtils.findRootNonNullToken(tree);
+			ParseDriver pd = new ParseDriver();
+			ASTNode tree = pd.parse(command, ctx);
+			tree = ParseUtils.findRootNonNullToken(tree);
 
-            BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
-            List<AbstractSemanticAnalyzerHook> saHooks = getSemanticAnalyzerHooks();
+			BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
+			List<AbstractSemanticAnalyzerHook> saHooks = getSemanticAnalyzerHooks();
 
-            // Do semantic analysis and plan generation
-            if (saHooks != null) {
-                HiveSemanticAnalyzerHookContext hookCtx = new HiveSemanticAnalyzerHookContextImpl();
-                hookCtx.setConf(conf);
-                for (AbstractSemanticAnalyzerHook hook : saHooks) {
-                    tree = hook.preAnalyze(hookCtx, tree);
-                }
-                sem.analyze(tree, ctx);
-                for (AbstractSemanticAnalyzerHook hook : saHooks) {
-                    hook.postAnalyze(hookCtx, sem.getRootTasks());
-                }
-            } else {
-                sem.analyze(tree, ctx);
-            }
+			// Do semantic analysis and plan generation
+			if (saHooks != null) {
+				HiveSemanticAnalyzerHookContext hookCtx = new HiveSemanticAnalyzerHookContextImpl();
+				hookCtx.setConf(conf);
+				for (AbstractSemanticAnalyzerHook hook : saHooks) {
+					tree = hook.preAnalyze(hookCtx, tree);
+				}
+				sem.analyze(tree, ctx);
+				for (AbstractSemanticAnalyzerHook hook : saHooks) {
+					hook.postAnalyze(hookCtx, sem.getRootTasks());
+				}
+			} else {
+				sem.analyze(tree, ctx);
+			}
 
-            LOG.info("Semantic Analysis Completed");
+			LOG.info("Semantic Analysis Completed");
 
-            // validate the plan
-            sem.validate();
+			// validate the plan
+			sem.validate();
 
-            plan = new QueryPlan(command, sem);
-            // initialize FetchTask right here
-            if (plan.getFetchTask() != null) {
-                plan.getFetchTask().initialize(conf, plan, null);
-            }
+			plan = new QueryPlan(command, sem);
+			// initialize FetchTask right here
+			if (plan.getFetchTask() != null) {
+				plan.getFetchTask().initialize(conf, plan, null);
+			}
 
-            // get the output schema
-            schema = getSchema(sem, conf);
+			// get the output schema
+			schema = getSchema(sem, conf);
 
-            // test Only - serialize the query plan and deserialize it
-            if (sem instanceof SemanticAnalyzer && command.toLowerCase().indexOf("create") < 0) {
+			// test Only - serialize the query plan and deserialize it
+			if (sem instanceof SemanticAnalyzer
+					&& command.toLowerCase().indexOf("create") < 0) {
 
-                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+				Thread.currentThread().setContextClassLoader(
+						this.getClass().getClassLoader());
 
-                String queryPlanFileName = ctx.getLocalScratchDir(true) + Path.SEPARATOR_CHAR + "queryplan.xml";
-                LOG.info("query plan = " + queryPlanFileName);
-                queryPlanFileName = new Path(queryPlanFileName).toUri().getPath();
+				String queryPlanFileName = ctx.getLocalScratchDir(true)
+						+ Path.SEPARATOR_CHAR + "queryplan.xml";
+				LOG.info("query plan = " + queryPlanFileName);
+				queryPlanFileName = new Path(queryPlanFileName).toUri()
+						.getPath();
 
-                // serialize the queryPlan
-                FileOutputStream fos = new FileOutputStream(queryPlanFileName);
-                Utilities.serializeQueryPlan(plan, fos);
-                fos.close();
+				// serialize the queryPlan
+				FileOutputStream fos = new FileOutputStream(queryPlanFileName);
+				Utilities.serializeQueryPlan(plan, fos);
+				fos.close();
 
-                // deserialize the queryPlan
-                FileInputStream fis = new FileInputStream(queryPlanFileName);
-                QueryPlan newPlan = Utilities.deserializeQueryPlan(fis, conf);
-                fis.close();
+				// deserialize the queryPlan
+				FileInputStream fis = new FileInputStream(queryPlanFileName);
+				QueryPlan newPlan = Utilities.deserializeQueryPlan(fis, conf);
+				fis.close();
 
-                // Use the deserialized plan
-                plan = newPlan;
-            }
+				// Use the deserialized plan
+				plan = newPlan;
+			}
 
-            // initialize FetchTask right here
-            if (plan.getFetchTask() != null) {
-                plan.getFetchTask().initialize(conf, plan, null);
-            }
+			// initialize FetchTask right here
+			if (plan.getFetchTask() != null) {
+				plan.getFetchTask().initialize(conf, plan, null);
+			}
 
-            // do the authorization check
-            if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED)) {
-                try {
-                    // doAuthorization(sem);
-                } catch (AuthorizationException authExp) {
-                    console.printError("Authorization failed:" + authExp.getMessage()
-                            + ". Use show grant to get more details.");
-                    return 403;
-                }
-            }
+			// do the authorization check
+			if (HiveConf.getBoolVar(conf,
+					HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED)) {
+				try {
+					// doAuthorization(sem);
+				} catch (AuthorizationException authExp) {
+					console.printError("Authorization failed:"
+							+ authExp.getMessage()
+							+ ". Use show grant to get more details.");
+					return 403;
+				}
+			}
 
-            // hyracks run
-            if (sem instanceof SemanticAnalyzer && command.toLowerCase().indexOf("create") < 0) {
-                hivesterix = true;
-                return engine.compileJob(sem.getRootTasks());
-            }
+			// hyracks run
+			if (sem instanceof SemanticAnalyzer
+					&& command.toLowerCase().indexOf("create") < 0) {
+				hivesterix = true;
+				return engine.compileJob(sem.getRootTasks());
+			}
 
-            return 0;
-        } catch (SemanticException e) {
-            errorMessage = "FAILED: Error in semantic analysis: " + e.getMessage();
-            SQLState = ErrorMsg.findSQLState(e.getMessage());
-            console.printError(errorMessage, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (10);
-        } catch (ParseException e) {
-            errorMessage = "FAILED: Parse Error: " + e.getMessage();
-            SQLState = ErrorMsg.findSQLState(e.getMessage());
-            console.printError(errorMessage, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (11);
-        } catch (Exception e) {
-            errorMessage = "FAILED: Hive Internal Error: " + Utilities.getNameMessage(e);
-            SQLState = ErrorMsg.findSQLState(e.getMessage());
-            console.printError(errorMessage + "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (12);
-        }
-    }
+			return 0;
+		} catch (SemanticException e) {
+			errorMessage = "FAILED: Error in semantic analysis: "
+					+ e.getMessage();
+			SQLState = ErrorMsg.findSQLState(e.getMessage());
+			console.printError(errorMessage, "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (10);
+		} catch (ParseException e) {
+			errorMessage = "FAILED: Parse Error: " + e.getMessage();
+			SQLState = ErrorMsg.findSQLState(e.getMessage());
+			console.printError(errorMessage, "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (11);
+		} catch (Exception e) {
+			errorMessage = "FAILED: Hive Internal Error: "
+					+ Utilities.getNameMessage(e);
+			SQLState = ErrorMsg.findSQLState(e.getMessage());
+			console.printError(errorMessage + "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (12);
+		}
+	}
 
-    private void doAuthorization(BaseSemanticAnalyzer sem) throws HiveException, AuthorizationException {
-        HashSet<ReadEntity> inputs = sem.getInputs();
-        HashSet<WriteEntity> outputs = sem.getOutputs();
-        SessionState ss = SessionState.get();
-        HiveOperation op = ss.getHiveOperation();
-        Hive db = sem.getDb();
-        if (op != null) {
-            if (op.equals(HiveOperation.CREATETABLE_AS_SELECT) || op.equals(HiveOperation.CREATETABLE)) {
-                ss.getAuthorizer().authorize(db.getDatabase(db.getCurrentDatabase()), null,
-                        HiveOperation.CREATETABLE_AS_SELECT.getOutputRequiredPrivileges());
-            } else {
-                // if (op.equals(HiveOperation.IMPORT)) {
-                // ImportSemanticAnalyzer isa = (ImportSemanticAnalyzer) sem;
-                // if (!isa.existsTable()) {
-                ss.getAuthorizer().authorize(db.getDatabase(db.getCurrentDatabase()), null,
-                        HiveOperation.CREATETABLE_AS_SELECT.getOutputRequiredPrivileges());
-                // }
-                // }
-            }
-            if (outputs != null && outputs.size() > 0) {
-                for (WriteEntity write : outputs) {
+	private void doAuthorization(BaseSemanticAnalyzer sem)
+			throws HiveException, AuthorizationException {
+		HashSet<ReadEntity> inputs = sem.getInputs();
+		HashSet<WriteEntity> outputs = sem.getOutputs();
+		SessionState ss = SessionState.get();
+		HiveOperation op = ss.getHiveOperation();
+		Hive db = sem.getDb();
+		if (op != null) {
+			if (op.equals(HiveOperation.CREATETABLE_AS_SELECT)
+					|| op.equals(HiveOperation.CREATETABLE)) {
+				ss.getAuthorizer().authorize(
+						db.getDatabase(db.getCurrentDatabase()),
+						null,
+						HiveOperation.CREATETABLE_AS_SELECT
+								.getOutputRequiredPrivileges());
+			} else {
+				// if (op.equals(HiveOperation.IMPORT)) {
+				// ImportSemanticAnalyzer isa = (ImportSemanticAnalyzer) sem;
+				// if (!isa.existsTable()) {
+				ss.getAuthorizer().authorize(
+						db.getDatabase(db.getCurrentDatabase()),
+						null,
+						HiveOperation.CREATETABLE_AS_SELECT
+								.getOutputRequiredPrivileges());
+				// }
+				// }
+			}
+			if (outputs != null && outputs.size() > 0) {
+				for (WriteEntity write : outputs) {
 
-                    if (write.getType() == WriteEntity.Type.PARTITION) {
-                        Partition part = db.getPartition(write.getTable(), write.getPartition().getSpec(), false);
-                        if (part != null) {
-                            ss.getAuthorizer().authorize(write.getPartition(), null, op.getOutputRequiredPrivileges());
-                            continue;
-                        }
-                    }
+					if (write.getType() == WriteEntity.Type.PARTITION) {
+						Partition part = db.getPartition(write.getTable(),
+								write.getPartition().getSpec(), false);
+						if (part != null) {
+							ss.getAuthorizer().authorize(write.getPartition(),
+									null, op.getOutputRequiredPrivileges());
+							continue;
+						}
+					}
 
-                    if (write.getTable() != null) {
-                        ss.getAuthorizer().authorize(write.getTable(), null, op.getOutputRequiredPrivileges());
-                    }
-                }
+					if (write.getTable() != null) {
+						ss.getAuthorizer().authorize(write.getTable(), null,
+								op.getOutputRequiredPrivileges());
+					}
+				}
 
-            }
-        }
+			}
+		}
 
-        if (inputs != null && inputs.size() > 0) {
+		if (inputs != null && inputs.size() > 0) {
 
-            Map<Table, List<String>> tab2Cols = new HashMap<Table, List<String>>();
-            Map<Partition, List<String>> part2Cols = new HashMap<Partition, List<String>>();
+			Map<Table, List<String>> tab2Cols = new HashMap<Table, List<String>>();
+			Map<Partition, List<String>> part2Cols = new HashMap<Partition, List<String>>();
 
-            Map<String, Boolean> tableUsePartLevelAuth = new HashMap<String, Boolean>();
-            for (ReadEntity read : inputs) {
-                if (read.getPartition() != null) {
-                    Table tbl = read.getTable();
-                    String tblName = tbl.getTableName();
-                    if (tableUsePartLevelAuth.get(tblName) == null) {
-                        boolean usePartLevelPriv = (tbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE") != null && ("TRUE"
-                                .equalsIgnoreCase(tbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))));
-                        if (usePartLevelPriv) {
-                            tableUsePartLevelAuth.put(tblName, Boolean.TRUE);
-                        } else {
-                            tableUsePartLevelAuth.put(tblName, Boolean.FALSE);
-                        }
-                    }
-                }
-            }
+			Map<String, Boolean> tableUsePartLevelAuth = new HashMap<String, Boolean>();
+			for (ReadEntity read : inputs) {
+				if (read.getPartition() != null) {
+					Table tbl = read.getTable();
+					String tblName = tbl.getTableName();
+					if (tableUsePartLevelAuth.get(tblName) == null) {
+						boolean usePartLevelPriv = (tbl.getParameters().get(
+								"PARTITION_LEVEL_PRIVILEGE") != null && ("TRUE"
+								.equalsIgnoreCase(tbl.getParameters().get(
+										"PARTITION_LEVEL_PRIVILEGE"))));
+						if (usePartLevelPriv) {
+							tableUsePartLevelAuth.put(tblName, Boolean.TRUE);
+						} else {
+							tableUsePartLevelAuth.put(tblName, Boolean.FALSE);
+						}
+					}
+				}
+			}
 
-            if (op.equals(HiveOperation.CREATETABLE_AS_SELECT) || op.equals(HiveOperation.QUERY)) {
-                SemanticAnalyzer querySem = (SemanticAnalyzer) sem;
-                ParseContext parseCtx = querySem.getParseContext();
-                Map<TableScanOperator, Table> tsoTopMap = parseCtx.getTopToTable();
+			if (op.equals(HiveOperation.CREATETABLE_AS_SELECT)
+					|| op.equals(HiveOperation.QUERY)) {
+				SemanticAnalyzer querySem = (SemanticAnalyzer) sem;
+				ParseContext parseCtx = querySem.getParseContext();
+				Map<TableScanOperator, Table> tsoTopMap = parseCtx
+						.getTopToTable();
 
-                for (Map.Entry<String, Operator<? extends Serializable>> topOpMap : querySem.getParseContext()
-                        .getTopOps().entrySet()) {
-                    Operator<? extends Serializable> topOp = topOpMap.getValue();
-                    if (topOp instanceof TableScanOperator && tsoTopMap.containsKey(topOp)) {
-                        TableScanOperator tableScanOp = (TableScanOperator) topOp;
-                        Table tbl = tsoTopMap.get(tableScanOp);
-                        List<Integer> neededColumnIds = tableScanOp.getNeededColumnIDs();
-                        List<FieldSchema> columns = tbl.getCols();
-                        List<String> cols = new ArrayList<String>();
-                        if (neededColumnIds != null && neededColumnIds.size() > 0) {
-                            for (int i = 0; i < neededColumnIds.size(); i++) {
-                                cols.add(columns.get(neededColumnIds.get(i)).getName());
-                            }
-                        } else {
-                            for (int i = 0; i < columns.size(); i++) {
-                                cols.add(columns.get(i).getName());
-                            }
-                        }
-                        if (tbl.isPartitioned() && tableUsePartLevelAuth.get(tbl.getTableName())) {
-                            String alias_id = topOpMap.getKey();
-                            PrunedPartitionList partsList = PartitionPruner.prune(parseCtx.getTopToTable().get(topOp),
-                                    parseCtx.getOpToPartPruner().get(topOp), parseCtx.getConf(), alias_id,
-                                    parseCtx.getPrunedPartitions());
-                            Set<Partition> parts = new HashSet<Partition>();
-                            parts.addAll(partsList.getConfirmedPartns());
-                            parts.addAll(partsList.getUnknownPartns());
-                            for (Partition part : parts) {
-                                List<String> existingCols = part2Cols.get(part);
-                                if (existingCols == null) {
-                                    existingCols = new ArrayList<String>();
-                                }
-                                existingCols.addAll(cols);
-                                part2Cols.put(part, existingCols);
-                            }
-                        } else {
-                            List<String> existingCols = tab2Cols.get(tbl);
-                            if (existingCols == null) {
-                                existingCols = new ArrayList<String>();
-                            }
-                            existingCols.addAll(cols);
-                            tab2Cols.put(tbl, existingCols);
-                        }
-                    }
-                }
-            }
+				for (Map.Entry<String, Operator<? extends Serializable>> topOpMap : querySem
+						.getParseContext().getTopOps().entrySet()) {
+					Operator<? extends Serializable> topOp = topOpMap
+							.getValue();
+					if (topOp instanceof TableScanOperator
+							&& tsoTopMap.containsKey(topOp)) {
+						TableScanOperator tableScanOp = (TableScanOperator) topOp;
+						Table tbl = tsoTopMap.get(tableScanOp);
+						List<Integer> neededColumnIds = tableScanOp
+								.getNeededColumnIDs();
+						List<FieldSchema> columns = tbl.getCols();
+						List<String> cols = new ArrayList<String>();
+						if (neededColumnIds != null
+								&& neededColumnIds.size() > 0) {
+							for (int i = 0; i < neededColumnIds.size(); i++) {
+								cols.add(columns.get(neededColumnIds.get(i))
+										.getName());
+							}
+						} else {
+							for (int i = 0; i < columns.size(); i++) {
+								cols.add(columns.get(i).getName());
+							}
+						}
+						if (tbl.isPartitioned()
+								&& tableUsePartLevelAuth
+										.get(tbl.getTableName())) {
+							String alias_id = topOpMap.getKey();
+							PrunedPartitionList partsList = PartitionPruner
+									.prune(parseCtx.getTopToTable().get(topOp),
+											parseCtx.getOpToPartPruner().get(
+													topOp), parseCtx.getConf(),
+											alias_id,
+											parseCtx.getPrunedPartitions());
+							Set<Partition> parts = new HashSet<Partition>();
+							parts.addAll(partsList.getConfirmedPartns());
+							parts.addAll(partsList.getUnknownPartns());
+							for (Partition part : parts) {
+								List<String> existingCols = part2Cols.get(part);
+								if (existingCols == null) {
+									existingCols = new ArrayList<String>();
+								}
+								existingCols.addAll(cols);
+								part2Cols.put(part, existingCols);
+							}
+						} else {
+							List<String> existingCols = tab2Cols.get(tbl);
+							if (existingCols == null) {
+								existingCols = new ArrayList<String>();
+							}
+							existingCols.addAll(cols);
+							tab2Cols.put(tbl, existingCols);
+						}
+					}
+				}
+			}
 
-            // cache the results for table authorization
-            Set<String> tableAuthChecked = new HashSet<String>();
-            for (ReadEntity read : inputs) {
-                Table tbl = null;
-                if (read.getPartition() != null) {
-                    tbl = read.getPartition().getTable();
-                    // use partition level authorization
-                    if (tableUsePartLevelAuth.get(tbl.getTableName())) {
-                        List<String> cols = part2Cols.get(read.getPartition());
-                        if (cols != null && cols.size() > 0) {
-                            ss.getAuthorizer().authorize(read.getPartition().getTable(), read.getPartition(), cols,
-                                    op.getInputRequiredPrivileges(), null);
-                        } else {
-                            ss.getAuthorizer().authorize(read.getPartition(), op.getInputRequiredPrivileges(), null);
-                        }
-                        continue;
-                    }
-                } else if (read.getTable() != null) {
-                    tbl = read.getTable();
-                }
+			// cache the results for table authorization
+			Set<String> tableAuthChecked = new HashSet<String>();
+			for (ReadEntity read : inputs) {
+				Table tbl = null;
+				if (read.getPartition() != null) {
+					tbl = read.getPartition().getTable();
+					// use partition level authorization
+					if (tableUsePartLevelAuth.get(tbl.getTableName())) {
+						List<String> cols = part2Cols.get(read.getPartition());
+						if (cols != null && cols.size() > 0) {
+							ss.getAuthorizer().authorize(
+									read.getPartition().getTable(),
+									read.getPartition(), cols,
+									op.getInputRequiredPrivileges(), null);
+						} else {
+							ss.getAuthorizer().authorize(read.getPartition(),
+									op.getInputRequiredPrivileges(), null);
+						}
+						continue;
+					}
+				} else if (read.getTable() != null) {
+					tbl = read.getTable();
+				}
 
-                // if we reach here, it means it needs to do a table
-                // authorization
-                // check, and the table authorization may already happened
-                // because of other
-                // partitions
-                if (tbl != null && !tableAuthChecked.contains(tbl.getTableName())) {
-                    List<String> cols = tab2Cols.get(tbl);
-                    if (cols != null && cols.size() > 0) {
-                        ss.getAuthorizer().authorize(tbl, null, cols, op.getInputRequiredPrivileges(), null);
-                    } else {
-                        ss.getAuthorizer().authorize(tbl, op.getInputRequiredPrivileges(), null);
-                    }
-                    tableAuthChecked.add(tbl.getTableName());
-                }
-            }
+				// if we reach here, it means it needs to do a table
+				// authorization
+				// check, and the table authorization may already happened
+				// because of other
+				// partitions
+				if (tbl != null
+						&& !tableAuthChecked.contains(tbl.getTableName())) {
+					List<String> cols = tab2Cols.get(tbl);
+					if (cols != null && cols.size() > 0) {
+						ss.getAuthorizer().authorize(tbl, null, cols,
+								op.getInputRequiredPrivileges(), null);
+					} else {
+						ss.getAuthorizer().authorize(tbl,
+								op.getInputRequiredPrivileges(), null);
+					}
+					tableAuthChecked.add(tbl.getTableName());
+				}
+			}
 
-        }
-    }
+		}
+	}
 
-    /**
-     * @return The current query plan associated with this Driver, if any.
-     */
-    public QueryPlan getPlan() {
-        return plan;
-    }
+	/**
+	 * @return The current query plan associated with this Driver, if any.
+	 */
+	public QueryPlan getPlan() {
+		return plan;
+	}
 
-    /**
-     * @param t
-     *            The table to be locked
-     * @param p
-     *            The partition to be locked
-     * @param mode
-     *            The mode of the lock (SHARED/EXCLUSIVE) Get the list of
-     *            objects to be locked. If a partition needs to be locked (in
-     *            any mode), all its parents should also be locked in SHARED
-     *            mode.
-     **/
-    private List<HiveLockObj> getLockObjects(Table t, Partition p, HiveLockMode mode) throws SemanticException {
-        List<HiveLockObj> locks = new LinkedList<HiveLockObj>();
+	/**
+	 * @param t
+	 *            The table to be locked
+	 * @param p
+	 *            The partition to be locked
+	 * @param mode
+	 *            The mode of the lock (SHARED/EXCLUSIVE) Get the list of
+	 *            objects to be locked. If a partition needs to be locked (in
+	 *            any mode), all its parents should also be locked in SHARED
+	 *            mode.
+	 **/
+	private List<HiveLockObj> getLockObjects(Table t, Partition p,
+			HiveLockMode mode) throws SemanticException {
+		List<HiveLockObj> locks = new LinkedList<HiveLockObj>();
 
-        HiveLockObjectData lockData = new HiveLockObjectData(plan.getQueryId(), String.valueOf(System
-                .currentTimeMillis()), "IMPLICIT");
+		HiveLockObjectData lockData = new HiveLockObjectData(plan.getQueryId(),
+				String.valueOf(System.currentTimeMillis()), "IMPLICIT");
 
-        if (t != null) {
-            locks.add(new HiveLockObj(new HiveLockObject(t, lockData), mode));
-            mode = HiveLockMode.SHARED;
-            locks.add(new HiveLockObj(new HiveLockObject(t.getDbName(), lockData), mode));
-            return locks;
-        }
+		if (t != null) {
+			locks.add(new HiveLockObj(new HiveLockObject(t, lockData), mode));
+			mode = HiveLockMode.SHARED;
+			locks.add(new HiveLockObj(new HiveLockObject(t.getDbName(),
+					lockData), mode));
+			return locks;
+		}
 
-        if (p != null) {
-            if (!(p instanceof DummyPartition)) {
-                locks.add(new HiveLockObj(new HiveLockObject(p, lockData), mode));
-            }
+		if (p != null) {
+			if (!(p instanceof DummyPartition)) {
+				locks.add(new HiveLockObj(new HiveLockObject(p, lockData), mode));
+			}
 
-            // All the parents are locked in shared mode
-            mode = HiveLockMode.SHARED;
+			// All the parents are locked in shared mode
+			mode = HiveLockMode.SHARED;
 
-            // For dummy partitions, only partition name is needed
-            String name = p.getName();
+			// For dummy partitions, only partition name is needed
+			String name = p.getName();
 
-            if (p instanceof DummyPartition) {
-                name = p.getName().split("@")[2];
-            }
+			if (p instanceof DummyPartition) {
+				name = p.getName().split("@")[2];
+			}
 
-            String partName = name;
-            String partialName = "";
-            String[] partns = name.split("/");
-            int len = p instanceof DummyPartition ? partns.length : partns.length - 1;
-            for (int idx = 0; idx < len; idx++) {
-                String partn = partns[idx];
-                partialName += partn;
-                try {
-                    locks.add(new HiveLockObj(new HiveLockObject(new DummyPartition(p.getTable(), p.getTable()
-                            .getDbName() + "/" + p.getTable().getTableName() + "/" + partialName), lockData), mode));
-                    partialName += "/";
-                } catch (HiveException e) {
-                    throw new SemanticException(e.getMessage());
-                }
-            }
+			String partName = name;
+			String partialName = "";
+			String[] partns = name.split("/");
+			int len = p instanceof DummyPartition ? partns.length
+					: partns.length - 1;
+			for (int idx = 0; idx < len; idx++) {
+				String partn = partns[idx];
+				partialName += partn;
+				try {
+					locks.add(new HiveLockObj(new HiveLockObject(
+							new DummyPartition(p.getTable(), p.getTable()
+									.getDbName()
+									+ "/"
+									+ p.getTable().getTableName()
+									+ "/"
+									+ partialName), lockData), mode));
+					partialName += "/";
+				} catch (HiveException e) {
+					throw new SemanticException(e.getMessage());
+				}
+			}
 
-            locks.add(new HiveLockObj(new HiveLockObject(p.getTable(), lockData), mode));
-            locks.add(new HiveLockObj(new HiveLockObject(p.getTable().getDbName(), lockData), mode));
-        }
-        return locks;
-    }
+			locks.add(new HiveLockObj(
+					new HiveLockObject(p.getTable(), lockData), mode));
+			locks.add(new HiveLockObj(new HiveLockObject(p.getTable()
+					.getDbName(), lockData), mode));
+		}
+		return locks;
+	}
 
-    /**
-     * Acquire read and write locks needed by the statement. The list of objects
-     * to be locked are obtained from he inputs and outputs populated by the
-     * compiler. The lock acuisition scheme is pretty simple. If all the locks
-     * cannot be obtained, error out. Deadlock is avoided by making sure that
-     * the locks are lexicographically sorted.
-     **/
-    public int acquireReadWriteLocks() {
-        try {
-            int sleepTime = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_SLEEP_BETWEEN_RETRIES) * 1000;
-            int numRetries = conf.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES);
+	/**
+	 * Acquire read and write locks needed by the statement. The list of objects
+	 * to be locked are obtained from he inputs and outputs populated by the
+	 * compiler. The lock acuisition scheme is pretty simple. If all the locks
+	 * cannot be obtained, error out. Deadlock is avoided by making sure that
+	 * the locks are lexicographically sorted.
+	 **/
+	public int acquireReadWriteLocks() {
+		try {
+			int sleepTime = conf
+					.getIntVar(HiveConf.ConfVars.HIVE_LOCK_SLEEP_BETWEEN_RETRIES) * 1000;
+			int numRetries = conf
+					.getIntVar(HiveConf.ConfVars.HIVE_LOCK_NUMRETRIES);
 
-            boolean supportConcurrency = conf.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
-            if (!supportConcurrency) {
-                return 0;
-            }
+			boolean supportConcurrency = conf
+					.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
+			if (!supportConcurrency) {
+				return 0;
+			}
 
-            List<HiveLockObj> lockObjects = new ArrayList<HiveLockObj>();
+			List<HiveLockObj> lockObjects = new ArrayList<HiveLockObj>();
 
-            // Sort all the inputs, outputs.
-            // If a lock needs to be acquired on any partition, a read lock
-            // needs to be acquired on all
-            // its parents also
-            for (ReadEntity input : plan.getInputs()) {
-                if (input.getType() == ReadEntity.Type.TABLE) {
-                    lockObjects.addAll(getLockObjects(input.getTable(), null, HiveLockMode.SHARED));
-                } else {
-                    lockObjects.addAll(getLockObjects(null, input.getPartition(), HiveLockMode.SHARED));
-                }
-            }
+			// Sort all the inputs, outputs.
+			// If a lock needs to be acquired on any partition, a read lock
+			// needs to be acquired on all
+			// its parents also
+			for (ReadEntity input : plan.getInputs()) {
+				if (input.getType() == ReadEntity.Type.TABLE) {
+					lockObjects.addAll(getLockObjects(input.getTable(), null,
+							HiveLockMode.SHARED));
+				} else {
+					lockObjects.addAll(getLockObjects(null,
+							input.getPartition(), HiveLockMode.SHARED));
+				}
+			}
 
-            for (WriteEntity output : plan.getOutputs()) {
-                if (output.getTyp() == WriteEntity.Type.TABLE) {
-                    lockObjects.addAll(getLockObjects(output.getTable(), null,
-                            output.isComplete() ? HiveLockMode.EXCLUSIVE : HiveLockMode.SHARED));
-                } else if (output.getTyp() == WriteEntity.Type.PARTITION) {
-                    lockObjects.addAll(getLockObjects(null, output.getPartition(), HiveLockMode.EXCLUSIVE));
-                }
-                // In case of dynamic queries, it is possible to have incomplete
-                // dummy partitions
-                else if (output.getTyp() == WriteEntity.Type.DUMMYPARTITION) {
-                    lockObjects.addAll(getLockObjects(null, output.getPartition(), HiveLockMode.SHARED));
-                }
-            }
+			for (WriteEntity output : plan.getOutputs()) {
+				if (output.getTyp() == WriteEntity.Type.TABLE) {
+					lockObjects.addAll(getLockObjects(output.getTable(), null,
+							output.isComplete() ? HiveLockMode.EXCLUSIVE
+									: HiveLockMode.SHARED));
+				} else if (output.getTyp() == WriteEntity.Type.PARTITION) {
+					lockObjects.addAll(getLockObjects(null,
+							output.getPartition(), HiveLockMode.EXCLUSIVE));
+				}
+				// In case of dynamic queries, it is possible to have incomplete
+				// dummy partitions
+				else if (output.getTyp() == WriteEntity.Type.DUMMYPARTITION) {
+					lockObjects.addAll(getLockObjects(null,
+							output.getPartition(), HiveLockMode.SHARED));
+				}
+			}
 
-            if (lockObjects.isEmpty() && !ctx.isNeedLockMgr()) {
-                return 0;
-            }
+			if (lockObjects.isEmpty() && !ctx.isNeedLockMgr()) {
+				return 0;
+			}
 
-            int ret = checkLockManager();
-            if (ret != 0) {
-                return ret;
-            }
+			int ret = checkLockManager();
+			if (ret != 0) {
+				return ret;
+			}
 
-            HiveLockObjectData lockData = new HiveLockObjectData(plan.getQueryId(), String.valueOf(System
-                    .currentTimeMillis()), "IMPLICIT");
+			HiveLockObjectData lockData = new HiveLockObjectData(
+					plan.getQueryId(), String.valueOf(System
+							.currentTimeMillis()), "IMPLICIT");
 
-            // Lock the database also
-            try {
-                Hive db = Hive.get(conf);
-                lockObjects.add(new HiveLockObj(new HiveLockObject(db.getCurrentDatabase(), lockData),
-                        HiveLockMode.SHARED));
-            } catch (HiveException e) {
-                throw new SemanticException(e.getMessage());
-            }
+			// Lock the database also
+			try {
+				Hive db = Hive.get(conf);
+				lockObjects.add(new HiveLockObj(new HiveLockObject(db
+						.getCurrentDatabase(), lockData), HiveLockMode.SHARED));
+			} catch (HiveException e) {
+				throw new SemanticException(e.getMessage());
+			}
 
-            ctx.setHiveLockMgr(hiveLockMgr);
-            List<HiveLock> hiveLocks = null;
+			ctx.setHiveLockMgr(hiveLockMgr);
+			List<HiveLock> hiveLocks = null;
 
-            int tryNum = 1;
-            do {
+			int tryNum = 1;
+			do {
 
-                // ctx.getHiveLockMgr();
-                // hiveLocks = ctx.getHiveLockMgr().lock(lockObjects, false);
+				// ctx.getHiveLockMgr();
+				// hiveLocks = ctx.getHiveLockMgr().lock(lockObjects, false);
 
-                if (hiveLocks != null) {
-                    break;
-                }
+				if (hiveLocks != null) {
+					break;
+				}
 
-                tryNum++;
-                try {
-                    Thread.sleep(sleepTime);
-                } catch (InterruptedException e) {
-                }
-            } while (tryNum < numRetries);
+				tryNum++;
+				try {
+					Thread.sleep(sleepTime);
+				} catch (InterruptedException e) {
+				}
+			} while (tryNum < numRetries);
 
-            if (hiveLocks == null) {
-                throw new SemanticException(ErrorMsg.LOCK_CANNOT_BE_ACQUIRED.getMsg());
-            } else {
-                ctx.setHiveLocks(hiveLocks);
-            }
+			if (hiveLocks == null) {
+				throw new SemanticException(
+						ErrorMsg.LOCK_CANNOT_BE_ACQUIRED.getMsg());
+			} else {
+				ctx.setHiveLocks(hiveLocks);
+			}
 
-            return (0);
-        } catch (SemanticException e) {
-            errorMessage = "FAILED: Error in acquiring locks: " + e.getMessage();
-            SQLState = ErrorMsg.findSQLState(e.getMessage());
-            console.printError(errorMessage, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (10);
-        } catch (Exception e) {
-            errorMessage = "FAILED: Error in acquiring locks: " + e.getMessage();
-            SQLState = ErrorMsg.findSQLState(e.getMessage());
-            console.printError(errorMessage, "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (10);
-        }
-    }
+			return (0);
+		} catch (SemanticException e) {
+			errorMessage = "FAILED: Error in acquiring locks: "
+					+ e.getMessage();
+			SQLState = ErrorMsg.findSQLState(e.getMessage());
+			console.printError(errorMessage, "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (10);
+		} catch (Exception e) {
+			errorMessage = "FAILED: Error in acquiring locks: "
+					+ e.getMessage();
+			SQLState = ErrorMsg.findSQLState(e.getMessage());
+			console.printError(errorMessage, "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (10);
+		}
+	}
 
-    /**
-     * Release all the locks acquired implicitly by the statement. Note that the
-     * locks acquired with 'keepAlive' set to True are not released.
-     **/
-    private void releaseLocks() {
-        if (ctx != null && ctx.getHiveLockMgr() != null) {
-            try {
-                ctx.getHiveLockMgr().close();
-                ctx.setHiveLocks(null);
-            } catch (LockException e) {
-            }
-        }
-    }
+	/**
+	 * Release all the locks acquired implicitly by the statement. Note that the
+	 * locks acquired with 'keepAlive' set to True are not released.
+	 **/
+	private void releaseLocks() {
+		if (ctx != null && ctx.getHiveLockMgr() != null) {
+			try {
+				ctx.getHiveLockMgr().close();
+				ctx.setHiveLocks(null);
+			} catch (LockException e) {
+			}
+		}
+	}
 
-    /**
-     * @param hiveLocks
-     *            list of hive locks to be released Release all the locks
-     *            specified. If some of the locks have already been released,
-     *            ignore them
-     **/
-    private void releaseLocks(List<HiveLock> hiveLocks) {
-        if (hiveLocks != null) {
-            ctx.getHiveLockMgr().releaseLocks(hiveLocks);
-        }
-        ctx.setHiveLocks(null);
-    }
+	/**
+	 * @param hiveLocks
+	 *            list of hive locks to be released Release all the locks
+	 *            specified. If some of the locks have already been released,
+	 *            ignore them
+	 **/
+	private void releaseLocks(List<HiveLock> hiveLocks) {
+		if (hiveLocks != null) {
+			ctx.getHiveLockMgr().releaseLocks(hiveLocks);
+		}
+		ctx.setHiveLocks(null);
+	}
 
-    public CommandProcessorResponse run(String command) {
-        errorMessage = null;
-        SQLState = null;
+	public CommandProcessorResponse run(String command) {
+		errorMessage = null;
+		SQLState = null;
 
-        int ret = compile(command);
-        if (ret != 0) {
-            // releaseLocks(ctx.getHiveLocks());
-            return new CommandProcessorResponse(ret, errorMessage, SQLState);
-        }
+		int ret = compile(command);
+		if (ret != 0) {
+			// releaseLocks(ctx.getHiveLocks());
+			return new CommandProcessorResponse(ret, errorMessage, SQLState);
+		}
 
-        // ret = acquireReadWriteLocks();
-        if (ret != 0) {
-            // releaseLocks(ctx.getHiveLocks());
-            return new CommandProcessorResponse(ret, errorMessage, SQLState);
-        }
+		// ret = acquireReadWriteLocks();
+		if (ret != 0) {
+			// releaseLocks(ctx.getHiveLocks());
+			return new CommandProcessorResponse(ret, errorMessage, SQLState);
+		}
 
-        ret = execute();
-        if (ret != 0) {
-            // releaseLocks(ctx.getHiveLocks());
-            return new CommandProcessorResponse(ret, errorMessage, SQLState);
-        }
+		ret = execute();
+		if (ret != 0) {
+			// releaseLocks(ctx.getHiveLocks());
+			return new CommandProcessorResponse(ret, errorMessage, SQLState);
+		}
 
-        // releaseLocks(ctx.getHiveLocks());
-        return new CommandProcessorResponse(ret);
-    }
+		// releaseLocks(ctx.getHiveLocks());
+		return new CommandProcessorResponse(ret);
+	}
 
-    private List<AbstractSemanticAnalyzerHook> getSemanticAnalyzerHooks() throws Exception {
-        ArrayList<AbstractSemanticAnalyzerHook> saHooks = new ArrayList<AbstractSemanticAnalyzerHook>();
-        String pestr = conf.getVar(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK);
-        if (pestr == null) {
-            return saHooks;
-        }
-        pestr = pestr.trim();
-        if (pestr.equals("")) {
-            return saHooks;
-        }
+	private List<AbstractSemanticAnalyzerHook> getSemanticAnalyzerHooks()
+			throws Exception {
+		ArrayList<AbstractSemanticAnalyzerHook> saHooks = new ArrayList<AbstractSemanticAnalyzerHook>();
+		String pestr = conf.getVar(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK);
+		if (pestr == null) {
+			return saHooks;
+		}
+		pestr = pestr.trim();
+		if (pestr.equals("")) {
+			return saHooks;
+		}
 
-        String[] peClasses = pestr.split(",");
+		String[] peClasses = pestr.split(",");
 
-        for (String peClass : peClasses) {
-            try {
-                AbstractSemanticAnalyzerHook hook = HiveUtils.getSemanticAnalyzerHook(conf, peClass);
-                saHooks.add(hook);
-            } catch (HiveException e) {
-                console.printError("Pre Exec Hook Class not found:" + e.getMessage());
-                throw e;
-            }
-        }
+		for (String peClass : peClasses) {
+			try {
+				AbstractSemanticAnalyzerHook hook = HiveUtils
+						.getSemanticAnalyzerHook(conf, peClass);
+				saHooks.add(hook);
+			} catch (HiveException e) {
+				console.printError("Pre Exec Hook Class not found:"
+						+ e.getMessage());
+				throw e;
+			}
+		}
 
-        return saHooks;
-    }
+		return saHooks;
+	}
 
-    private List<Hook> getPreExecHooks() throws Exception {
-        ArrayList<Hook> pehooks = new ArrayList<Hook>();
-        String pestr = conf.getVar(HiveConf.ConfVars.PREEXECHOOKS);
-        pestr = pestr.trim();
-        if (pestr.equals("")) {
-            return pehooks;
-        }
+	private List<Hook> getPreExecHooks() throws Exception {
+		ArrayList<Hook> pehooks = new ArrayList<Hook>();
+		String pestr = conf.getVar(HiveConf.ConfVars.PREEXECHOOKS);
+		pestr = pestr.trim();
+		if (pestr.equals("")) {
+			return pehooks;
+		}
 
-        String[] peClasses = pestr.split(",");
+		String[] peClasses = pestr.split(",");
 
-        for (String peClass : peClasses) {
-            try {
-                pehooks.add((Hook) Class.forName(peClass.trim(), true, JavaUtils.getClassLoader()).newInstance());
-            } catch (ClassNotFoundException e) {
-                console.printError("Pre Exec Hook Class not found:" + e.getMessage());
-                throw e;
-            }
-        }
+		for (String peClass : peClasses) {
+			try {
+				pehooks.add((Hook) Class.forName(peClass.trim(), true,
+						JavaUtils.getClassLoader()).newInstance());
+			} catch (ClassNotFoundException e) {
+				console.printError("Pre Exec Hook Class not found:"
+						+ e.getMessage());
+				throw e;
+			}
+		}
 
-        return pehooks;
-    }
+		return pehooks;
+	}
 
-    private List<Hook> getPostExecHooks() throws Exception {
-        ArrayList<Hook> pehooks = new ArrayList<Hook>();
-        String pestr = conf.getVar(HiveConf.ConfVars.POSTEXECHOOKS);
-        pestr = pestr.trim();
-        if (pestr.equals("")) {
-            return pehooks;
-        }
+	private List<Hook> getPostExecHooks() throws Exception {
+		ArrayList<Hook> pehooks = new ArrayList<Hook>();
+		String pestr = conf.getVar(HiveConf.ConfVars.POSTEXECHOOKS);
+		pestr = pestr.trim();
+		if (pestr.equals("")) {
+			return pehooks;
+		}
 
-        String[] peClasses = pestr.split(",");
+		String[] peClasses = pestr.split(",");
 
-        for (String peClass : peClasses) {
-            try {
-                pehooks.add((Hook) Class.forName(peClass.trim(), true, JavaUtils.getClassLoader()).newInstance());
-            } catch (ClassNotFoundException e) {
-                console.printError("Post Exec Hook Class not found:" + e.getMessage());
-                throw e;
-            }
-        }
+		for (String peClass : peClasses) {
+			try {
+				pehooks.add((Hook) Class.forName(peClass.trim(), true,
+						JavaUtils.getClassLoader()).newInstance());
+			} catch (ClassNotFoundException e) {
+				console.printError("Post Exec Hook Class not found:"
+						+ e.getMessage());
+				throw e;
+			}
+		}
 
-        return pehooks;
-    }
+		return pehooks;
+	}
 
-    public int execute() {
-        // execute hivesterix plan
-        if (hivesterix) {
-            hivesterix = false;
-            int ret = engine.executeJob();
-            if (ret != 0)
-                return ret;
-        }
+	public int execute() {
+		// execute hivesterix plan
+		if (hivesterix) {
+			hivesterix = false;
+			int ret = engine.executeJob();
+			if (ret != 0)
+				return ret;
+		}
 
-        boolean noName = StringUtils.isEmpty(conf.getVar(HiveConf.ConfVars.HADOOPJOBNAME));
-        int maxlen = conf.getIntVar(HiveConf.ConfVars.HIVEJOBNAMELENGTH);
+		boolean noName = StringUtils.isEmpty(conf
+				.getVar(HiveConf.ConfVars.HADOOPJOBNAME));
+		int maxlen = conf.getIntVar(HiveConf.ConfVars.HIVEJOBNAMELENGTH);
 
-        String queryId = plan.getQueryId();
-        String queryStr = plan.getQueryStr();
+		String queryId = plan.getQueryId();
+		String queryStr = plan.getQueryStr();
 
-        conf.setVar(HiveConf.ConfVars.HIVEQUERYID, queryId);
-        conf.setVar(HiveConf.ConfVars.HIVEQUERYSTRING, queryStr);
-        maxthreads = HiveConf.getIntVar(conf, HiveConf.ConfVars.EXECPARALLETHREADNUMBER);
+		conf.setVar(HiveConf.ConfVars.HIVEQUERYID, queryId);
+		conf.setVar(HiveConf.ConfVars.HIVEQUERYSTRING, queryStr);
+		maxthreads = HiveConf.getIntVar(conf,
+				HiveConf.ConfVars.EXECPARALLETHREADNUMBER);
 
-        try {
-            LOG.info("Starting command: " + queryStr);
+		try {
+			LOG.info("Starting command: " + queryStr);
 
-            plan.setStarted();
+			plan.setStarted();
 
-            if (SessionState.get() != null) {
-                SessionState.get().getHiveHistory().startQuery(queryStr, conf.getVar(HiveConf.ConfVars.HIVEQUERYID));
-                SessionState.get().getHiveHistory().logPlanProgress(plan);
-            }
-            resStream = null;
+			if (SessionState.get() != null) {
+				SessionState
+						.get()
+						.getHiveHistory()
+						.startQuery(queryStr,
+								conf.getVar(HiveConf.ConfVars.HIVEQUERYID));
+				SessionState.get().getHiveHistory().logPlanProgress(plan);
+			}
+			resStream = null;
 
-            HookContext hookContext = new HookContext(plan, conf);
+			HookContext hookContext = new HookContext(plan, conf);
 
-            for (Hook peh : getPreExecHooks()) {
-                if (peh instanceof ExecuteWithHookContext) {
-                    ((ExecuteWithHookContext) peh).run(hookContext);
-                } else if (peh instanceof PreExecute) {
-                    ((PreExecute) peh).run(SessionState.get(), plan.getInputs(), plan.getOutputs(), ShimLoader
-                            .getHadoopShims().getUGIForConf(conf));
-                }
-            }
+			for (Hook peh : getPreExecHooks()) {
+				if (peh instanceof ExecuteWithHookContext) {
+					((ExecuteWithHookContext) peh).run(hookContext);
+				} else if (peh instanceof PreExecute) {
+					((PreExecute) peh).run(SessionState.get(),
+							plan.getInputs(), plan.getOutputs(), ShimLoader
+									.getHadoopShims().getUGIForConf(conf));
+				}
+			}
 
-            int jobs = Utilities.getMRTasks(plan.getRootTasks()).size();
-            if (jobs > 0) {
-                console.printInfo("Total MapReduce jobs = " + jobs);
-            }
-            if (SessionState.get() != null) {
-                SessionState.get().getHiveHistory()
-                        .setQueryProperty(queryId, Keys.QUERY_NUM_TASKS, String.valueOf(jobs));
-                SessionState.get().getHiveHistory().setIdToTableMap(plan.getIdToTableNameMap());
-            }
-            String jobname = Utilities.abbreviate(queryStr, maxlen - 6);
+			int jobs = Utilities.getMRTasks(plan.getRootTasks()).size();
+			if (jobs > 0) {
+				console.printInfo("Total MapReduce jobs = " + jobs);
+			}
+			if (SessionState.get() != null) {
+				SessionState
+						.get()
+						.getHiveHistory()
+						.setQueryProperty(queryId, Keys.QUERY_NUM_TASKS,
+								String.valueOf(jobs));
+				SessionState.get().getHiveHistory()
+						.setIdToTableMap(plan.getIdToTableNameMap());
+			}
+			String jobname = Utilities.abbreviate(queryStr, maxlen - 6);
 
-            // A runtime that launches runnable tasks as separate Threads
-            // through
-            // TaskRunners
-            // As soon as a task isRunnable, it is put in a queue
-            // At any time, at most maxthreads tasks can be running
-            // The main thread polls the TaskRunners to check if they have
-            // finished.
+			// A runtime that launches runnable tasks as separate Threads
+			// through
+			// TaskRunners
+			// As soon as a task isRunnable, it is put in a queue
+			// At any time, at most maxthreads tasks can be running
+			// The main thread polls the TaskRunners to check if they have
+			// finished.
 
-            Queue<Task<? extends Serializable>> runnable = new LinkedList<Task<? extends Serializable>>();
-            Map<TaskResult, TaskRunner> running = new HashMap<TaskResult, TaskRunner>();
+			Queue<Task<? extends Serializable>> runnable = new LinkedList<Task<? extends Serializable>>();
+			Map<TaskResult, TaskRunner> running = new HashMap<TaskResult, TaskRunner>();
 
-            DriverContext driverCxt = new DriverContext(runnable, ctx);
+			DriverContext driverCxt = new DriverContext(runnable, ctx);
 
-            // Add root Tasks to runnable
+			// Add root Tasks to runnable
 
-            for (Task<? extends Serializable> tsk : plan.getRootTasks()) {
-                driverCxt.addToRunnable(tsk);
-            }
+			for (Task<? extends Serializable> tsk : plan.getRootTasks()) {
+				driverCxt.addToRunnable(tsk);
+			}
 
-            // Loop while you either have tasks running, or tasks queued up
+			// Loop while you either have tasks running, or tasks queued up
 
-            while (running.size() != 0 || runnable.peek() != null) {
-                // Launch upto maxthreads tasks
-                while (runnable.peek() != null && running.size() < maxthreads) {
-                    Task<? extends Serializable> tsk = runnable.remove();
-                    console.printInfo("executing task " + tsk.getName());
-                    launchTask(tsk, queryId, noName, running, jobname, jobs, driverCxt);
-                }
+			while (running.size() != 0 || runnable.peek() != null) {
+				// Launch upto maxthreads tasks
+				while (runnable.peek() != null && running.size() < maxthreads) {
+					Task<? extends Serializable> tsk = runnable.remove();
+					console.printInfo("executing task " + tsk.getName());
+					launchTask(tsk, queryId, noName, running, jobname, jobs,
+							driverCxt);
+				}
 
-                // poll the Tasks to see which one completed
-                TaskResult tskRes = pollTasks(running.keySet());
-                TaskRunner tskRun = running.remove(tskRes);
-                Task<? extends Serializable> tsk = tskRun.getTask();
-                hookContext.addCompleteTask(tskRun);
+				// poll the Tasks to see which one completed
+				TaskResult tskRes = pollTasks(running.keySet());
+				TaskRunner tskRun = running.remove(tskRes);
+				Task<? extends Serializable> tsk = tskRun.getTask();
+				hookContext.addCompleteTask(tskRun);
 
-                int exitVal = tskRes.getExitVal();
-                if (exitVal != 0) {
-                    Task<? extends Serializable> backupTask = tsk.getAndInitBackupTask();
-                    if (backupTask != null) {
-                        errorMessage = "FAILED: Execution Error, return code " + exitVal + " from "
-                                + tsk.getClass().getName();
-                        console.printError(errorMessage);
+				int exitVal = tskRes.getExitVal();
+				if (exitVal != 0) {
+					Task<? extends Serializable> backupTask = tsk
+							.getAndInitBackupTask();
+					if (backupTask != null) {
+						errorMessage = "FAILED: Execution Error, return code "
+								+ exitVal + " from " + tsk.getClass().getName();
+						console.printError(errorMessage);
 
-                        errorMessage = "ATTEMPT: Execute BackupTask: " + backupTask.getClass().getName();
-                        console.printError(errorMessage);
+						errorMessage = "ATTEMPT: Execute BackupTask: "
+								+ backupTask.getClass().getName();
+						console.printError(errorMessage);
 
-                        // add backup task to runnable
-                        if (DriverContext.isLaunchable(backupTask)) {
-                            driverCxt.addToRunnable(backupTask);
-                        }
-                        continue;
+						// add backup task to runnable
+						if (DriverContext.isLaunchable(backupTask)) {
+							driverCxt.addToRunnable(backupTask);
+						}
+						continue;
 
-                    } else {
-                        // TODO: This error messaging is not very informative.
-                        // Fix that.
-                        errorMessage = "FAILED: Execution Error, return code " + exitVal + " from "
-                                + tsk.getClass().getName();
-                        SQLState = "08S01";
-                        console.printError(errorMessage);
-                        if (running.size() != 0) {
-                            taskCleanup();
-                        }
-                        // in case we decided to run everything in local mode,
-                        // restore the
-                        // the jobtracker setting to its initial value
-                        ctx.restoreOriginalTracker();
-                        return 9;
-                    }
-                }
+					} else {
+						// TODO: This error messaging is not very informative.
+						// Fix that.
+						errorMessage = "FAILED: Execution Error, return code "
+								+ exitVal + " from " + tsk.getClass().getName();
+						SQLState = "08S01";
+						console.printError(errorMessage);
+						if (running.size() != 0) {
+							taskCleanup();
+						}
+						// in case we decided to run everything in local mode,
+						// restore the
+						// the jobtracker setting to its initial value
+						ctx.restoreOriginalTracker();
+						return 9;
+					}
+				}
 
-                if (SessionState.get() != null) {
-                    SessionState.get().getHiveHistory()
-                            .setTaskProperty(queryId, tsk.getId(), Keys.TASK_RET_CODE, String.valueOf(exitVal));
-                    SessionState.get().getHiveHistory().endTask(queryId, tsk);
-                }
+				if (SessionState.get() != null) {
+					SessionState
+							.get()
+							.getHiveHistory()
+							.setTaskProperty(queryId, tsk.getId(),
+									Keys.TASK_RET_CODE, String.valueOf(exitVal));
+					SessionState.get().getHiveHistory().endTask(queryId, tsk);
+				}
 
-                if (tsk.getChildTasks() != null) {
-                    for (Task<? extends Serializable> child : tsk.getChildTasks()) {
-                        // hivesterix: don't check launchable condition
-                        // if (DriverContext.isLaunchable(child)) {
-                        driverCxt.addToRunnable(child);
-                        // }
-                    }
-                }
-            }
+				if (tsk.getChildTasks() != null) {
+					for (Task<? extends Serializable> child : tsk
+							.getChildTasks()) {
+						// hivesterix: don't check launchable condition
+						// if (DriverContext.isLaunchable(child)) {
+						driverCxt.addToRunnable(child);
+						// }
+					}
+				}
+			}
 
-            // in case we decided to run everything in local mode, restore the
-            // the jobtracker setting to its initial value
-            ctx.restoreOriginalTracker();
+			// in case we decided to run everything in local mode, restore the
+			// the jobtracker setting to its initial value
+			ctx.restoreOriginalTracker();
 
-            // remove incomplete outputs.
-            // Some incomplete outputs may be added at the beginning, for eg:
-            // for dynamic partitions.
-            // remove them
-            HashSet<WriteEntity> remOutputs = new HashSet<WriteEntity>();
-            for (WriteEntity output : plan.getOutputs()) {
-                if (!output.isComplete()) {
-                    remOutputs.add(output);
-                }
-            }
+			// remove incomplete outputs.
+			// Some incomplete outputs may be added at the beginning, for eg:
+			// for dynamic partitions.
+			// remove them
+			HashSet<WriteEntity> remOutputs = new HashSet<WriteEntity>();
+			for (WriteEntity output : plan.getOutputs()) {
+				if (!output.isComplete()) {
+					remOutputs.add(output);
+				}
+			}
 
-            for (WriteEntity output : remOutputs) {
-                plan.getOutputs().remove(output);
-            }
+			for (WriteEntity output : remOutputs) {
+				plan.getOutputs().remove(output);
+			}
 
-            // Get all the post execution hooks and execute them.
-            for (Hook peh : getPostExecHooks()) {
-                if (peh instanceof ExecuteWithHookContext) {
-                    ((ExecuteWithHookContext) peh).run(hookContext);
-                } else if (peh instanceof PostExecute) {
-                    ((PostExecute) peh)
-                            .run(SessionState.get(), plan.getInputs(), plan.getOutputs(),
-                                    (SessionState.get() != null ? SessionState.get().getLineageState().getLineageInfo()
-                                            : null), ShimLoader.getHadoopShims().getUGIForConf(conf));
-                }
-            }
+			// Get all the post execution hooks and execute them.
+			for (Hook peh : getPostExecHooks()) {
+				if (peh instanceof ExecuteWithHookContext) {
+					((ExecuteWithHookContext) peh).run(hookContext);
+				} else if (peh instanceof PostExecute) {
+					((PostExecute) peh)
+							.run(SessionState.get(),
+									plan.getInputs(),
+									plan.getOutputs(),
+									(SessionState.get() != null ? SessionState
+											.get().getLineageState()
+											.getLineageInfo() : null),
+									ShimLoader.getHadoopShims().getUGIForConf(
+											conf));
+				}
+			}
 
-            if (SessionState.get() != null) {
-                SessionState.get().getHiveHistory().setQueryProperty(queryId, Keys.QUERY_RET_CODE, String.valueOf(0));
-                SessionState.get().getHiveHistory().printRowCount(queryId);
-            }
-        } catch (Exception e) {
-            if (SessionState.get() != null) {
-                SessionState.get().getHiveHistory().setQueryProperty(queryId, Keys.QUERY_RET_CODE, String.valueOf(12));
-            }
-            // TODO: do better with handling types of Exception here
-            errorMessage = "FAILED: Hive Internal Error: " + Utilities.getNameMessage(e);
-            SQLState = "08S01";
-            console.printError(errorMessage + "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return (12);
-        } finally {
-            if (SessionState.get() != null) {
-                SessionState.get().getHiveHistory().endQuery(queryId);
-            }
-            if (noName) {
-                conf.setVar(HiveConf.ConfVars.HADOOPJOBNAME, "");
-            }
-        }
-        plan.setDone();
+			if (SessionState.get() != null) {
+				SessionState
+						.get()
+						.getHiveHistory()
+						.setQueryProperty(queryId, Keys.QUERY_RET_CODE,
+								String.valueOf(0));
+				SessionState.get().getHiveHistory().printRowCount(queryId);
+			}
+		} catch (Exception e) {
+			if (SessionState.get() != null) {
+				SessionState
+						.get()
+						.getHiveHistory()
+						.setQueryProperty(queryId, Keys.QUERY_RET_CODE,
+								String.valueOf(12));
+			}
+			// TODO: do better with handling types of Exception here
+			errorMessage = "FAILED: Hive Internal Error: "
+					+ Utilities.getNameMessage(e);
+			SQLState = "08S01";
+			console.printError(errorMessage + "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return (12);
+		} finally {
+			if (SessionState.get() != null) {
+				SessionState.get().getHiveHistory().endQuery(queryId);
+			}
+			if (noName) {
+				conf.setVar(HiveConf.ConfVars.HADOOPJOBNAME, "");
+			}
+		}
+		plan.setDone();
 
-        if (SessionState.get() != null) {
-            try {
-                SessionState.get().getHiveHistory().logPlanProgress(plan);
-            } catch (Exception e) {
-            }
-        }
-        console.printInfo("OK");
+		if (SessionState.get() != null) {
+			try {
+				SessionState.get().getHiveHistory().logPlanProgress(plan);
+			} catch (Exception e) {
+			}
+		}
+		console.printInfo("OK");
 
-        return (0);
-    }
+		return (0);
+	}
 
-    /**
-     * Launches a new task
-     * 
-     * @param tsk
-     *            task being launched
-     * @param queryId
-     *            Id of the query containing the task
-     * @param noName
-     *            whether the task has a name set
-     * @param running
-     *            map from taskresults to taskrunners
-     * @param jobname
-     *            name of the task, if it is a map-reduce job
-     * @param jobs
-     *            number of map-reduce jobs
-     * @param curJobNo
-     *            the sequential number of the next map-reduce job
-     * @return the updated number of last the map-reduce job launched
-     */
+	/**
+	 * Launches a new task
+	 * 
+	 * @param tsk
+	 *            task being launched
+	 * @param queryId
+	 *            Id of the query containing the task
+	 * @param noName
+	 *            whether the task has a name set
+	 * @param running
+	 *            map from taskresults to taskrunners
+	 * @param jobname
+	 *            name of the task, if it is a map-reduce job
+	 * @param jobs
+	 *            number of map-reduce jobs
+	 * @param curJobNo
+	 *            the sequential number of the next map-reduce job
+	 * @return the updated number of last the map-reduce job launched
+	 */
 
-    public void launchTask(Task<? extends Serializable> tsk, String queryId, boolean noName,
-            Map<TaskResult, TaskRunner> running, String jobname, int jobs, DriverContext cxt) {
+	public void launchTask(Task<? extends Serializable> tsk, String queryId,
+			boolean noName, Map<TaskResult, TaskRunner> running,
+			String jobname, int jobs, DriverContext cxt) {
 
-        if (SessionState.get() != null) {
-            SessionState.get().getHiveHistory().startTask(queryId, tsk, tsk.getClass().getName());
-        }
-        if (tsk.isMapRedTask() && !(tsk instanceof ConditionalTask)) {
-            if (noName) {
-                conf.setVar(HiveConf.ConfVars.HADOOPJOBNAME, jobname + "(" + tsk.getId() + ")");
-            }
-            cxt.incCurJobNo(1);
-            console.printInfo("Launching Job " + cxt.getCurJobNo() + " out of " + jobs);
-        }
-        tsk.initialize(conf, plan, cxt);
-        TaskResult tskRes = new TaskResult();
-        TaskRunner tskRun = new TaskRunner(tsk, tskRes);
+		if (SessionState.get() != null) {
+			SessionState.get().getHiveHistory()
+					.startTask(queryId, tsk, tsk.getClass().getName());
+		}
+		if (tsk.isMapRedTask() && !(tsk instanceof ConditionalTask)) {
+			if (noName) {
+				conf.setVar(HiveConf.ConfVars.HADOOPJOBNAME, jobname + "("
+						+ tsk.getId() + ")");
+			}
+			cxt.incCurJobNo(1);
+			console.printInfo("Launching Job " + cxt.getCurJobNo() + " out of "
+					+ jobs);
+		}
+		tsk.initialize(conf, plan, cxt);
+		TaskResult tskRes = new TaskResult();
+		TaskRunner tskRun = new TaskRunner(tsk, tskRes);
 
-        // HiveConf.getBoolVar(conf, HiveConf.ConfVars.EXECPARALLEL) &&
-        // Launch Task: hivesterix tweak
-        if (tsk instanceof MapRedTask || tsk instanceof StatsTask) {
-            // Launch it in the parallel mode, as a separate thread only for MR
-            // tasks
-            tskRes.setRunning(false);
-            tskRes.setExitVal(0);
-        } else if (tsk instanceof ConditionalTask) {
-            ConditionalTask condTask = (ConditionalTask) tsk;
-            ConditionalResolver crs = condTask.getResolver();
-            if (crs instanceof ConditionalResolverMergeFiles) {
-                tskRes.setRunning(false);
-                tskRes.setExitVal(0);
+		// HiveConf.getBoolVar(conf, HiveConf.ConfVars.EXECPARALLEL) &&
+		// Launch Task: hivesterix tweak
+		if (tsk instanceof MapRedTask || tsk instanceof StatsTask) {
+			// Launch it in the parallel mode, as a separate thread only for MR
+			// tasks
+			tskRes.setRunning(false);
+			tskRes.setExitVal(0);
+		} else if (tsk instanceof ConditionalTask) {
+			ConditionalTask condTask = (ConditionalTask) tsk;
+			ConditionalResolver crs = condTask.getResolver();
+			if (crs instanceof ConditionalResolverMergeFiles) {
+				tskRes.setRunning(false);
+				tskRes.setExitVal(0);
 
-                List<Task<? extends Serializable>> children = condTask.getListTasks();
-                for (Task<? extends Serializable> child : children)
-                    if (child instanceof MapRedTask)
-                        cxt.addToRunnable(child);
-            }
-        } else {
-            tskRun.runSequential();
-        }
-        running.put(tskRes, tskRun);
-        return;
-    }
+				List<Task<? extends Serializable>> children = condTask
+						.getListTasks();
+				for (Task<? extends Serializable> child : children)
+					if (child instanceof MapRedTask)
+						cxt.addToRunnable(child);
+			}
+		} else {
+			tskRun.runSequential();
+		}
+		running.put(tskRes, tskRun);
+		return;
+	}
 
-    /**
-     * Cleans up remaining tasks in case of failure
-     */
+	/**
+	 * Cleans up remaining tasks in case of failure
+	 */
 
-    public void taskCleanup() {
-        // The currently existing Shutdown hooks will be automatically called,
-        // killing the map-reduce processes.
-        // The non MR processes will be killed as well.
-        System.exit(9);
-    }
+	public void taskCleanup() {
+		// The currently existing Shutdown hooks will be automatically called,
+		// killing the map-reduce processes.
+		// The non MR processes will be killed as well.
+		System.exit(9);
+	}
 
-    /**
-     * Polls running tasks to see if a task has ended.
-     * 
-     * @param results
-     *            Set of result objects for running tasks
-     * @return The result object for any completed/failed task
-     */
+	/**
+	 * Polls running tasks to see if a task has ended.
+	 * 
+	 * @param results
+	 *            Set of result objects for running tasks
+	 * @return The result object for any completed/failed task
+	 */
 
-    public TaskResult pollTasks(Set<TaskResult> results) {
-        Iterator<TaskResult> resultIterator = results.iterator();
-        while (true) {
-            while (resultIterator.hasNext()) {
-                TaskResult tskRes = resultIterator.next();
-                if (tskRes.isRunning() == false) {
-                    return tskRes;
-                }
-            }
+	public TaskResult pollTasks(Set<TaskResult> results) {
+		Iterator<TaskResult> resultIterator = results.iterator();
+		while (true) {
+			while (resultIterator.hasNext()) {
+				TaskResult tskRes = resultIterator.next();
+				if (tskRes.isRunning() == false) {
+					return tskRes;
+				}
+			}
 
-            // In this loop, nothing was found
-            // Sleep 10 seconds and restart
-            try {
-                Thread.sleep(sleeptime);
-            } catch (InterruptedException ie) {
-                // Do Nothing
-                ;
-            }
-            resultIterator = results.iterator();
-        }
-    }
+			// In this loop, nothing was found
+			// Sleep 10 seconds and restart
+			try {
+				Thread.sleep(sleeptime);
+			} catch (InterruptedException ie) {
+				// Do Nothing
+				;
+			}
+			resultIterator = results.iterator();
+		}
+	}
 
-    public boolean getResults(ArrayList<String> res) throws IOException {
-        if (plan != null && plan.getFetchTask() != null) {
-            FetchTask ft = plan.getFetchTask();
-            ft.setMaxRows(maxRows);
-            return ft.fetch(res);
-        }
+	public boolean getResults(ArrayList<String> res) throws IOException {
+		if (plan != null && plan.getFetchTask() != null) {
+			FetchTask ft = plan.getFetchTask();
+			ft.setMaxRows(maxRows);
+			return ft.fetch(res);
+		}
 
-        if (resStream == null) {
-            resStream = ctx.getStream();
-        }
-        if (resStream == null) {
-            return false;
-        }
+		if (resStream == null) {
+			resStream = ctx.getStream();
+		}
+		if (resStream == null) {
+			return false;
+		}
 
-        int numRows = 0;
-        String row = null;
+		int numRows = 0;
+		String row = null;
 
-        while (numRows < maxRows) {
-            if (resStream == null) {
-                if (numRows > 0) {
-                    return true;
-                } else {
-                    return false;
-                }
-            }
+		while (numRows < maxRows) {
+			if (resStream == null) {
+				if (numRows > 0) {
+					return true;
+				} else {
+					return false;
+				}
+			}
 
-            bos.reset();
-            Utilities.StreamStatus ss;
-            try {
-                ss = Utilities.readColumn(resStream, bos);
-                if (bos.getCount() > 0) {
-                    row = new String(bos.getData(), 0, bos.getCount(), "UTF-8");
-                } else if (ss == Utilities.StreamStatus.TERMINATED) {
-                    row = new String();
-                }
+			bos.reset();
+			Utilities.StreamStatus ss;
+			try {
+				ss = Utilities.readColumn(resStream, bos);
+				if (bos.getCount() > 0) {
+					row = new String(bos.getData(), 0, bos.getCount(), "UTF-8");
+				} else if (ss == Utilities.StreamStatus.TERMINATED) {
+					row = new String();
+				}
 
-                if (row != null) {
-                    numRows++;
-                    res.add(row);
-                }
-            } catch (IOException e) {
-                console.printError("FAILED: Unexpected IO exception : " + e.getMessage());
-                res = null;
-                return false;
-            }
+				if (row != null) {
+					numRows++;
+					res.add(row);
+				}
+			} catch (IOException e) {
+				console.printError("FAILED: Unexpected IO exception : "
+						+ e.getMessage());
+				res = null;
+				return false;
+			}
 
-            if (ss == Utilities.StreamStatus.EOF) {
-                resStream = ctx.getStream();
-            }
-        }
-        return true;
-    }
+			if (ss == Utilities.StreamStatus.EOF) {
+				resStream = ctx.getStream();
+			}
+		}
+		return true;
+	}
 
-    public int close() {
-        try {
-            if (plan != null) {
-                FetchTask fetchTask = plan.getFetchTask();
-                if (null != fetchTask) {
-                    try {
-                        fetchTask.clearFetch();
-                    } catch (Exception e) {
-                        LOG.debug(" Exception while clearing the Fetch task ", e);
-                    }
-                }
-            }
-            if (ctx != null) {
-                ctx.clear();
-            }
-            if (null != resStream) {
-                try {
-                    ((FSDataInputStream) resStream).close();
-                } catch (Exception e) {
-                    LOG.debug(" Exception while closing the resStream ", e);
-                }
-            }
-        } catch (Exception e) {
-            console.printError("FAILED: Hive Internal Error: " + Utilities.getNameMessage(e) + "\n"
-                    + org.apache.hadoop.util.StringUtils.stringifyException(e));
-            return 13;
-        }
+	public int close() {
+		try {
+			if (plan != null) {
+				FetchTask fetchTask = plan.getFetchTask();
+				if (null != fetchTask) {
+					try {
+						fetchTask.clearFetch();
+					} catch (Exception e) {
+						LOG.debug(" Exception while clearing the Fetch task ",
+								e);
+					}
+				}
+			}
+			if (ctx != null) {
+				ctx.clear();
+			}
+			if (null != resStream) {
+				try {
+					((FSDataInputStream) resStream).close();
+				} catch (Exception e) {
+					LOG.debug(" Exception while closing the resStream ", e);
+				}
+			}
+		} catch (Exception e) {
+			console.printError("FAILED: Hive Internal Error: "
+					+ Utilities.getNameMessage(e) + "\n"
+					+ org.apache.hadoop.util.StringUtils.stringifyException(e));
+			return 13;
+		}
 
-        return 0;
-    }
+		return 0;
+	}
 
-    public void destroy() {
-        releaseLocks();
-    }
+	public void destroy() {
+		releaseLocks();
+	}
 
-    public org.apache.hadoop.hive.ql.plan.api.Query getQueryPlan() throws IOException {
-        return plan.getQueryPlan();
-    }
+	public org.apache.hadoop.hive.ql.plan.api.Query getQueryPlan()
+			throws IOException {
+		return plan.getQueryPlan();
+	}
 
-    public int getTryCount() {
-        return tryCount;
-    }
+	public int getTryCount() {
+		return tryCount;
+	}
 
-    public void setTryCount(int tryCount) {
-        this.tryCount = tryCount;
-    }
+	public void setTryCount(int tryCount) {
+		this.tryCount = tryCount;
+	}
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFAverage.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFAverage.java
index 4a05927..b174432 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFAverage.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFAverage.java
@@ -52,184 +52,202 @@
 @Description(name = "avg", value = "_FUNC_(x) - Returns the mean of a set of numbers")
 public class GenericUDAFAverage extends AbstractGenericUDAFResolver {
 
-    static final Log LOG = LogFactory.getLog(GenericUDAFAverage.class.getName());
+	static final Log LOG = LogFactory
+			.getLog(GenericUDAFAverage.class.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        if (parameters.length != 1) {
-            throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected.");
-        }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		if (parameters.length != 1) {
+			throw new UDFArgumentTypeException(parameters.length - 1,
+					"Exactly one argument is expected.");
+		}
 
-        if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
-                    + parameters[0].getTypeName() + " is passed.");
-        }
-        switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
-            case BYTE:
-            case SHORT:
-            case INT:
-            case LONG:
-            case FLOAT:
-            case DOUBLE:
-            case STRING:
-                return new GenericUDAFAverageEvaluator();
-            case BOOLEAN:
-            default:
-                throw new UDFArgumentTypeException(0, "Only numeric or string type arguments are accepted but "
-                        + parameters[0].getTypeName() + " is passed.");
-        }
-    }
+		if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(0,
+					"Only primitive type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+		switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
+		case BYTE:
+		case SHORT:
+		case INT:
+		case LONG:
+		case FLOAT:
+		case DOUBLE:
+		case STRING:
+			return new GenericUDAFAverageEvaluator();
+		case BOOLEAN:
+		default:
+			throw new UDFArgumentTypeException(0,
+					"Only numeric or string type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+	}
 
-    /**
-     * GenericUDAFAverageEvaluator.
-     * 
-     */
-    public static class GenericUDAFAverageEvaluator extends GenericUDAFEvaluator {
+	/**
+	 * GenericUDAFAverageEvaluator.
+	 * 
+	 */
+	public static class GenericUDAFAverageEvaluator extends
+			GenericUDAFEvaluator {
 
-        // For PARTIAL1 and COMPLETE
-        PrimitiveObjectInspector inputOI;
+		// For PARTIAL1 and COMPLETE
+		PrimitiveObjectInspector inputOI;
 
-        // For PARTIAL2 and FINAL
-        StructObjectInspector soi;
-        StructField countField;
-        StructField sumField;
-        LongObjectInspector countFieldOI;
-        DoubleObjectInspector sumFieldOI;
+		// For PARTIAL2 and FINAL
+		StructObjectInspector soi;
+		StructField countField;
+		StructField sumField;
+		LongObjectInspector countFieldOI;
+		DoubleObjectInspector sumFieldOI;
 
-        // For PARTIAL1 and PARTIAL2
-        Object[] partialResult;
+		// For PARTIAL1 and PARTIAL2
+		Object[] partialResult;
 
-        // For FINAL and COMPLETE
-        DoubleWritable result;
+		// For FINAL and COMPLETE
+		DoubleWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            super.init(m, parameters);
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			super.init(m, parameters);
 
-            // init input
-            if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
-                inputOI = (PrimitiveObjectInspector) parameters[0];
-            } else {
-                soi = (StructObjectInspector) parameters[0];
-                countField = soi.getStructFieldRef("count");
-                sumField = soi.getStructFieldRef("sum");
-                countFieldOI = (LongObjectInspector) countField.getFieldObjectInspector();
-                sumFieldOI = (DoubleObjectInspector) sumField.getFieldObjectInspector();
-            }
+			// init input
+			if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+				inputOI = (PrimitiveObjectInspector) parameters[0];
+			} else {
+				soi = (StructObjectInspector) parameters[0];
+				countField = soi.getStructFieldRef("count");
+				sumField = soi.getStructFieldRef("sum");
+				countFieldOI = (LongObjectInspector) countField
+						.getFieldObjectInspector();
+				sumFieldOI = (DoubleObjectInspector) sumField
+						.getFieldObjectInspector();
+			}
 
-            // init output
-            if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
-                // The output of a partial aggregation is a struct containing
-                // a "long" count and a "double" sum.
+			// init output
+			if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
+				// The output of a partial aggregation is a struct containing
+				// a "long" count and a "double" sum.
 
-                ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
-                foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                ArrayList<String> fname = new ArrayList<String>();
-                fname.add("count");
-                fname.add("sum");
-                partialResult = new Object[2];
-                partialResult[0] = new LongWritable(0);
-                partialResult[1] = new DoubleWritable(0);
-                return ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi);
+				ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
+				foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				ArrayList<String> fname = new ArrayList<String>();
+				fname.add("count");
+				fname.add("sum");
+				partialResult = new Object[2];
+				partialResult[0] = new LongWritable(0);
+				partialResult[1] = new DoubleWritable(0);
+				return ObjectInspectorFactory.getStandardStructObjectInspector(
+						fname, foi);
 
-            } else {
-                result = new DoubleWritable(0);
-                return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
-            }
-        }
+			} else {
+				result = new DoubleWritable(0);
+				return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+			}
+		}
 
-        static class AverageAgg implements SerializableBuffer {
-            long count;
-            double sum;
+		static class AverageAgg implements SerializableBuffer {
+			long count;
+			double sum;
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                count = BufferSerDeUtil.getLong(data, start);
-                start += 8;
-                sum = BufferSerDeUtil.getDouble(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				count = BufferSerDeUtil.getLong(data, start);
+				start += 8;
+				sum = BufferSerDeUtil.getDouble(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeLong(count, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(sum, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeLong(count, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(sum, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeLong(count);
-                output.writeDouble(sum);
-            }
-        };
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeLong(count);
+				output.writeDouble(sum);
+			}
+		};
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            AverageAgg result = new AverageAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			AverageAgg result = new AverageAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            AverageAgg myagg = (AverageAgg) agg;
-            myagg.count = 0;
-            myagg.sum = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			AverageAgg myagg = (AverageAgg) agg;
+			myagg.count = 0;
+			myagg.sum = 0;
+		}
 
-        boolean warned = false;
+		boolean warned = false;
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            Object p = parameters[0];
-            if (p != null) {
-                AverageAgg myagg = (AverageAgg) agg;
-                try {
-                    double v = PrimitiveObjectInspectorUtils.getDouble(p, inputOI);
-                    myagg.count++;
-                    myagg.sum += v;
-                } catch (NumberFormatException e) {
-                    if (!warned) {
-                        warned = true;
-                        LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e));
-                        LOG.warn(getClass().getSimpleName() + " ignoring similar exceptions.");
-                    }
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			Object p = parameters[0];
+			if (p != null) {
+				AverageAgg myagg = (AverageAgg) agg;
+				try {
+					double v = PrimitiveObjectInspectorUtils.getDouble(p,
+							inputOI);
+					myagg.count++;
+					myagg.sum += v;
+				} catch (NumberFormatException e) {
+					if (!warned) {
+						warned = true;
+						LOG.warn(getClass().getSimpleName() + " "
+								+ StringUtils.stringifyException(e));
+						LOG.warn(getClass().getSimpleName()
+								+ " ignoring similar exceptions.");
+					}
+				}
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            AverageAgg myagg = (AverageAgg) agg;
-            ((LongWritable) partialResult[0]).set(myagg.count);
-            ((DoubleWritable) partialResult[1]).set(myagg.sum);
-            return partialResult;
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			AverageAgg myagg = (AverageAgg) agg;
+			((LongWritable) partialResult[0]).set(myagg.count);
+			((DoubleWritable) partialResult[1]).set(myagg.sum);
+			return partialResult;
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                AverageAgg myagg = (AverageAgg) agg;
-                Object partialCount = soi.getStructFieldData(partial, countField);
-                Object partialSum = soi.getStructFieldData(partial, sumField);
-                myagg.count += countFieldOI.get(partialCount);
-                myagg.sum += sumFieldOI.get(partialSum);
-            }
-        }
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				AverageAgg myagg = (AverageAgg) agg;
+				Object partialCount = soi.getStructFieldData(partial,
+						countField);
+				Object partialSum = soi.getStructFieldData(partial, sumField);
+				myagg.count += countFieldOI.get(partialCount);
+				myagg.sum += sumFieldOI.get(partialSum);
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            AverageAgg myagg = (AverageAgg) agg;
-            if (myagg.count == 0) {
-                return null;
-            } else {
-                result.set(myagg.sum / myagg.count);
-                return result;
-            }
-        }
-    }
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			AverageAgg myagg = (AverageAgg) agg;
+			if (myagg.count == 0) {
+				return null;
+			} else {
+				result.set(myagg.sum / myagg.count);
+				return result;
+			}
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCorrelation.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCorrelation.java
index 6652afc..716faac 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCorrelation.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCorrelation.java
@@ -63,336 +63,366 @@
  * 
  */
 @Description(name = "corr", value = "_FUNC_(x,y) - Returns the Pearson coefficient of correlation\n"
-        + "between a set of number pairs", extended = "The function takes as arguments any pair of numeric types and returns a double.\n"
-        + "Any pair with a NULL is ignored. If the function is applied to an empty set or\n"
-        + "a singleton set, NULL will be returned. Otherwise, it computes the following:\n"
-        + "   COVAR_POP(x,y)/(STDDEV_POP(x)*STDDEV_POP(y))\n"
-        + "where neither x nor y is null,\n"
-        + "COVAR_POP is the population covariance,\n" + "and STDDEV_POP is the population standard deviation.")
+		+ "between a set of number pairs", extended = "The function takes as arguments any pair of numeric types and returns a double.\n"
+		+ "Any pair with a NULL is ignored. If the function is applied to an empty set or\n"
+		+ "a singleton set, NULL will be returned. Otherwise, it computes the following:\n"
+		+ "   COVAR_POP(x,y)/(STDDEV_POP(x)*STDDEV_POP(y))\n"
+		+ "where neither x nor y is null,\n"
+		+ "COVAR_POP is the population covariance,\n"
+		+ "and STDDEV_POP is the population standard deviation.")
 public class GenericUDAFCorrelation extends AbstractGenericUDAFResolver {
 
-    static final Log LOG = LogFactory.getLog(GenericUDAFCorrelation.class.getName());
+	static final Log LOG = LogFactory.getLog(GenericUDAFCorrelation.class
+			.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        if (parameters.length != 2) {
-            throw new UDFArgumentTypeException(parameters.length - 1, "Exactly two arguments are expected.");
-        }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		if (parameters.length != 2) {
+			throw new UDFArgumentTypeException(parameters.length - 1,
+					"Exactly two arguments are expected.");
+		}
 
-        if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
-                    + parameters[0].getTypeName() + " is passed.");
-        }
+		if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(0,
+					"Only primitive type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
 
-        if (parameters[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(1, "Only primitive type arguments are accepted but "
-                    + parameters[1].getTypeName() + " is passed.");
-        }
+		if (parameters[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(1,
+					"Only primitive type arguments are accepted but "
+							+ parameters[1].getTypeName() + " is passed.");
+		}
 
-        switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
-            case BYTE:
-            case SHORT:
-            case INT:
-            case LONG:
-            case FLOAT:
-            case DOUBLE:
-                switch (((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory()) {
-                    case BYTE:
-                    case SHORT:
-                    case INT:
-                    case LONG:
-                    case FLOAT:
-                    case DOUBLE:
-                        return new GenericUDAFCorrelationEvaluator();
-                    case STRING:
-                    case BOOLEAN:
-                    default:
-                        throw new UDFArgumentTypeException(1, "Only numeric type arguments are accepted but "
-                                + parameters[1].getTypeName() + " is passed.");
-                }
-            case STRING:
-            case BOOLEAN:
-            default:
-                throw new UDFArgumentTypeException(0, "Only numeric type arguments are accepted but "
-                        + parameters[0].getTypeName() + " is passed.");
-        }
-    }
+		switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
+		case BYTE:
+		case SHORT:
+		case INT:
+		case LONG:
+		case FLOAT:
+		case DOUBLE:
+			switch (((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory()) {
+			case BYTE:
+			case SHORT:
+			case INT:
+			case LONG:
+			case FLOAT:
+			case DOUBLE:
+				return new GenericUDAFCorrelationEvaluator();
+			case STRING:
+			case BOOLEAN:
+			default:
+				throw new UDFArgumentTypeException(1,
+						"Only numeric type arguments are accepted but "
+								+ parameters[1].getTypeName() + " is passed.");
+			}
+		case STRING:
+		case BOOLEAN:
+		default:
+			throw new UDFArgumentTypeException(0,
+					"Only numeric type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+	}
 
-    /**
-     * Evaluate the Pearson correlation coefficient using a stable one-pass
-     * algorithm, based on work by Philippe Pébay and Donald Knuth.
-     * 
-     * Incremental: n : <count> mx_n = mx_(n-1) + [x_n - mx_(n-1)]/n : <xavg>
-     * my_n = my_(n-1) + [y_n - my_(n-1)]/n : <yavg> c_n = c_(n-1) + (x_n -
-     * mx_(n-1))*(y_n - my_n) : <covariance * n> vx_n = vx_(n-1) + (x_n -
-     * mx_n)(x_n - mx_(n-1)): <variance * n> vy_n = vy_(n-1) + (y_n - my_n)(y_n
-     * - my_(n-1)): <variance * n>
-     * 
-     * Merge: c_X = c_A + c_B + (mx_A - mx_B)*(my_A - my_B)*n_A*n_B/n_X vx_(A,B)
-     * = vx_A + vx_B + (mx_A - mx_B)*(mx_A - mx_B)*n_A*n_B/(n_A+n_B) vy_(A,B) =
-     * vy_A + vy_B + (my_A - my_B)*(my_A - my_B)*n_A*n_B/(n_A+n_B)
-     * 
-     */
-    public static class GenericUDAFCorrelationEvaluator extends GenericUDAFEvaluator {
+	/**
+	 * Evaluate the Pearson correlation coefficient using a stable one-pass
+	 * algorithm, based on work by Philippe Pébay and Donald Knuth.
+	 * 
+	 * Incremental: n : <count> mx_n = mx_(n-1) + [x_n - mx_(n-1)]/n : <xavg>
+	 * my_n = my_(n-1) + [y_n - my_(n-1)]/n : <yavg> c_n = c_(n-1) + (x_n -
+	 * mx_(n-1))*(y_n - my_n) : <covariance * n> vx_n = vx_(n-1) + (x_n -
+	 * mx_n)(x_n - mx_(n-1)): <variance * n> vy_n = vy_(n-1) + (y_n - my_n)(y_n
+	 * - my_(n-1)): <variance * n>
+	 * 
+	 * Merge: c_X = c_A + c_B + (mx_A - mx_B)*(my_A - my_B)*n_A*n_B/n_X vx_(A,B)
+	 * = vx_A + vx_B + (mx_A - mx_B)*(mx_A - mx_B)*n_A*n_B/(n_A+n_B) vy_(A,B) =
+	 * vy_A + vy_B + (my_A - my_B)*(my_A - my_B)*n_A*n_B/(n_A+n_B)
+	 * 
+	 */
+	public static class GenericUDAFCorrelationEvaluator extends
+			GenericUDAFEvaluator {
 
-        // For PARTIAL1 and COMPLETE
-        private PrimitiveObjectInspector xInputOI;
-        private PrimitiveObjectInspector yInputOI;
+		// For PARTIAL1 and COMPLETE
+		private PrimitiveObjectInspector xInputOI;
+		private PrimitiveObjectInspector yInputOI;
 
-        // For PARTIAL2 and FINAL
-        private StructObjectInspector soi;
-        private StructField countField;
-        private StructField xavgField;
-        private StructField yavgField;
-        private StructField xvarField;
-        private StructField yvarField;
-        private StructField covarField;
-        private LongObjectInspector countFieldOI;
-        private DoubleObjectInspector xavgFieldOI;
-        private DoubleObjectInspector yavgFieldOI;
-        private DoubleObjectInspector xvarFieldOI;
-        private DoubleObjectInspector yvarFieldOI;
-        private DoubleObjectInspector covarFieldOI;
+		// For PARTIAL2 and FINAL
+		private StructObjectInspector soi;
+		private StructField countField;
+		private StructField xavgField;
+		private StructField yavgField;
+		private StructField xvarField;
+		private StructField yvarField;
+		private StructField covarField;
+		private LongObjectInspector countFieldOI;
+		private DoubleObjectInspector xavgFieldOI;
+		private DoubleObjectInspector yavgFieldOI;
+		private DoubleObjectInspector xvarFieldOI;
+		private DoubleObjectInspector yvarFieldOI;
+		private DoubleObjectInspector covarFieldOI;
 
-        // For PARTIAL1 and PARTIAL2
-        private Object[] partialResult;
+		// For PARTIAL1 and PARTIAL2
+		private Object[] partialResult;
 
-        // For FINAL and COMPLETE
-        private DoubleWritable result;
+		// For FINAL and COMPLETE
+		private DoubleWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            super.init(m, parameters);
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			super.init(m, parameters);
 
-            // init input
-            if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
-                assert (parameters.length == 2);
-                xInputOI = (PrimitiveObjectInspector) parameters[0];
-                yInputOI = (PrimitiveObjectInspector) parameters[1];
-            } else {
-                assert (parameters.length == 1);
-                soi = (StructObjectInspector) parameters[0];
+			// init input
+			if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+				assert (parameters.length == 2);
+				xInputOI = (PrimitiveObjectInspector) parameters[0];
+				yInputOI = (PrimitiveObjectInspector) parameters[1];
+			} else {
+				assert (parameters.length == 1);
+				soi = (StructObjectInspector) parameters[0];
 
-                countField = soi.getStructFieldRef("count");
-                xavgField = soi.getStructFieldRef("xavg");
-                yavgField = soi.getStructFieldRef("yavg");
-                xvarField = soi.getStructFieldRef("xvar");
-                yvarField = soi.getStructFieldRef("yvar");
-                covarField = soi.getStructFieldRef("covar");
+				countField = soi.getStructFieldRef("count");
+				xavgField = soi.getStructFieldRef("xavg");
+				yavgField = soi.getStructFieldRef("yavg");
+				xvarField = soi.getStructFieldRef("xvar");
+				yvarField = soi.getStructFieldRef("yvar");
+				covarField = soi.getStructFieldRef("covar");
 
-                countFieldOI = (LongObjectInspector) countField.getFieldObjectInspector();
-                xavgFieldOI = (DoubleObjectInspector) xavgField.getFieldObjectInspector();
-                yavgFieldOI = (DoubleObjectInspector) yavgField.getFieldObjectInspector();
-                xvarFieldOI = (DoubleObjectInspector) xvarField.getFieldObjectInspector();
-                yvarFieldOI = (DoubleObjectInspector) yvarField.getFieldObjectInspector();
-                covarFieldOI = (DoubleObjectInspector) covarField.getFieldObjectInspector();
-            }
+				countFieldOI = (LongObjectInspector) countField
+						.getFieldObjectInspector();
+				xavgFieldOI = (DoubleObjectInspector) xavgField
+						.getFieldObjectInspector();
+				yavgFieldOI = (DoubleObjectInspector) yavgField
+						.getFieldObjectInspector();
+				xvarFieldOI = (DoubleObjectInspector) xvarField
+						.getFieldObjectInspector();
+				yvarFieldOI = (DoubleObjectInspector) yvarField
+						.getFieldObjectInspector();
+				covarFieldOI = (DoubleObjectInspector) covarField
+						.getFieldObjectInspector();
+			}
 
-            // init output
-            if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
-                // The output of a partial aggregation is a struct containing
-                // a long count, two double averages, two double variances,
-                // and a double covariance.
+			// init output
+			if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
+				// The output of a partial aggregation is a struct containing
+				// a long count, two double averages, two double variances,
+				// and a double covariance.
 
-                ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
+				ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
 
-                foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
 
-                ArrayList<String> fname = new ArrayList<String>();
-                fname.add("count");
-                fname.add("xavg");
-                fname.add("yavg");
-                fname.add("xvar");
-                fname.add("yvar");
-                fname.add("covar");
+				ArrayList<String> fname = new ArrayList<String>();
+				fname.add("count");
+				fname.add("xavg");
+				fname.add("yavg");
+				fname.add("xvar");
+				fname.add("yvar");
+				fname.add("covar");
 
-                partialResult = new Object[6];
-                partialResult[0] = new LongWritable(0);
-                partialResult[1] = new DoubleWritable(0);
-                partialResult[2] = new DoubleWritable(0);
-                partialResult[3] = new DoubleWritable(0);
-                partialResult[4] = new DoubleWritable(0);
-                partialResult[5] = new DoubleWritable(0);
+				partialResult = new Object[6];
+				partialResult[0] = new LongWritable(0);
+				partialResult[1] = new DoubleWritable(0);
+				partialResult[2] = new DoubleWritable(0);
+				partialResult[3] = new DoubleWritable(0);
+				partialResult[4] = new DoubleWritable(0);
+				partialResult[5] = new DoubleWritable(0);
 
-                return ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi);
+				return ObjectInspectorFactory.getStandardStructObjectInspector(
+						fname, foi);
 
-            } else {
-                setResult(new DoubleWritable(0));
-                return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
-            }
-        }
+			} else {
+				setResult(new DoubleWritable(0));
+				return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+			}
+		}
 
-        static class StdAgg implements SerializableBuffer {
-            long count; // number n of elements
-            double xavg; // average of x elements
-            double yavg; // average of y elements
-            double xvar; // n times the variance of x elements
-            double yvar; // n times the variance of y elements
-            double covar; // n times the covariance
+		static class StdAgg implements SerializableBuffer {
+			long count; // number n of elements
+			double xavg; // average of x elements
+			double yavg; // average of y elements
+			double xvar; // n times the variance of x elements
+			double yvar; // n times the variance of y elements
+			double covar; // n times the covariance
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                count = BufferSerDeUtil.getLong(data, start);
-                start += 8;
-                xavg = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                yavg = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                xvar = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                yvar = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                covar = BufferSerDeUtil.getDouble(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				count = BufferSerDeUtil.getLong(data, start);
+				start += 8;
+				xavg = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				yavg = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				xvar = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				yvar = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				covar = BufferSerDeUtil.getDouble(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeLong(count, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(xavg, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(yavg, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(xvar, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(yvar, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(covar, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeLong(count, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(xavg, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(yavg, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(xvar, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(yvar, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(covar, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeLong(count);
-                output.writeDouble(xavg);
-                output.writeDouble(yavg);
-                output.writeDouble(xvar);
-                output.writeDouble(yvar);
-                output.writeDouble(covar);
-            }
-        };
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeLong(count);
+				output.writeDouble(xavg);
+				output.writeDouble(yavg);
+				output.writeDouble(xvar);
+				output.writeDouble(yvar);
+				output.writeDouble(covar);
+			}
+		};
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            StdAgg result = new StdAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			StdAgg result = new StdAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            myagg.count = 0;
-            myagg.xavg = 0;
-            myagg.yavg = 0;
-            myagg.xvar = 0;
-            myagg.yvar = 0;
-            myagg.covar = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			myagg.count = 0;
+			myagg.xavg = 0;
+			myagg.yavg = 0;
+			myagg.xvar = 0;
+			myagg.yvar = 0;
+			myagg.covar = 0;
+		}
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 2);
-            Object px = parameters[0];
-            Object py = parameters[1];
-            if (px != null && py != null) {
-                StdAgg myagg = (StdAgg) agg;
-                double vx = PrimitiveObjectInspectorUtils.getDouble(px, xInputOI);
-                double vy = PrimitiveObjectInspectorUtils.getDouble(py, yInputOI);
-                double xavgOld = myagg.xavg;
-                double yavgOld = myagg.yavg;
-                myagg.count++;
-                myagg.xavg += (vx - xavgOld) / myagg.count;
-                myagg.yavg += (vy - yavgOld) / myagg.count;
-                if (myagg.count > 1) {
-                    myagg.covar += (vx - xavgOld) * (vy - myagg.yavg);
-                    myagg.xvar += (vx - xavgOld) * (vx - myagg.xavg);
-                    myagg.yvar += (vy - yavgOld) * (vy - myagg.yavg);
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 2);
+			Object px = parameters[0];
+			Object py = parameters[1];
+			if (px != null && py != null) {
+				StdAgg myagg = (StdAgg) agg;
+				double vx = PrimitiveObjectInspectorUtils.getDouble(px,
+						xInputOI);
+				double vy = PrimitiveObjectInspectorUtils.getDouble(py,
+						yInputOI);
+				double xavgOld = myagg.xavg;
+				double yavgOld = myagg.yavg;
+				myagg.count++;
+				myagg.xavg += (vx - xavgOld) / myagg.count;
+				myagg.yavg += (vy - yavgOld) / myagg.count;
+				if (myagg.count > 1) {
+					myagg.covar += (vx - xavgOld) * (vy - myagg.yavg);
+					myagg.xvar += (vx - xavgOld) * (vx - myagg.xavg);
+					myagg.yvar += (vy - yavgOld) * (vy - myagg.yavg);
+				}
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            ((LongWritable) partialResult[0]).set(myagg.count);
-            ((DoubleWritable) partialResult[1]).set(myagg.xavg);
-            ((DoubleWritable) partialResult[2]).set(myagg.yavg);
-            ((DoubleWritable) partialResult[3]).set(myagg.xvar);
-            ((DoubleWritable) partialResult[4]).set(myagg.yvar);
-            ((DoubleWritable) partialResult[5]).set(myagg.covar);
-            return partialResult;
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			((LongWritable) partialResult[0]).set(myagg.count);
+			((DoubleWritable) partialResult[1]).set(myagg.xavg);
+			((DoubleWritable) partialResult[2]).set(myagg.yavg);
+			((DoubleWritable) partialResult[3]).set(myagg.xvar);
+			((DoubleWritable) partialResult[4]).set(myagg.yvar);
+			((DoubleWritable) partialResult[5]).set(myagg.covar);
+			return partialResult;
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                StdAgg myagg = (StdAgg) agg;
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				StdAgg myagg = (StdAgg) agg;
 
-                Object partialCount = soi.getStructFieldData(partial, countField);
-                Object partialXAvg = soi.getStructFieldData(partial, xavgField);
-                Object partialYAvg = soi.getStructFieldData(partial, yavgField);
-                Object partialXVar = soi.getStructFieldData(partial, xvarField);
-                Object partialYVar = soi.getStructFieldData(partial, yvarField);
-                Object partialCovar = soi.getStructFieldData(partial, covarField);
+				Object partialCount = soi.getStructFieldData(partial,
+						countField);
+				Object partialXAvg = soi.getStructFieldData(partial, xavgField);
+				Object partialYAvg = soi.getStructFieldData(partial, yavgField);
+				Object partialXVar = soi.getStructFieldData(partial, xvarField);
+				Object partialYVar = soi.getStructFieldData(partial, yvarField);
+				Object partialCovar = soi.getStructFieldData(partial,
+						covarField);
 
-                long nA = myagg.count;
-                long nB = countFieldOI.get(partialCount);
+				long nA = myagg.count;
+				long nB = countFieldOI.get(partialCount);
 
-                if (nA == 0) {
-                    // Just copy the information since there is nothing so far
-                    myagg.count = countFieldOI.get(partialCount);
-                    myagg.xavg = xavgFieldOI.get(partialXAvg);
-                    myagg.yavg = yavgFieldOI.get(partialYAvg);
-                    myagg.xvar = xvarFieldOI.get(partialXVar);
-                    myagg.yvar = yvarFieldOI.get(partialYVar);
-                    myagg.covar = covarFieldOI.get(partialCovar);
-                }
+				if (nA == 0) {
+					// Just copy the information since there is nothing so far
+					myagg.count = countFieldOI.get(partialCount);
+					myagg.xavg = xavgFieldOI.get(partialXAvg);
+					myagg.yavg = yavgFieldOI.get(partialYAvg);
+					myagg.xvar = xvarFieldOI.get(partialXVar);
+					myagg.yvar = yvarFieldOI.get(partialYVar);
+					myagg.covar = covarFieldOI.get(partialCovar);
+				}
 
-                if (nA != 0 && nB != 0) {
-                    // Merge the two partials
-                    double xavgA = myagg.xavg;
-                    double yavgA = myagg.yavg;
-                    double xavgB = xavgFieldOI.get(partialXAvg);
-                    double yavgB = yavgFieldOI.get(partialYAvg);
-                    double xvarB = xvarFieldOI.get(partialXVar);
-                    double yvarB = yvarFieldOI.get(partialYVar);
-                    double covarB = covarFieldOI.get(partialCovar);
+				if (nA != 0 && nB != 0) {
+					// Merge the two partials
+					double xavgA = myagg.xavg;
+					double yavgA = myagg.yavg;
+					double xavgB = xavgFieldOI.get(partialXAvg);
+					double yavgB = yavgFieldOI.get(partialYAvg);
+					double xvarB = xvarFieldOI.get(partialXVar);
+					double yvarB = yvarFieldOI.get(partialYVar);
+					double covarB = covarFieldOI.get(partialCovar);
 
-                    myagg.count += nB;
-                    myagg.xavg = (xavgA * nA + xavgB * nB) / myagg.count;
-                    myagg.yavg = (yavgA * nA + yavgB * nB) / myagg.count;
-                    myagg.xvar += xvarB + (xavgA - xavgB) * (xavgA - xavgB) * myagg.count;
-                    myagg.yvar += yvarB + (yavgA - yavgB) * (yavgA - yavgB) * myagg.count;
-                    myagg.covar += covarB + (xavgA - xavgB) * (yavgA - yavgB) * ((double) (nA * nB) / myagg.count);
-                }
-            }
-        }
+					myagg.count += nB;
+					myagg.xavg = (xavgA * nA + xavgB * nB) / myagg.count;
+					myagg.yavg = (yavgA * nA + yavgB * nB) / myagg.count;
+					myagg.xvar += xvarB + (xavgA - xavgB) * (xavgA - xavgB)
+							* myagg.count;
+					myagg.yvar += yvarB + (yavgA - yavgB) * (yavgA - yavgB)
+							* myagg.count;
+					myagg.covar += covarB + (xavgA - xavgB) * (yavgA - yavgB)
+							* ((double) (nA * nB) / myagg.count);
+				}
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
 
-            if (myagg.count < 2) { // SQL standard - return null for zero or one
-                                   // pair
-                return null;
-            } else {
-                getResult().set(myagg.covar / java.lang.Math.sqrt(myagg.xvar) / java.lang.Math.sqrt(myagg.yvar));
-                return getResult();
-            }
-        }
+			if (myagg.count < 2) { // SQL standard - return null for zero or one
+									// pair
+				return null;
+			} else {
+				getResult().set(
+						myagg.covar / java.lang.Math.sqrt(myagg.xvar)
+								/ java.lang.Math.sqrt(myagg.yvar));
+				return getResult();
+			}
+		}
 
-        public void setResult(DoubleWritable result) {
-            this.result = result;
-        }
+		public void setResult(DoubleWritable result) {
+			this.result = result;
+		}
 
-        public DoubleWritable getResult() {
-            return result;
-        }
-    }
+		public DoubleWritable getResult() {
+			return result;
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCount.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCount.java
index e4081f5..c2758bc 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCount.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCount.java
@@ -39,137 +39,149 @@
  * This class implements the COUNT aggregation function as in SQL.
  */
 @Description(name = "count", value = "_FUNC_(*) - Returns the total number of retrieved rows, including "
-        + "rows containing NULL values.\n"
+		+ "rows containing NULL values.\n"
 
-        + "_FUNC_(expr) - Returns the number of rows for which the supplied " + "expression is non-NULL.\n"
+		+ "_FUNC_(expr) - Returns the number of rows for which the supplied "
+		+ "expression is non-NULL.\n"
 
-        + "_FUNC_(DISTINCT expr[, expr...]) - Returns the number of rows for "
-        + "which the supplied expression(s) are unique and non-NULL.")
+		+ "_FUNC_(DISTINCT expr[, expr...]) - Returns the number of rows for "
+		+ "which the supplied expression(s) are unique and non-NULL.")
 public class GenericUDAFCount implements GenericUDAFResolver2 {
 
-    private static final Log LOG = LogFactory.getLog(GenericUDAFCount.class.getName());
+	private static final Log LOG = LogFactory.getLog(GenericUDAFCount.class
+			.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        // This method implementation is preserved for backward compatibility.
-        return new GenericUDAFCountEvaluator();
-    }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		// This method implementation is preserved for backward compatibility.
+		return new GenericUDAFCountEvaluator();
+	}
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo) throws SemanticException {
+	@Override
+	public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo paramInfo)
+			throws SemanticException {
 
-        TypeInfo[] parameters = paramInfo.getParameters();
+		TypeInfo[] parameters = paramInfo.getParameters();
 
-        if (parameters.length == 0) {
-            if (!paramInfo.isAllColumns()) {
-                throw new UDFArgumentException("Argument expected");
-            }
-            assert !paramInfo.isDistinct() : "DISTINCT not supported with *";
-        } else {
-            if (parameters.length > 1 && !paramInfo.isDistinct()) {
-                throw new UDFArgumentException("DISTINCT keyword must be specified");
-            }
-            assert !paramInfo.isAllColumns() : "* not supported in expression list";
-        }
+		if (parameters.length == 0) {
+			if (!paramInfo.isAllColumns()) {
+				throw new UDFArgumentException("Argument expected");
+			}
+			assert !paramInfo.isDistinct() : "DISTINCT not supported with *";
+		} else {
+			if (parameters.length > 1 && !paramInfo.isDistinct()) {
+				throw new UDFArgumentException(
+						"DISTINCT keyword must be specified");
+			}
+			assert !paramInfo.isAllColumns() : "* not supported in expression list";
+		}
 
-        return new GenericUDAFCountEvaluator().setCountAllColumns(paramInfo.isAllColumns());
-    }
+		return new GenericUDAFCountEvaluator().setCountAllColumns(paramInfo
+				.isAllColumns());
+	}
 
-    /**
-     * GenericUDAFCountEvaluator.
-     * 
-     */
-    public static class GenericUDAFCountEvaluator extends GenericUDAFEvaluator {
-        private boolean countAllColumns = false;
-        private LongObjectInspector partialCountAggOI;
-        private LongWritable result;
+	/**
+	 * GenericUDAFCountEvaluator.
+	 * 
+	 */
+	public static class GenericUDAFCountEvaluator extends GenericUDAFEvaluator {
+		private boolean countAllColumns = false;
+		private LongObjectInspector partialCountAggOI;
+		private LongWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            super.init(m, parameters);
-            partialCountAggOI = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
-            result = new LongWritable(0);
-            return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
-        }
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			super.init(m, parameters);
+			partialCountAggOI = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
+			result = new LongWritable(0);
+			return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
+		}
 
-        private GenericUDAFCountEvaluator setCountAllColumns(boolean countAllCols) {
-            countAllColumns = countAllCols;
-            return this;
-        }
+		private GenericUDAFCountEvaluator setCountAllColumns(
+				boolean countAllCols) {
+			countAllColumns = countAllCols;
+			return this;
+		}
 
-        /** class for storing count value. */
-        static class CountAgg implements SerializableBuffer {
-            long value;
+		/** class for storing count value. */
+		static class CountAgg implements SerializableBuffer {
+			long value;
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                value = BufferSerDeUtil.getLong(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				value = BufferSerDeUtil.getLong(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeLong(value, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeLong(value, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeLong(value);
-            }
-        }
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeLong(value);
+			}
+		}
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            CountAgg buffer = new CountAgg();
-            reset(buffer);
-            return buffer;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			CountAgg buffer = new CountAgg();
+			reset(buffer);
+			return buffer;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            ((CountAgg) agg).value = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			((CountAgg) agg).value = 0;
+		}
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            // parameters == null means the input table/split is empty
-            if (parameters == null) {
-                return;
-            }
-            if (countAllColumns) {
-                assert parameters.length == 0;
-                ((CountAgg) agg).value++;
-            } else {
-                assert parameters.length > 0;
-                boolean countThisRow = true;
-                for (Object nextParam : parameters) {
-                    if (nextParam == null) {
-                        countThisRow = false;
-                        break;
-                    }
-                }
-                if (countThisRow) {
-                    ((CountAgg) agg).value++;
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			// parameters == null means the input table/split is empty
+			if (parameters == null) {
+				return;
+			}
+			if (countAllColumns) {
+				assert parameters.length == 0;
+				((CountAgg) agg).value++;
+			} else {
+				assert parameters.length > 0;
+				boolean countThisRow = true;
+				for (Object nextParam : parameters) {
+					if (nextParam == null) {
+						countThisRow = false;
+						break;
+					}
+				}
+				if (countThisRow) {
+					((CountAgg) agg).value++;
+				}
+			}
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                long p = partialCountAggOI.get(partial);
-                ((CountAgg) agg).value += p;
-            }
-        }
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				long p = partialCountAggOI.get(partial);
+				((CountAgg) agg).value += p;
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            result.set(((CountAgg) agg).value);
-            return result;
-        }
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			result.set(((CountAgg) agg).value);
+			return result;
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            return terminate(agg);
-        }
-    }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			return terminate(agg);
+		}
+	}
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCovariance.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCovariance.java
index 0453c3b..b844a22 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCovariance.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFCovariance.java
@@ -57,294 +57,318 @@
  * 
  */
 @Description(name = "covariance,covar_pop", value = "_FUNC_(x,y) - Returns the population covariance of a set of number pairs", extended = "The function takes as arguments any pair of numeric types and returns a double.\n"
-        + "Any pair with a NULL is ignored. If the function is applied to an empty set, NULL\n"
-        + "will be returned. Otherwise, it computes the following:\n"
-        + "   (SUM(x*y)-SUM(x)*SUM(y)/COUNT(x,y))/COUNT(x,y)\n" + "where neither x nor y is null.")
+		+ "Any pair with a NULL is ignored. If the function is applied to an empty set, NULL\n"
+		+ "will be returned. Otherwise, it computes the following:\n"
+		+ "   (SUM(x*y)-SUM(x)*SUM(y)/COUNT(x,y))/COUNT(x,y)\n"
+		+ "where neither x nor y is null.")
 public class GenericUDAFCovariance extends AbstractGenericUDAFResolver {
 
-    static final Log LOG = LogFactory.getLog(GenericUDAFCovariance.class.getName());
+	static final Log LOG = LogFactory.getLog(GenericUDAFCovariance.class
+			.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        if (parameters.length != 2) {
-            throw new UDFArgumentTypeException(parameters.length - 1, "Exactly two arguments are expected.");
-        }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		if (parameters.length != 2) {
+			throw new UDFArgumentTypeException(parameters.length - 1,
+					"Exactly two arguments are expected.");
+		}
 
-        if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
-                    + parameters[0].getTypeName() + " is passed.");
-        }
+		if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(0,
+					"Only primitive type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
 
-        if (parameters[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(1, "Only primitive type arguments are accepted but "
-                    + parameters[1].getTypeName() + " is passed.");
-        }
+		if (parameters[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(1,
+					"Only primitive type arguments are accepted but "
+							+ parameters[1].getTypeName() + " is passed.");
+		}
 
-        switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
-            case BYTE:
-            case SHORT:
-            case INT:
-            case LONG:
-            case FLOAT:
-            case DOUBLE:
-                switch (((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory()) {
-                    case BYTE:
-                    case SHORT:
-                    case INT:
-                    case LONG:
-                    case FLOAT:
-                    case DOUBLE:
-                        return new GenericUDAFCovarianceEvaluator();
-                    case STRING:
-                    case BOOLEAN:
-                    default:
-                        throw new UDFArgumentTypeException(1, "Only numeric or string type arguments are accepted but "
-                                + parameters[1].getTypeName() + " is passed.");
-                }
-            case STRING:
-            case BOOLEAN:
-            default:
-                throw new UDFArgumentTypeException(0, "Only numeric or string type arguments are accepted but "
-                        + parameters[0].getTypeName() + " is passed.");
-        }
-    }
+		switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
+		case BYTE:
+		case SHORT:
+		case INT:
+		case LONG:
+		case FLOAT:
+		case DOUBLE:
+			switch (((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory()) {
+			case BYTE:
+			case SHORT:
+			case INT:
+			case LONG:
+			case FLOAT:
+			case DOUBLE:
+				return new GenericUDAFCovarianceEvaluator();
+			case STRING:
+			case BOOLEAN:
+			default:
+				throw new UDFArgumentTypeException(1,
+						"Only numeric or string type arguments are accepted but "
+								+ parameters[1].getTypeName() + " is passed.");
+			}
+		case STRING:
+		case BOOLEAN:
+		default:
+			throw new UDFArgumentTypeException(0,
+					"Only numeric or string type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+	}
 
-    /**
-     * Evaluate the variance using the algorithm described in
-     * http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance,
-     * presumably by Pébay, Philippe (2008), in "Formulas for Robust, One-Pass
-     * Parallel Computation of Covariances and Arbitrary-Order Statistical
-     * Moments", Technical Report SAND2008-6212, Sandia National Laboratories,
-     * http://infoserve.sandia.gov/sand_doc/2008/086212.pdf
-     * 
-     * Incremental: n : <count> mx_n = mx_(n-1) + [x_n - mx_(n-1)]/n : <xavg>
-     * my_n = my_(n-1) + [y_n - my_(n-1)]/n : <yavg> c_n = c_(n-1) + (x_n -
-     * mx_(n-1))*(y_n - my_n) : <covariance * n>
-     * 
-     * Merge: c_X = c_A + c_B + (mx_A - mx_B)*(my_A - my_B)*n_A*n_B/n_X
-     * 
-     * This one-pass algorithm is stable.
-     * 
-     */
-    public static class GenericUDAFCovarianceEvaluator extends GenericUDAFEvaluator {
+	/**
+	 * Evaluate the variance using the algorithm described in
+	 * http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance,
+	 * presumably by Pébay, Philippe (2008), in "Formulas for Robust, One-Pass
+	 * Parallel Computation of Covariances and Arbitrary-Order Statistical
+	 * Moments", Technical Report SAND2008-6212, Sandia National Laboratories,
+	 * http://infoserve.sandia.gov/sand_doc/2008/086212.pdf
+	 * 
+	 * Incremental: n : <count> mx_n = mx_(n-1) + [x_n - mx_(n-1)]/n : <xavg>
+	 * my_n = my_(n-1) + [y_n - my_(n-1)]/n : <yavg> c_n = c_(n-1) + (x_n -
+	 * mx_(n-1))*(y_n - my_n) : <covariance * n>
+	 * 
+	 * Merge: c_X = c_A + c_B + (mx_A - mx_B)*(my_A - my_B)*n_A*n_B/n_X
+	 * 
+	 * This one-pass algorithm is stable.
+	 * 
+	 */
+	public static class GenericUDAFCovarianceEvaluator extends
+			GenericUDAFEvaluator {
 
-        // For PARTIAL1 and COMPLETE
-        private PrimitiveObjectInspector xInputOI;
-        private PrimitiveObjectInspector yInputOI;
+		// For PARTIAL1 and COMPLETE
+		private PrimitiveObjectInspector xInputOI;
+		private PrimitiveObjectInspector yInputOI;
 
-        // For PARTIAL2 and FINAL
-        private StructObjectInspector soi;
-        private StructField countField;
-        private StructField xavgField;
-        private StructField yavgField;
-        private StructField covarField;
-        private LongObjectInspector countFieldOI;
-        private DoubleObjectInspector xavgFieldOI;
-        private DoubleObjectInspector yavgFieldOI;
-        private DoubleObjectInspector covarFieldOI;
+		// For PARTIAL2 and FINAL
+		private StructObjectInspector soi;
+		private StructField countField;
+		private StructField xavgField;
+		private StructField yavgField;
+		private StructField covarField;
+		private LongObjectInspector countFieldOI;
+		private DoubleObjectInspector xavgFieldOI;
+		private DoubleObjectInspector yavgFieldOI;
+		private DoubleObjectInspector covarFieldOI;
 
-        // For PARTIAL1 and PARTIAL2
-        private Object[] partialResult;
+		// For PARTIAL1 and PARTIAL2
+		private Object[] partialResult;
 
-        // For FINAL and COMPLETE
-        private DoubleWritable result;
+		// For FINAL and COMPLETE
+		private DoubleWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            super.init(m, parameters);
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			super.init(m, parameters);
 
-            // init input
-            if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
-                assert (parameters.length == 2);
-                xInputOI = (PrimitiveObjectInspector) parameters[0];
-                yInputOI = (PrimitiveObjectInspector) parameters[1];
-            } else {
-                assert (parameters.length == 1);
-                soi = (StructObjectInspector) parameters[0];
+			// init input
+			if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+				assert (parameters.length == 2);
+				xInputOI = (PrimitiveObjectInspector) parameters[0];
+				yInputOI = (PrimitiveObjectInspector) parameters[1];
+			} else {
+				assert (parameters.length == 1);
+				soi = (StructObjectInspector) parameters[0];
 
-                countField = soi.getStructFieldRef("count");
-                xavgField = soi.getStructFieldRef("xavg");
-                yavgField = soi.getStructFieldRef("yavg");
-                covarField = soi.getStructFieldRef("covar");
+				countField = soi.getStructFieldRef("count");
+				xavgField = soi.getStructFieldRef("xavg");
+				yavgField = soi.getStructFieldRef("yavg");
+				covarField = soi.getStructFieldRef("covar");
 
-                countFieldOI = (LongObjectInspector) countField.getFieldObjectInspector();
-                xavgFieldOI = (DoubleObjectInspector) xavgField.getFieldObjectInspector();
-                yavgFieldOI = (DoubleObjectInspector) yavgField.getFieldObjectInspector();
-                covarFieldOI = (DoubleObjectInspector) covarField.getFieldObjectInspector();
-            }
+				countFieldOI = (LongObjectInspector) countField
+						.getFieldObjectInspector();
+				xavgFieldOI = (DoubleObjectInspector) xavgField
+						.getFieldObjectInspector();
+				yavgFieldOI = (DoubleObjectInspector) yavgField
+						.getFieldObjectInspector();
+				covarFieldOI = (DoubleObjectInspector) covarField
+						.getFieldObjectInspector();
+			}
 
-            // init output
-            if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
-                // The output of a partial aggregation is a struct containing
-                // a long count, two double averages, and a double covariance.
+			// init output
+			if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
+				// The output of a partial aggregation is a struct containing
+				// a long count, two double averages, and a double covariance.
 
-                ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
+				ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
 
-                foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
 
-                ArrayList<String> fname = new ArrayList<String>();
-                fname.add("count");
-                fname.add("xavg");
-                fname.add("yavg");
-                fname.add("covar");
+				ArrayList<String> fname = new ArrayList<String>();
+				fname.add("count");
+				fname.add("xavg");
+				fname.add("yavg");
+				fname.add("covar");
 
-                partialResult = new Object[4];
-                partialResult[0] = new LongWritable(0);
-                partialResult[1] = new DoubleWritable(0);
-                partialResult[2] = new DoubleWritable(0);
-                partialResult[3] = new DoubleWritable(0);
+				partialResult = new Object[4];
+				partialResult[0] = new LongWritable(0);
+				partialResult[1] = new DoubleWritable(0);
+				partialResult[2] = new DoubleWritable(0);
+				partialResult[3] = new DoubleWritable(0);
 
-                return ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi);
+				return ObjectInspectorFactory.getStandardStructObjectInspector(
+						fname, foi);
 
-            } else {
-                setResult(new DoubleWritable(0));
-                return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
-            }
-        }
+			} else {
+				setResult(new DoubleWritable(0));
+				return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+			}
+		}
 
-        static class StdAgg implements SerializableBuffer {
-            long count; // number n of elements
-            double xavg; // average of x elements
-            double yavg; // average of y elements
-            double covar; // n times the covariance
+		static class StdAgg implements SerializableBuffer {
+			long count; // number n of elements
+			double xavg; // average of x elements
+			double yavg; // average of y elements
+			double covar; // n times the covariance
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                count = BufferSerDeUtil.getLong(data, start);
-                start += 8;
-                xavg = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                yavg = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                covar = BufferSerDeUtil.getDouble(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				count = BufferSerDeUtil.getLong(data, start);
+				start += 8;
+				xavg = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				yavg = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				covar = BufferSerDeUtil.getDouble(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeLong(count, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(xavg, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(yavg, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(covar, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeLong(count, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(xavg, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(yavg, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(covar, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeLong(count);
-                output.writeDouble(xavg);
-                output.writeDouble(yavg);
-                output.writeDouble(covar);
-            }
-        };
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeLong(count);
+				output.writeDouble(xavg);
+				output.writeDouble(yavg);
+				output.writeDouble(covar);
+			}
+		};
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            StdAgg result = new StdAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			StdAgg result = new StdAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            myagg.count = 0;
-            myagg.xavg = 0;
-            myagg.yavg = 0;
-            myagg.covar = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			myagg.count = 0;
+			myagg.xavg = 0;
+			myagg.yavg = 0;
+			myagg.covar = 0;
+		}
 
-        private boolean warned = false;
+		private boolean warned = false;
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 2);
-            Object px = parameters[0];
-            Object py = parameters[1];
-            if (px != null && py != null) {
-                StdAgg myagg = (StdAgg) agg;
-                double vx = PrimitiveObjectInspectorUtils.getDouble(px, xInputOI);
-                double vy = PrimitiveObjectInspectorUtils.getDouble(py, yInputOI);
-                myagg.count++;
-                myagg.yavg = myagg.yavg + (vy - myagg.yavg) / myagg.count;
-                if (myagg.count > 1) {
-                    myagg.covar += (vx - myagg.xavg) * (vy - myagg.yavg);
-                }
-                myagg.xavg = myagg.xavg + (vx - myagg.xavg) / myagg.count;
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 2);
+			Object px = parameters[0];
+			Object py = parameters[1];
+			if (px != null && py != null) {
+				StdAgg myagg = (StdAgg) agg;
+				double vx = PrimitiveObjectInspectorUtils.getDouble(px,
+						xInputOI);
+				double vy = PrimitiveObjectInspectorUtils.getDouble(py,
+						yInputOI);
+				myagg.count++;
+				myagg.yavg = myagg.yavg + (vy - myagg.yavg) / myagg.count;
+				if (myagg.count > 1) {
+					myagg.covar += (vx - myagg.xavg) * (vy - myagg.yavg);
+				}
+				myagg.xavg = myagg.xavg + (vx - myagg.xavg) / myagg.count;
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            ((LongWritable) partialResult[0]).set(myagg.count);
-            ((DoubleWritable) partialResult[1]).set(myagg.xavg);
-            ((DoubleWritable) partialResult[2]).set(myagg.yavg);
-            ((DoubleWritable) partialResult[3]).set(myagg.covar);
-            return partialResult;
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			((LongWritable) partialResult[0]).set(myagg.count);
+			((DoubleWritable) partialResult[1]).set(myagg.xavg);
+			((DoubleWritable) partialResult[2]).set(myagg.yavg);
+			((DoubleWritable) partialResult[3]).set(myagg.covar);
+			return partialResult;
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                StdAgg myagg = (StdAgg) agg;
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				StdAgg myagg = (StdAgg) agg;
 
-                Object partialCount = soi.getStructFieldData(partial, countField);
-                Object partialXAvg = soi.getStructFieldData(partial, xavgField);
-                Object partialYAvg = soi.getStructFieldData(partial, yavgField);
-                Object partialCovar = soi.getStructFieldData(partial, covarField);
+				Object partialCount = soi.getStructFieldData(partial,
+						countField);
+				Object partialXAvg = soi.getStructFieldData(partial, xavgField);
+				Object partialYAvg = soi.getStructFieldData(partial, yavgField);
+				Object partialCovar = soi.getStructFieldData(partial,
+						covarField);
 
-                long nA = myagg.count;
-                long nB = countFieldOI.get(partialCount);
+				long nA = myagg.count;
+				long nB = countFieldOI.get(partialCount);
 
-                if (nA == 0) {
-                    // Just copy the information since there is nothing so far
-                    myagg.count = countFieldOI.get(partialCount);
-                    myagg.xavg = xavgFieldOI.get(partialXAvg);
-                    myagg.yavg = yavgFieldOI.get(partialYAvg);
-                    myagg.covar = covarFieldOI.get(partialCovar);
-                }
+				if (nA == 0) {
+					// Just copy the information since there is nothing so far
+					myagg.count = countFieldOI.get(partialCount);
+					myagg.xavg = xavgFieldOI.get(partialXAvg);
+					myagg.yavg = yavgFieldOI.get(partialYAvg);
+					myagg.covar = covarFieldOI.get(partialCovar);
+				}
 
-                if (nA != 0 && nB != 0) {
-                    // Merge the two partials
-                    double xavgA = myagg.xavg;
-                    double yavgA = myagg.yavg;
-                    double xavgB = xavgFieldOI.get(partialXAvg);
-                    double yavgB = yavgFieldOI.get(partialYAvg);
-                    double covarB = covarFieldOI.get(partialCovar);
+				if (nA != 0 && nB != 0) {
+					// Merge the two partials
+					double xavgA = myagg.xavg;
+					double yavgA = myagg.yavg;
+					double xavgB = xavgFieldOI.get(partialXAvg);
+					double yavgB = yavgFieldOI.get(partialYAvg);
+					double covarB = covarFieldOI.get(partialCovar);
 
-                    myagg.count += nB;
-                    myagg.xavg = (xavgA * nA + xavgB * nB) / myagg.count;
-                    myagg.yavg = (yavgA * nA + yavgB * nB) / myagg.count;
-                    myagg.covar += covarB + (xavgA - xavgB) * (yavgA - yavgB) * ((double) (nA * nB) / myagg.count);
-                }
-            }
-        }
+					myagg.count += nB;
+					myagg.xavg = (xavgA * nA + xavgB * nB) / myagg.count;
+					myagg.yavg = (yavgA * nA + yavgB * nB) / myagg.count;
+					myagg.covar += covarB + (xavgA - xavgB) * (yavgA - yavgB)
+							* ((double) (nA * nB) / myagg.count);
+				}
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
 
-            if (myagg.count == 0) { // SQL standard - return null for zero
-                                    // elements
-                return null;
-            } else {
-                getResult().set(myagg.covar / (myagg.count));
-                return getResult();
-            }
-        }
+			if (myagg.count == 0) { // SQL standard - return null for zero
+									// elements
+				return null;
+			} else {
+				getResult().set(myagg.covar / (myagg.count));
+				return getResult();
+			}
+		}
 
-        public void setResult(DoubleWritable result) {
-            this.result = result;
-        }
+		public void setResult(DoubleWritable result) {
+			this.result = result;
+		}
 
-        public DoubleWritable getResult() {
-            return result;
-        }
-    }
+		public DoubleWritable getResult() {
+			return result;
+		}
+	}
 
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
index 23b453f..0323531 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFSum.java
@@ -46,230 +46,249 @@
 @Description(name = "sum", value = "_FUNC_(x) - Returns the sum of a set of numbers")
 public class GenericUDAFSum extends AbstractGenericUDAFResolver {
 
-    static final Log LOG = LogFactory.getLog(GenericUDAFSum.class.getName());
+	static final Log LOG = LogFactory.getLog(GenericUDAFSum.class.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        if (parameters.length != 1) {
-            throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected.");
-        }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		if (parameters.length != 1) {
+			throw new UDFArgumentTypeException(parameters.length - 1,
+					"Exactly one argument is expected.");
+		}
 
-        if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
-                    + parameters[0].getTypeName() + " is passed.");
-        }
-        switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
-            case BYTE:
-            case SHORT:
-            case INT:
-            case LONG:
-                return new GenericUDAFSumLong();
-            case FLOAT:
-            case DOUBLE:
-            case STRING:
-                return new GenericUDAFSumDouble();
-            case BOOLEAN:
-            default:
-                throw new UDFArgumentTypeException(0, "Only numeric or string type arguments are accepted but "
-                        + parameters[0].getTypeName() + " is passed.");
-        }
-    }
+		if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(0,
+					"Only primitive type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+		switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
+		case BYTE:
+		case SHORT:
+		case INT:
+		case LONG:
+			return new GenericUDAFSumLong();
+		case FLOAT:
+		case DOUBLE:
+		case STRING:
+			return new GenericUDAFSumDouble();
+		case BOOLEAN:
+		default:
+			throw new UDFArgumentTypeException(0,
+					"Only numeric or string type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+	}
 
-    /**
-     * GenericUDAFSumDouble.
-     * 
-     */
-    public static class GenericUDAFSumDouble extends GenericUDAFEvaluator {
-        private PrimitiveObjectInspector inputOI;
-        private DoubleWritable result;
+	/**
+	 * GenericUDAFSumDouble.
+	 * 
+	 */
+	public static class GenericUDAFSumDouble extends GenericUDAFEvaluator {
+		private PrimitiveObjectInspector inputOI;
+		private DoubleWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            super.init(m, parameters);
-            result = new DoubleWritable(0);
-            inputOI = (PrimitiveObjectInspector) parameters[0];
-            return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
-        }
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			super.init(m, parameters);
+			result = new DoubleWritable(0);
+			inputOI = (PrimitiveObjectInspector) parameters[0];
+			return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+		}
 
-        /** class for storing double sum value. */
-        static class SumDoubleAgg implements SerializableBuffer {
-            boolean empty;
-            double sum;
+		/** class for storing double sum value. */
+		static class SumDoubleAgg implements SerializableBuffer {
+			boolean empty;
+			double sum;
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                empty = BufferSerDeUtil.getBoolean(data, start);
-                start += 1;
-                sum = BufferSerDeUtil.getDouble(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				empty = BufferSerDeUtil.getBoolean(data, start);
+				start += 1;
+				sum = BufferSerDeUtil.getDouble(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeBoolean(empty, data, start);
-                start += 1;
-                BufferSerDeUtil.writeDouble(sum, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeBoolean(empty, data, start);
+				start += 1;
+				BufferSerDeUtil.writeDouble(sum, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeBoolean(empty);
-                output.writeDouble(sum);
-            }
-        }
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeBoolean(empty);
+				output.writeDouble(sum);
+			}
+		}
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            SumDoubleAgg result = new SumDoubleAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			SumDoubleAgg result = new SumDoubleAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            SumDoubleAgg myagg = (SumDoubleAgg) agg;
-            myagg.empty = true;
-            myagg.sum = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			SumDoubleAgg myagg = (SumDoubleAgg) agg;
+			myagg.empty = true;
+			myagg.sum = 0;
+		}
 
-        boolean warned = false;
+		boolean warned = false;
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            try {
-                merge(agg, parameters[0]);
-            } catch (NumberFormatException e) {
-                if (!warned) {
-                    warned = true;
-                    LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e));
-                    LOG.warn(getClass().getSimpleName() + " ignoring similar exceptions.");
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			try {
+				merge(agg, parameters[0]);
+			} catch (NumberFormatException e) {
+				if (!warned) {
+					warned = true;
+					LOG.warn(getClass().getSimpleName() + " "
+							+ StringUtils.stringifyException(e));
+					LOG.warn(getClass().getSimpleName()
+							+ " ignoring similar exceptions.");
+				}
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            return terminate(agg);
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			return terminate(agg);
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                SumDoubleAgg myagg = (SumDoubleAgg) agg;
-                myagg.empty = false;
-                myagg.sum += PrimitiveObjectInspectorUtils.getDouble(partial, inputOI);
-            }
-        }
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				SumDoubleAgg myagg = (SumDoubleAgg) agg;
+				myagg.empty = false;
+				myagg.sum += PrimitiveObjectInspectorUtils.getDouble(partial,
+						inputOI);
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            SumDoubleAgg myagg = (SumDoubleAgg) agg;
-            if (myagg.empty) {
-                return null;
-            }
-            result.set(myagg.sum);
-            return result;
-        }
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			SumDoubleAgg myagg = (SumDoubleAgg) agg;
+			if (myagg.empty) {
+				return null;
+			}
+			result.set(myagg.sum);
+			return result;
+		}
 
-    }
+	}
 
-    /**
-     * GenericUDAFSumLong.
-     * 
-     */
-    public static class GenericUDAFSumLong extends GenericUDAFEvaluator {
-        private PrimitiveObjectInspector inputOI;
-        private LongWritable result;
+	/**
+	 * GenericUDAFSumLong.
+	 * 
+	 */
+	public static class GenericUDAFSumLong extends GenericUDAFEvaluator {
+		private PrimitiveObjectInspector inputOI;
+		private LongWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            super.init(m, parameters);
-            result = new LongWritable(0);
-            inputOI = (PrimitiveObjectInspector) parameters[0];
-            return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
-        }
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			super.init(m, parameters);
+			result = new LongWritable(0);
+			inputOI = (PrimitiveObjectInspector) parameters[0];
+			return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
+		}
 
-        /** class for storing double sum value. */
-        static class SumLongAgg implements SerializableBuffer {
-            boolean empty;
-            long sum;
+		/** class for storing double sum value. */
+		static class SumLongAgg implements SerializableBuffer {
+			boolean empty;
+			long sum;
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                empty = BufferSerDeUtil.getBoolean(data, start);
-                start += 1;
-                sum = BufferSerDeUtil.getLong(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				empty = BufferSerDeUtil.getBoolean(data, start);
+				start += 1;
+				sum = BufferSerDeUtil.getLong(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeBoolean(empty, data, start);
-                start += 1;
-                BufferSerDeUtil.writeLong(sum, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeBoolean(empty, data, start);
+				start += 1;
+				BufferSerDeUtil.writeLong(sum, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeBoolean(empty);
-                output.writeLong(sum);
-            }
-        }
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeBoolean(empty);
+				output.writeLong(sum);
+			}
+		}
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            SumLongAgg result = new SumLongAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			SumLongAgg result = new SumLongAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            SumLongAgg myagg = (SumLongAgg) agg;
-            myagg.empty = true;
-            myagg.sum = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			SumLongAgg myagg = (SumLongAgg) agg;
+			myagg.empty = true;
+			myagg.sum = 0;
+		}
 
-        private boolean warned = false;
+		private boolean warned = false;
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            try {
-                merge(agg, parameters[0]);
-            } catch (NumberFormatException e) {
-                if (!warned) {
-                    warned = true;
-                    LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e));
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			try {
+				merge(agg, parameters[0]);
+			} catch (NumberFormatException e) {
+				if (!warned) {
+					warned = true;
+					LOG.warn(getClass().getSimpleName() + " "
+							+ StringUtils.stringifyException(e));
+				}
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            return terminate(agg);
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			return terminate(agg);
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                SumLongAgg myagg = (SumLongAgg) agg;
-                myagg.sum += PrimitiveObjectInspectorUtils.getLong(partial, inputOI);
-                myagg.empty = false;
-            }
-        }
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				SumLongAgg myagg = (SumLongAgg) agg;
+				myagg.sum += PrimitiveObjectInspectorUtils.getLong(partial,
+						inputOI);
+				myagg.empty = false;
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            SumLongAgg myagg = (SumLongAgg) agg;
-            if (myagg.empty) {
-                return null;
-            }
-            result.set(myagg.sum);
-            return result;
-        }
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			SumLongAgg myagg = (SumLongAgg) agg;
+			if (myagg.empty) {
+				return null;
+			}
+			result.set(myagg.sum);
+			return result;
+		}
 
-    }
+	}
 
 }
diff --git a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFVariance.java b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFVariance.java
index d91551d..9dd370a 100644
--- a/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFVariance.java
+++ b/hivesterix/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFVariance.java
@@ -53,260 +53,282 @@
 @Description(name = "variance,var_pop", value = "_FUNC_(x) - Returns the variance of a set of numbers")
 public class GenericUDAFVariance extends AbstractGenericUDAFResolver {
 
-    static final Log LOG = LogFactory.getLog(GenericUDAFVariance.class.getName());
+	static final Log LOG = LogFactory.getLog(GenericUDAFVariance.class
+			.getName());
 
-    @Override
-    public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException {
-        if (parameters.length != 1) {
-            throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected.");
-        }
+	@Override
+	public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
+			throws SemanticException {
+		if (parameters.length != 1) {
+			throw new UDFArgumentTypeException(parameters.length - 1,
+					"Exactly one argument is expected.");
+		}
 
-        if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
-            throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
-                    + parameters[0].getTypeName() + " is passed.");
-        }
-        switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
-            case BYTE:
-            case SHORT:
-            case INT:
-            case LONG:
-            case FLOAT:
-            case DOUBLE:
-            case STRING:
-                return new GenericUDAFVarianceEvaluator();
-            case BOOLEAN:
-            default:
-                throw new UDFArgumentTypeException(0, "Only numeric or string type arguments are accepted but "
-                        + parameters[0].getTypeName() + " is passed.");
-        }
-    }
+		if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
+			throw new UDFArgumentTypeException(0,
+					"Only primitive type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+		switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
+		case BYTE:
+		case SHORT:
+		case INT:
+		case LONG:
+		case FLOAT:
+		case DOUBLE:
+		case STRING:
+			return new GenericUDAFVarianceEvaluator();
+		case BOOLEAN:
+		default:
+			throw new UDFArgumentTypeException(0,
+					"Only numeric or string type arguments are accepted but "
+							+ parameters[0].getTypeName() + " is passed.");
+		}
+	}
 
-    /**
-     * Evaluate the variance using the algorithm described by Chan, Golub, and
-     * LeVeque in
-     * "Algorithms for computing the sample variance: analysis and recommendations"
-     * The American Statistician, 37 (1983) pp. 242--247.
-     * 
-     * variance = variance1 + variance2 + n/(m*(m+n)) * pow(((m/n)*t1 - t2),2)
-     * 
-     * where: - variance is sum[x-avg^2] (this is actually n times the variance)
-     * and is updated at every step. - n is the count of elements in chunk1 - m
-     * is the count of elements in chunk2 - t1 = sum of elements in chunk1, t2 =
-     * sum of elements in chunk2.
-     * 
-     * This algorithm was proven to be numerically stable by J.L. Barlow in
-     * "Error analysis of a pairwise summation algorithm to compute sample variance"
-     * Numer. Math, 58 (1991) pp. 583--590
-     * 
-     */
-    public static class GenericUDAFVarianceEvaluator extends GenericUDAFEvaluator {
+	/**
+	 * Evaluate the variance using the algorithm described by Chan, Golub, and
+	 * LeVeque in
+	 * "Algorithms for computing the sample variance: analysis and recommendations"
+	 * The American Statistician, 37 (1983) pp. 242--247.
+	 * 
+	 * variance = variance1 + variance2 + n/(m*(m+n)) * pow(((m/n)*t1 - t2),2)
+	 * 
+	 * where: - variance is sum[x-avg^2] (this is actually n times the variance)
+	 * and is updated at every step. - n is the count of elements in chunk1 - m
+	 * is the count of elements in chunk2 - t1 = sum of elements in chunk1, t2 =
+	 * sum of elements in chunk2.
+	 * 
+	 * This algorithm was proven to be numerically stable by J.L. Barlow in
+	 * "Error analysis of a pairwise summation algorithm to compute sample variance"
+	 * Numer. Math, 58 (1991) pp. 583--590
+	 * 
+	 */
+	public static class GenericUDAFVarianceEvaluator extends
+			GenericUDAFEvaluator {
 
-        // For PARTIAL1 and COMPLETE
-        private PrimitiveObjectInspector inputOI;
+		// For PARTIAL1 and COMPLETE
+		private PrimitiveObjectInspector inputOI;
 
-        // For PARTIAL2 and FINAL
-        private StructObjectInspector soi;
-        private StructField countField;
-        private StructField sumField;
-        private StructField varianceField;
-        private LongObjectInspector countFieldOI;
-        private DoubleObjectInspector sumFieldOI;
-        private DoubleObjectInspector varianceFieldOI;
+		// For PARTIAL2 and FINAL
+		private StructObjectInspector soi;
+		private StructField countField;
+		private StructField sumField;
+		private StructField varianceField;
+		private LongObjectInspector countFieldOI;
+		private DoubleObjectInspector sumFieldOI;
+		private DoubleObjectInspector varianceFieldOI;
 
-        // For PARTIAL1 and PARTIAL2
-        private Object[] partialResult;
+		// For PARTIAL1 and PARTIAL2
+		private Object[] partialResult;
 
-        // For FINAL and COMPLETE
-        private DoubleWritable result;
+		// For FINAL and COMPLETE
+		private DoubleWritable result;
 
-        @Override
-        public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            super.init(m, parameters);
+		@Override
+		public ObjectInspector init(Mode m, ObjectInspector[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			super.init(m, parameters);
 
-            // init input
-            if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
-                inputOI = (PrimitiveObjectInspector) parameters[0];
-            } else {
-                soi = (StructObjectInspector) parameters[0];
+			// init input
+			if (mode == Mode.PARTIAL1 || mode == Mode.COMPLETE) {
+				inputOI = (PrimitiveObjectInspector) parameters[0];
+			} else {
+				soi = (StructObjectInspector) parameters[0];
 
-                countField = soi.getStructFieldRef("count");
-                sumField = soi.getStructFieldRef("sum");
-                varianceField = soi.getStructFieldRef("variance");
+				countField = soi.getStructFieldRef("count");
+				sumField = soi.getStructFieldRef("sum");
+				varianceField = soi.getStructFieldRef("variance");
 
-                countFieldOI = (LongObjectInspector) countField.getFieldObjectInspector();
-                sumFieldOI = (DoubleObjectInspector) sumField.getFieldObjectInspector();
-                varianceFieldOI = (DoubleObjectInspector) varianceField.getFieldObjectInspector();
-            }
+				countFieldOI = (LongObjectInspector) countField
+						.getFieldObjectInspector();
+				sumFieldOI = (DoubleObjectInspector) sumField
+						.getFieldObjectInspector();
+				varianceFieldOI = (DoubleObjectInspector) varianceField
+						.getFieldObjectInspector();
+			}
 
-            // init output
-            if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
-                // The output of a partial aggregation is a struct containing
-                // a long count and doubles sum and variance.
+			// init output
+			if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
+				// The output of a partial aggregation is a struct containing
+				// a long count and doubles sum and variance.
 
-                ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
+				ArrayList<ObjectInspector> foi = new ArrayList<ObjectInspector>();
 
-                foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
-                foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+				foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
 
-                ArrayList<String> fname = new ArrayList<String>();
-                fname.add("count");
-                fname.add("sum");
-                fname.add("variance");
+				ArrayList<String> fname = new ArrayList<String>();
+				fname.add("count");
+				fname.add("sum");
+				fname.add("variance");
 
-                partialResult = new Object[3];
-                partialResult[0] = new LongWritable(0);
-                partialResult[1] = new DoubleWritable(0);
-                partialResult[2] = new DoubleWritable(0);
+				partialResult = new Object[3];
+				partialResult[0] = new LongWritable(0);
+				partialResult[1] = new DoubleWritable(0);
+				partialResult[2] = new DoubleWritable(0);
 
-                return ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi);
+				return ObjectInspectorFactory.getStandardStructObjectInspector(
+						fname, foi);
 
-            } else {
-                setResult(new DoubleWritable(0));
-                return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
-            }
-        }
+			} else {
+				setResult(new DoubleWritable(0));
+				return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+			}
+		}
 
-        static class StdAgg implements SerializableBuffer {
-            long count; // number of elements
-            double sum; // sum of elements
-            double variance; // sum[x-avg^2] (this is actually n times the
-                             // variance)
+		static class StdAgg implements SerializableBuffer {
+			long count; // number of elements
+			double sum; // sum of elements
+			double variance; // sum[x-avg^2] (this is actually n times the
+								// variance)
 
-            @Override
-            public void deSerializeAggBuffer(byte[] data, int start, int len) {
-                count = BufferSerDeUtil.getLong(data, start);
-                start += 8;
-                sum = BufferSerDeUtil.getDouble(data, start);
-                start += 8;
-                variance = BufferSerDeUtil.getDouble(data, start);
-            }
+			@Override
+			public void deSerializeAggBuffer(byte[] data, int start, int len) {
+				count = BufferSerDeUtil.getLong(data, start);
+				start += 8;
+				sum = BufferSerDeUtil.getDouble(data, start);
+				start += 8;
+				variance = BufferSerDeUtil.getDouble(data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(byte[] data, int start, int len) {
-                BufferSerDeUtil.writeLong(count, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(sum, data, start);
-                start += 8;
-                BufferSerDeUtil.writeDouble(variance, data, start);
-            }
+			@Override
+			public void serializeAggBuffer(byte[] data, int start, int len) {
+				BufferSerDeUtil.writeLong(count, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(sum, data, start);
+				start += 8;
+				BufferSerDeUtil.writeDouble(variance, data, start);
+			}
 
-            @Override
-            public void serializeAggBuffer(DataOutput output) throws IOException {
-                output.writeLong(count);
-                output.writeDouble(sum);
-                output.writeDouble(variance);
-            }
-        };
+			@Override
+			public void serializeAggBuffer(DataOutput output)
+					throws IOException {
+				output.writeLong(count);
+				output.writeDouble(sum);
+				output.writeDouble(variance);
+			}
+		};
 
-        @Override
-        public AggregationBuffer getNewAggregationBuffer() throws HiveException {
-            StdAgg result = new StdAgg();
-            reset(result);
-            return result;
-        }
+		@Override
+		public AggregationBuffer getNewAggregationBuffer() throws HiveException {
+			StdAgg result = new StdAgg();
+			reset(result);
+			return result;
+		}
 
-        @Override
-        public void reset(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            myagg.count = 0;
-            myagg.sum = 0;
-            myagg.variance = 0;
-        }
+		@Override
+		public void reset(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			myagg.count = 0;
+			myagg.sum = 0;
+			myagg.variance = 0;
+		}
 
-        private boolean warned = false;
+		private boolean warned = false;
 
-        @Override
-        public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
-            assert (parameters.length == 1);
-            Object p = parameters[0];
-            if (p != null) {
-                StdAgg myagg = (StdAgg) agg;
-                try {
-                    double v = PrimitiveObjectInspectorUtils.getDouble(p, inputOI);
-                    myagg.count++;
-                    myagg.sum += v;
-                    if (myagg.count > 1) {
-                        double t = myagg.count * v - myagg.sum;
-                        myagg.variance += (t * t) / ((double) myagg.count * (myagg.count - 1));
-                    }
-                } catch (NumberFormatException e) {
-                    if (!warned) {
-                        warned = true;
-                        LOG.warn(getClass().getSimpleName() + " " + StringUtils.stringifyException(e));
-                        LOG.warn(getClass().getSimpleName() + " ignoring similar exceptions.");
-                    }
-                }
-            }
-        }
+		@Override
+		public void iterate(AggregationBuffer agg, Object[] parameters)
+				throws HiveException {
+			assert (parameters.length == 1);
+			Object p = parameters[0];
+			if (p != null) {
+				StdAgg myagg = (StdAgg) agg;
+				try {
+					double v = PrimitiveObjectInspectorUtils.getDouble(p,
+							inputOI);
+					myagg.count++;
+					myagg.sum += v;
+					if (myagg.count > 1) {
+						double t = myagg.count * v - myagg.sum;
+						myagg.variance += (t * t)
+								/ ((double) myagg.count * (myagg.count - 1));
+					}
+				} catch (NumberFormatException e) {
+					if (!warned) {
+						warned = true;
+						LOG.warn(getClass().getSimpleName() + " "
+								+ StringUtils.stringifyException(e));
+						LOG.warn(getClass().getSimpleName()
+								+ " ignoring similar exceptions.");
+					}
+				}
+			}
+		}
 
-        @Override
-        public Object terminatePartial(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
-            ((LongWritable) partialResult[0]).set(myagg.count);
-            ((DoubleWritable) partialResult[1]).set(myagg.sum);
-            ((DoubleWritable) partialResult[2]).set(myagg.variance);
-            return partialResult;
-        }
+		@Override
+		public Object terminatePartial(AggregationBuffer agg)
+				throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
+			((LongWritable) partialResult[0]).set(myagg.count);
+			((DoubleWritable) partialResult[1]).set(myagg.sum);
+			((DoubleWritable) partialResult[2]).set(myagg.variance);
+			return partialResult;
+		}
 
-        @Override
-        public void merge(AggregationBuffer agg, Object partial) throws HiveException {
-            if (partial != null) {
-                StdAgg myagg = (StdAgg) agg;
+		@Override
+		public void merge(AggregationBuffer agg, Object partial)
+				throws HiveException {
+			if (partial != null) {
+				StdAgg myagg = (StdAgg) agg;
 
-                Object partialCount = soi.getStructFieldData(partial, countField);
-                Object partialSum = soi.getStructFieldData(partial, sumField);
-                Object partialVariance = soi.getStructFieldData(partial, varianceField);
+				Object partialCount = soi.getStructFieldData(partial,
+						countField);
+				Object partialSum = soi.getStructFieldData(partial, sumField);
+				Object partialVariance = soi.getStructFieldData(partial,
+						varianceField);
 
-                long n = myagg.count;
-                long m = countFieldOI.get(partialCount);
+				long n = myagg.count;
+				long m = countFieldOI.get(partialCount);
 
-                if (n == 0) {
-                    // Just copy the information since there is nothing so far
-                    myagg.variance = sumFieldOI.get(partialVariance);
-                    myagg.count = countFieldOI.get(partialCount);
-                    myagg.sum = sumFieldOI.get(partialSum);
-                }
+				if (n == 0) {
+					// Just copy the information since there is nothing so far
+					myagg.variance = sumFieldOI.get(partialVariance);
+					myagg.count = countFieldOI.get(partialCount);
+					myagg.sum = sumFieldOI.get(partialSum);
+				}
 
-                if (m != 0 && n != 0) {
-                    // Merge the two partials
+				if (m != 0 && n != 0) {
+					// Merge the two partials
 
-                    double a = myagg.sum;
-                    double b = sumFieldOI.get(partialSum);
+					double a = myagg.sum;
+					double b = sumFieldOI.get(partialSum);
 
-                    myagg.count += m;
-                    myagg.sum += b;
-                    double t = (m / (double) n) * a - b;
-                    myagg.variance += sumFieldOI.get(partialVariance) + ((n / (double) m) / ((double) n + m)) * t * t;
-                }
-            }
-        }
+					myagg.count += m;
+					myagg.sum += b;
+					double t = (m / (double) n) * a - b;
+					myagg.variance += sumFieldOI.get(partialVariance)
+							+ ((n / (double) m) / ((double) n + m)) * t * t;
+				}
+			}
+		}
 
-        @Override
-        public Object terminate(AggregationBuffer agg) throws HiveException {
-            StdAgg myagg = (StdAgg) agg;
+		@Override
+		public Object terminate(AggregationBuffer agg) throws HiveException {
+			StdAgg myagg = (StdAgg) agg;
 
-            if (myagg.count == 0) { // SQL standard - return null for zero
-                                    // elements
-                return null;
-            } else {
-                if (myagg.count > 1) {
-                    getResult().set(myagg.variance / (myagg.count));
-                } else { // for one element the variance is always 0
-                    getResult().set(0);
-                }
-                return getResult();
-            }
-        }
+			if (myagg.count == 0) { // SQL standard - return null for zero
+									// elements
+				return null;
+			} else {
+				if (myagg.count > 1) {
+					getResult().set(myagg.variance / (myagg.count));
+				} else { // for one element the variance is always 0
+					getResult().set(0);
+				}
+				return getResult();
+			}
+		}
 
-        public void setResult(DoubleWritable result) {
-            this.result = result;
-        }
+		public void setResult(DoubleWritable result) {
+			this.result = result;
+		}
 
-        public DoubleWritable getResult() {
-            return result;
-        }
-    }
+		public DoubleWritable getResult() {
+			return result;
+		}
+	}
 
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestCase.java
index 3a0f381..a69a3f2 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestCase.java
@@ -15,128 +15,130 @@
 import edu.uci.ics.hivesterix.runtime.config.ConfUtil;
 
 public class PerfTestCase extends AbstractPerfTestCase {
-    private File resultFile;
-    private FileSystem dfs;
+	private File resultFile;
+	private FileSystem dfs;
 
-    PerfTestCase(File queryFile, File resultFile) {
-        super("testRuntimeFunction", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	PerfTestCase(File queryFile, File resultFile) {
+		super("testRuntimeFunction", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testRuntimeFunction() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	@Test
+	public void testRuntimeFunction() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
 
-        dfs = FileSystem.get(ConfUtil.getJobConf());
+		dfs = FileSystem.get(ConfUtil.getJobConf());
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            driver.run(query);
-            driver.clear();
-            i++;
-        }
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			driver.run(query);
+			driver.clear();
+			i++;
+		}
 
-        String warehouse = hconf.get("hive.metastore.warehouse.dir");
-        String tableName = removeExt(resultFile.getName());
-        String directory = warehouse + "/" + tableName + "/";
-        String localDirectory = "tmp";
+		String warehouse = hconf.get("hive.metastore.warehouse.dir");
+		String tableName = removeExt(resultFile.getName());
+		String directory = warehouse + "/" + tableName + "/";
+		String localDirectory = "tmp";
 
-        FileStatus[] files = dfs.listStatus(new Path(directory));
-        FileSystem lfs = null;
-        if (files == null) {
-            lfs = FileSystem.getLocal(ConfUtil.getJobConf());
-            files = lfs.listStatus(new Path(directory));
-        }
+		FileStatus[] files = dfs.listStatus(new Path(directory));
+		FileSystem lfs = null;
+		if (files == null) {
+			lfs = FileSystem.getLocal(ConfUtil.getJobConf());
+			files = lfs.listStatus(new Path(directory));
+		}
 
-        File resultDirectory = new File(localDirectory + "/" + tableName);
-        deleteDir(resultDirectory);
-        resultDirectory.mkdir();
+		File resultDirectory = new File(localDirectory + "/" + tableName);
+		deleteDir(resultDirectory);
+		resultDirectory.mkdir();
 
-        for (FileStatus fs : files) {
-            Path src = fs.getPath();
-            if (src.getName().indexOf("crc") >= 0)
-                continue;
+		for (FileStatus fs : files) {
+			Path src = fs.getPath();
+			if (src.getName().indexOf("crc") >= 0)
+				continue;
 
-            String destStr = localDirectory + "/" + tableName + "/" + src.getName();
-            Path dest = new Path(destStr);
-            if (lfs != null) {
-                lfs.copyToLocalFile(src, dest);
-                dfs.copyFromLocalFile(dest, new Path(directory));
-            } else
-                dfs.copyToLocalFile(src, dest);
-        }
+			String destStr = localDirectory + "/" + tableName + "/"
+					+ src.getName();
+			Path dest = new Path(destStr);
+			if (lfs != null) {
+				lfs.copyToLocalFile(src, dest);
+				dfs.copyFromLocalFile(dest, new Path(directory));
+			} else
+				dfs.copyToLocalFile(src, dest);
+		}
 
-        File[] rFiles = resultDirectory.listFiles();
-        StringBuilder sb = new StringBuilder();
-        for (File r : rFiles) {
-            if (r.getName().indexOf("crc") >= 0)
-                continue;
-            readFileToString(r, sb);
-        }
-        deleteDir(resultDirectory);
+		File[] rFiles = resultDirectory.listFiles();
+		StringBuilder sb = new StringBuilder();
+		for (File r : rFiles) {
+			if (r.getName().indexOf("crc") >= 0)
+				continue;
+			readFileToString(r, sb);
+		}
+		deleteDir(resultDirectory);
 
-        StringBuilder buf = new StringBuilder();
-        readFileToString(resultFile, buf);
-        if (!equal(buf, sb)) {
-            throw new Exception("Result for " + queryFile + " changed:\n" + sw.toString());
-        }
-    }
+		StringBuilder buf = new StringBuilder();
+		readFileToString(resultFile, buf);
+		if (!equal(buf, sb)) {
+			throw new Exception("Result for " + queryFile + " changed:\n"
+					+ sw.toString());
+		}
+	}
 
-    private void deleteDir(File resultDirectory) {
-        if (resultDirectory.exists()) {
-            File[] rFiles = resultDirectory.listFiles();
-            for (File r : rFiles)
-                r.delete();
-            resultDirectory.delete();
-        }
-    }
+	private void deleteDir(File resultDirectory) {
+		if (resultDirectory.exists()) {
+			File[] rFiles = resultDirectory.listFiles();
+			for (File r : rFiles)
+				r.delete();
+			resultDirectory.delete();
+		}
+	}
 
-    private boolean equal(StringBuilder sb1, StringBuilder sb2) {
-        String s1 = sb1.toString();
-        String s2 = sb2.toString();
-        String[] rowsOne = s1.split("\n");
-        String[] rowsTwo = s2.split("\n");
+	private boolean equal(StringBuilder sb1, StringBuilder sb2) {
+		String s1 = sb1.toString();
+		String s2 = sb2.toString();
+		String[] rowsOne = s1.split("\n");
+		String[] rowsTwo = s2.split("\n");
 
-        if (rowsOne.length != rowsTwo.length)
-            return false;
+		if (rowsOne.length != rowsTwo.length)
+			return false;
 
-        for (int i = 0; i < rowsOne.length; i++) {
-            String row1 = rowsOne[i];
-            String row2 = rowsTwo[i];
+		for (int i = 0; i < rowsOne.length; i++) {
+			String row1 = rowsOne[i];
+			String row2 = rowsTwo[i];
 
-            if (row1.equals(row2))
-                continue;
+			if (row1.equals(row2))
+				continue;
 
-            String[] fields1 = row1.split("");
-            String[] fields2 = row2.split("");
+			String[] fields1 = row1.split("");
+			String[] fields2 = row2.split("");
 
-            for (int j = 0; j < fields1.length; j++) {
-                if (fields1[j].equals(fields2[j])) {
-                    continue;
-                } else if (fields1[j].indexOf('.') < 0) {
-                    return false;
-                } else {
-                    Float float1 = Float.parseFloat(fields1[j]);
-                    Float float2 = Float.parseFloat(fields2[j]);
+			for (int j = 0; j < fields1.length; j++) {
+				if (fields1[j].equals(fields2[j])) {
+					continue;
+				} else if (fields1[j].indexOf('.') < 0) {
+					return false;
+				} else {
+					Float float1 = Float.parseFloat(fields1[j]);
+					Float float2 = Float.parseFloat(fields2[j]);
 
-                    if (Math.abs(float1 - float2) == 0)
-                        continue;
-                    else
-                        return false;
-                }
-            }
-        }
+					if (Math.abs(float1 - float2) == 0)
+						continue;
+					else
+						return false;
+				}
+			}
+		}
 
-        return true;
-    }
+		return true;
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuite.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuite.java
index 796842d..8d8178f 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuite.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuite.java
@@ -9,66 +9,66 @@
 

 public class PerfTestSuite extends AbstractPerfTestSuiteClass {

 

-    private static final String PATH_TO_QUERIES = "src/test/resources/perf/queries/";

-    private static final String PATH_TO_RESULTS = "src/test/resources/perf/results/";

-    private static final String PATH_TO_IGNORES = "src/test/resources/perf/ignore.txt";

+	private static final String PATH_TO_QUERIES = "src/test/resources/perf/queries/";

+	private static final String PATH_TO_RESULTS = "src/test/resources/perf/results/";

+	private static final String PATH_TO_IGNORES = "src/test/resources/perf/ignore.txt";

 

-    private static final String FILE_EXTENSION_OF_RESULTS = "result";

+	private static final String FILE_EXTENSION_OF_RESULTS = "result";

 

-    public static Test suite() throws Exception {

-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

-        File testData = new File(PATH_TO_QUERIES);

-        File[] queries = testData.listFiles();

-        PerfTestSuite testSuite = new PerfTestSuite();

+	public static Test suite() throws Exception {

+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

+		File testData = new File(PATH_TO_QUERIES);

+		File[] queries = testData.listFiles();

+		PerfTestSuite testSuite = new PerfTestSuite();

 

-        // set hdfs and hyracks cluster, and load test data to hdfs

-        try {

-            testSuite.setup();

-            testSuite.loadData();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

+		// set hdfs and hyracks cluster, and load test data to hdfs

+		try {

+			testSuite.setup();

+			testSuite.loadData();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

 

-        for (File qFile : queries) {

-            if (isIgnored(qFile.getName(), ignores))

-                continue;

+		for (File qFile : queries) {

+			if (isIgnored(qFile.getName(), ignores))

+				continue;

 

-            if (qFile.isFile()) {

-                String resultFileName = hiveExtToResExt(qFile.getName());

-                File rFile = new File(PATH_TO_RESULTS + resultFileName);

-                testSuite.addTest(new PerfTestCase(qFile, rFile));

-            }

-        }

-        return testSuite;

-    }

+			if (qFile.isFile()) {

+				String resultFileName = hiveExtToResExt(qFile.getName());

+				File rFile = new File(PATH_TO_RESULTS + resultFileName);

+				testSuite.addTest(new PerfTestCase(qFile, rFile));

+			}

+		}

+		return testSuite;

+	}

 

-    private static String hiveExtToResExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

-    }

+	private static String hiveExtToResExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

+	}

 

-    /**

-     * Runs the tests and collects their result in a TestResult.

-     */

-    @Override

-    public void run(TestResult result) {

+	/**

+	 * Runs the tests and collects their result in a TestResult.

+	 */

+	@Override

+	public void run(TestResult result) {

 

-        int testCount = countTestCases();

-        for (int i = 0; i < testCount; i++) {

-            Test each = this.testAt(i);

-            if (result.shouldStop())

-                break;

-            runTest(each, result);

-        }

+		int testCount = countTestCases();

+		for (int i = 0; i < testCount; i++) {

+			Test each = this.testAt(i);

+			if (result.shouldStop())

+				break;

+			runTest(each, result);

+		}

 

-        // cleanup hdfs and hyracks cluster

-        try {

-            cleanup();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

-    }

+		// cleanup hdfs and hyracks cluster

+		try {

+			cleanup();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteCaseGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteCaseGenerator.java
index 75a325e..258db22 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteCaseGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteCaseGenerator.java
@@ -13,87 +13,89 @@
 import edu.uci.ics.hivesterix.runtime.config.ConfUtil;
 
 public class PerfTestSuiteCaseGenerator extends AbstractPerfTestCase {
-    private File resultFile;
-    private FileSystem dfs;
+	private File resultFile;
+	private FileSystem dfs;
 
-    PerfTestSuiteCaseGenerator(File queryFile, File resultFile) {
-        super("testRuntimeFunction", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	PerfTestSuiteCaseGenerator(File queryFile, File resultFile) {
+		super("testRuntimeFunction", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testRuntimeFunction() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
+	@Test
+	public void testRuntimeFunction() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf);
-        driver.init();
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf);
+		driver.init();
 
-        dfs = FileSystem.get(ConfUtil.getJobConf());
+		dfs = FileSystem.get(ConfUtil.getJobConf());
 
-        long startTime = System.currentTimeMillis();
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            driver.run(query);
-            // driver.clear();
-            i++;
-        }
-        long endTime = System.currentTimeMillis();
-        System.out.println(resultFile.getName() + " execution time " + (endTime - startTime));
+		long startTime = System.currentTimeMillis();
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			driver.run(query);
+			// driver.clear();
+			i++;
+		}
+		long endTime = System.currentTimeMillis();
+		System.out.println(resultFile.getName() + " execution time "
+				+ (endTime - startTime));
 
-        String warehouse = hconf.get("hive.metastore.warehouse.dir");
-        String tableName = removeExt(resultFile.getName());
-        String directory = warehouse + "/" + tableName + "/";
-        String localDirectory = "tmp";
+		String warehouse = hconf.get("hive.metastore.warehouse.dir");
+		String tableName = removeExt(resultFile.getName());
+		String directory = warehouse + "/" + tableName + "/";
+		String localDirectory = "tmp";
 
-        FileStatus[] files = dfs.listStatus(new Path(directory));
-        FileSystem lfs = null;
-        if (files == null) {
-            lfs = FileSystem.getLocal(ConfUtil.getJobConf());
-            files = lfs.listStatus(new Path(directory));
-        }
+		FileStatus[] files = dfs.listStatus(new Path(directory));
+		FileSystem lfs = null;
+		if (files == null) {
+			lfs = FileSystem.getLocal(ConfUtil.getJobConf());
+			files = lfs.listStatus(new Path(directory));
+		}
 
-        File resultDirectory = new File(localDirectory + "/" + tableName);
-        deleteDir(resultDirectory);
-        resultDirectory.mkdir();
+		File resultDirectory = new File(localDirectory + "/" + tableName);
+		deleteDir(resultDirectory);
+		resultDirectory.mkdir();
 
-        for (FileStatus fs : files) {
-            Path src = fs.getPath();
-            if (src.getName().indexOf("crc") >= 0)
-                continue;
+		for (FileStatus fs : files) {
+			Path src = fs.getPath();
+			if (src.getName().indexOf("crc") >= 0)
+				continue;
 
-            String destStr = localDirectory + "/" + tableName + "/" + src.getName();
-            Path dest = new Path(destStr);
-            if (lfs != null) {
-                lfs.copyToLocalFile(src, dest);
-                dfs.copyFromLocalFile(dest, new Path(directory));
-            } else
-                dfs.copyToLocalFile(src, dest);
-        }
+			String destStr = localDirectory + "/" + tableName + "/"
+					+ src.getName();
+			Path dest = new Path(destStr);
+			if (lfs != null) {
+				lfs.copyToLocalFile(src, dest);
+				dfs.copyFromLocalFile(dest, new Path(directory));
+			} else
+				dfs.copyToLocalFile(src, dest);
+		}
 
-        File[] rFiles = resultDirectory.listFiles();
-        StringBuilder sb = new StringBuilder();
-        for (File r : rFiles) {
-            if (r.getName().indexOf("crc") >= 0)
-                continue;
-            readFileToString(r, sb);
-        }
-        deleteDir(resultDirectory);
+		File[] rFiles = resultDirectory.listFiles();
+		StringBuilder sb = new StringBuilder();
+		for (File r : rFiles) {
+			if (r.getName().indexOf("crc") >= 0)
+				continue;
+			readFileToString(r, sb);
+		}
+		deleteDir(resultDirectory);
 
-        writeStringToFile(resultFile, sb);
-    }
+		writeStringToFile(resultFile, sb);
+	}
 
-    private void deleteDir(File resultDirectory) {
-        if (resultDirectory.exists()) {
-            File[] rFiles = resultDirectory.listFiles();
-            for (File r : rFiles)
-                r.delete();
-            resultDirectory.delete();
-        }
-    }
+	private void deleteDir(File resultDirectory) {
+		if (resultDirectory.exists()) {
+			File[] rFiles = resultDirectory.listFiles();
+			for (File r : rFiles)
+				r.delete();
+			resultDirectory.delete();
+		}
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteGenerator.java
index aa38014..0a27ca2 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/PerfTestSuiteGenerator.java
@@ -9,66 +9,66 @@
 

 public class PerfTestSuiteGenerator extends AbstractPerfTestSuiteClass {

 

-    private static final String PATH_TO_QUERIES = "src/test/resources/perf/queries/";

-    private static final String PATH_TO_RESULTS = "src/test/resources/perf/results/";

-    private static final String PATH_TO_IGNORES = "src/test/resources/perf/ignore.txt";

+	private static final String PATH_TO_QUERIES = "src/test/resources/perf/queries/";

+	private static final String PATH_TO_RESULTS = "src/test/resources/perf/results/";

+	private static final String PATH_TO_IGNORES = "src/test/resources/perf/ignore.txt";

 

-    private static final String FILE_EXTENSION_OF_RESULTS = "result";

+	private static final String FILE_EXTENSION_OF_RESULTS = "result";

 

-    public static Test suite() throws Exception {

-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

-        File testData = new File(PATH_TO_QUERIES);

-        File[] queries = testData.listFiles();

-        PerfTestSuiteGenerator testSuite = new PerfTestSuiteGenerator();

+	public static Test suite() throws Exception {

+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

+		File testData = new File(PATH_TO_QUERIES);

+		File[] queries = testData.listFiles();

+		PerfTestSuiteGenerator testSuite = new PerfTestSuiteGenerator();

 

-        // set hdfs and hyracks cluster, and load test data to hdfs

-        try {

-            testSuite.setup();

-            testSuite.loadData();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

+		// set hdfs and hyracks cluster, and load test data to hdfs

+		try {

+			testSuite.setup();

+			testSuite.loadData();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

 

-        for (File qFile : queries) {

-            if (isIgnored(qFile.getName(), ignores))

-                continue;

+		for (File qFile : queries) {

+			if (isIgnored(qFile.getName(), ignores))

+				continue;

 

-            if (qFile.isFile() && qFile.getName().startsWith("q18_")) {

-                String resultFileName = hiveExtToResExt(qFile.getName());

-                File rFile = new File(PATH_TO_RESULTS + resultFileName);

-                testSuite.addTest(new PerfTestSuiteCaseGenerator(qFile, rFile));

-            }

-        }

-        return testSuite;

-    }

+			if (qFile.isFile() && qFile.getName().startsWith("q18_")) {

+				String resultFileName = hiveExtToResExt(qFile.getName());

+				File rFile = new File(PATH_TO_RESULTS + resultFileName);

+				testSuite.addTest(new PerfTestSuiteCaseGenerator(qFile, rFile));

+			}

+		}

+		return testSuite;

+	}

 

-    private static String hiveExtToResExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

-    }

+	private static String hiveExtToResExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

+	}

 

-    /**

-     * Runs the tests and collects their result in a TestResult.

-     */

-    @Override

-    public void run(TestResult result) {

+	/**

+	 * Runs the tests and collects their result in a TestResult.

+	 */

+	@Override

+	public void run(TestResult result) {

 

-        int testCount = countTestCases();

-        for (int i = 0; i < testCount; i++) {

-            Test each = this.testAt(i);

-            if (result.shouldStop())

-                break;

-            runTest(each, result);

-        }

+		int testCount = countTestCases();

+		for (int i = 0; i < testCount; i++) {

+			Test each = this.testAt(i);

+			if (result.shouldStop())

+				break;

+			runTest(each, result);

+		}

 

-        // cleanup hdfs and hyracks cluster

-        try {

-            cleanup();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

-    }

+		// cleanup hdfs and hyracks cluster

+		try {

+			cleanup();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestCase.java
index 7e7db36..f55d6a1 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestCase.java
@@ -10,40 +10,43 @@
 import junit.framework.TestCase;

 

 public class AbstractPerfTestCase extends TestCase {

-    protected File queryFile;

+	protected File queryFile;

 

-    public AbstractPerfTestCase(String testName, File queryFile) {

-        super(testName);

-    }

+	public AbstractPerfTestCase(String testName, File queryFile) {

+		super(testName);

+	}

 

-    protected static void readFileToString(File file, StringBuilder buf) throws Exception {

-        BufferedReader result = new BufferedReader(new FileReader(file));

-        while (true) {

-            String s = result.readLine();

-            if (s == null) {

-                break;

-            } else {

-                buf.append(s);

-                buf.append('\n');

-            }

-        }

-        result.close();

-    }

+	protected static void readFileToString(File file, StringBuilder buf)

+			throws Exception {

+		BufferedReader result = new BufferedReader(new FileReader(file));

+		while (true) {

+			String s = result.readLine();

+			if (s == null) {

+				break;

+			} else {

+				buf.append(s);

+				buf.append('\n');

+			}

+		}

+		result.close();

+	}

 

-    protected static void writeStringToFile(File file, StringWriter buf) throws Exception {

-        PrintWriter result = new PrintWriter(new FileWriter(file));

-        result.print(buf);

-        result.close();

-    }

+	protected static void writeStringToFile(File file, StringWriter buf)

+			throws Exception {

+		PrintWriter result = new PrintWriter(new FileWriter(file));

+		result.print(buf);

+		result.close();

+	}

 

-    protected static void writeStringToFile(File file, StringBuilder buf) throws Exception {

-        PrintWriter result = new PrintWriter(new FileWriter(file));

-        result.print(buf);

-        result.close();

-    }

+	protected static void writeStringToFile(File file, StringBuilder buf)

+			throws Exception {

+		PrintWriter result = new PrintWriter(new FileWriter(file));

+		result.print(buf);

+		result.close();

+	}

 

-    protected static String removeExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot);

-    }

+	protected static String removeExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot);

+	}

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestSuiteClass.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestSuiteClass.java
index df947ea..3f6d560 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestSuiteClass.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/perf/base/AbstractPerfTestSuiteClass.java
@@ -31,177 +31,181 @@
 

 public abstract class AbstractPerfTestSuiteClass extends TestSuite {

 

-    private static final String PATH_TO_HADOOP_CONF = "src/test/resources/perf/hadoop/conf";

-    private static final String PATH_TO_HIVE_CONF = "src/test/resources/perf/hive/conf/hive-default.xml";

+	private static final String PATH_TO_HADOOP_CONF = "src/test/resources/perf/hadoop/conf";

+	private static final String PATH_TO_HIVE_CONF = "src/test/resources/perf/hive/conf/hive-default.xml";

 

-    private static final String PATH_TO_CLUSTER_CONF = "src/test/resources/perf/conf/cluster";

-    private static final String PATH_TO_DATA = "src/test/resources/perf/data/";

+	private static final String PATH_TO_CLUSTER_CONF = "src/test/resources/perf/conf/cluster";

+	private static final String PATH_TO_DATA = "src/test/resources/perf/data/";

 

-    private MiniDFSCluster dfsCluster;

-    private MiniMRCluster mrCluster;

+	private MiniDFSCluster dfsCluster;

+	private MiniMRCluster mrCluster;

 

-    private JobConf conf = new JobConf();

-    protected FileSystem dfs;

+	private JobConf conf = new JobConf();

+	protected FileSystem dfs;

 

-    private int numberOfNC = 2;

-    private ClusterControllerService cc;

-    private Map<String, NodeControllerService> ncs = new HashMap<String, NodeControllerService>();

+	private int numberOfNC = 2;

+	private ClusterControllerService cc;

+	private Map<String, NodeControllerService> ncs = new HashMap<String, NodeControllerService>();

 

-    /**

-     * setup cluster

-     * 

-     * @throws IOException

-     */

-    protected void setup() throws Exception {

-        setupHdfs();

-        setupHyracks();

-    }

+	/**

+	 * setup cluster

+	 * 

+	 * @throws IOException

+	 */

+	protected void setup() throws Exception {

+		setupHdfs();

+		setupHyracks();

+	}

 

-    private void setupHdfs() throws IOException {

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));

-        HiveConf hconf = new HiveConf(SessionState.class);

-        hconf.addResource(new Path(PATH_TO_HIVE_CONF));

+	private void setupHdfs() throws IOException {

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));

+		HiveConf hconf = new HiveConf(SessionState.class);

+		hconf.addResource(new Path(PATH_TO_HIVE_CONF));

 

-        FileSystem lfs = FileSystem.getLocal(new Configuration());

-        lfs.delete(new Path("build"), true);

-        lfs.delete(new Path("metastore_db"), true);

+		FileSystem lfs = FileSystem.getLocal(new Configuration());

+		lfs.delete(new Path("build"), true);

+		lfs.delete(new Path("metastore_db"), true);

 

-        System.setProperty("hadoop.log.dir", "logs");

-        dfsCluster = new MiniDFSCluster(hconf, numberOfNC, true, null);

-        dfs = dfsCluster.getFileSystem();

+		System.setProperty("hadoop.log.dir", "logs");

+		dfsCluster = new MiniDFSCluster(hconf, numberOfNC, true, null);

+		dfs = dfsCluster.getFileSystem();

 

-        mrCluster = new MiniMRCluster(2, dfs.getUri().toString(), 1);

-        hconf.setVar(HiveConf.ConfVars.HADOOPJT, "localhost:" + mrCluster.getJobTrackerPort());

-        hconf.setInt("mapred.min.split.size", 1342177280);

+		mrCluster = new MiniMRCluster(2, dfs.getUri().toString(), 1);

+		hconf.setVar(HiveConf.ConfVars.HADOOPJT,

+				"localhost:" + mrCluster.getJobTrackerPort());

+		hconf.setInt("mapred.min.split.size", 1342177280);

 

-        conf = new JobConf(hconf);

-        ConfUtil.setJobConf(conf);

+		conf = new JobConf(hconf);

+		ConfUtil.setJobConf(conf);

 

-        String fsName = conf.get("fs.default.name");

-        hconf.set("hive.metastore.warehouse.dir", fsName.concat("/tmp/hivesterix"));

-        String warehouse = hconf.get("hive.metastore.warehouse.dir");

-        dfs.mkdirs(new Path(warehouse));

-        ConfUtil.setHiveConf(hconf);

-    }

+		String fsName = conf.get("fs.default.name");

+		hconf.set("hive.metastore.warehouse.dir",

+				fsName.concat("/tmp/hivesterix"));

+		String warehouse = hconf.get("hive.metastore.warehouse.dir");

+		dfs.mkdirs(new Path(warehouse));

+		ConfUtil.setHiveConf(hconf);

+	}

 

-    private void setupHyracks() throws Exception {

-        // read hive conf

-        HiveConf hconf = new HiveConf(SessionState.class);

-        hconf.addResource(new Path(PATH_TO_HIVE_CONF));

-        SessionState.start(hconf);

-        String ipAddress = hconf.get("hive.hyracks.host");

-        int clientPort = Integer.parseInt(hconf.get("hive.hyracks.port"));

-        int clusterPort = clientPort;

-        String applicationName = hconf.get("hive.hyracks.app");

+	private void setupHyracks() throws Exception {

+		// read hive conf

+		HiveConf hconf = new HiveConf(SessionState.class);

+		hconf.addResource(new Path(PATH_TO_HIVE_CONF));

+		SessionState.start(hconf);

+		String ipAddress = hconf.get("hive.hyracks.host");

+		int clientPort = Integer.parseInt(hconf.get("hive.hyracks.port"));

+		int clusterPort = clientPort;

+		String applicationName = hconf.get("hive.hyracks.app");

 

-        // start hyracks cc

-        CCConfig ccConfig = new CCConfig();

-        ccConfig.clientNetIpAddress = ipAddress;

-        ccConfig.clientNetPort = clientPort;

-        ccConfig.clusterNetPort = clusterPort;

-        ccConfig.profileDumpPeriod = 1000;

-        ccConfig.heartbeatPeriod = 200000000;

-        ccConfig.maxHeartbeatLapsePeriods = 200000000;

-        cc = new ClusterControllerService(ccConfig);

-        cc.start();

+		// start hyracks cc

+		CCConfig ccConfig = new CCConfig();

+		ccConfig.clientNetIpAddress = ipAddress;

+		ccConfig.clientNetPort = clientPort;

+		ccConfig.clusterNetPort = clusterPort;

+		ccConfig.profileDumpPeriod = 1000;

+		ccConfig.heartbeatPeriod = 200000000;

+		ccConfig.maxHeartbeatLapsePeriods = 200000000;

+		cc = new ClusterControllerService(ccConfig);

+		cc.start();

 

-        // start hyracks nc

-        for (int i = 0; i < numberOfNC; i++) {

-            NCConfig ncConfig = new NCConfig();

-            ncConfig.ccHost = ipAddress;

-            ncConfig.clusterNetIPAddress = ipAddress;

-            ncConfig.ccPort = clientPort;

-            ncConfig.dataIPAddress = "127.0.0.1";

-            ncConfig.nodeId = "nc" + i;

-            NodeControllerService nc = new NodeControllerService(ncConfig);

-            nc.start();

-            ncs.put(ncConfig.nodeId, nc);

-        }

+		// start hyracks nc

+		for (int i = 0; i < numberOfNC; i++) {

+			NCConfig ncConfig = new NCConfig();

+			ncConfig.ccHost = ipAddress;

+			ncConfig.clusterNetIPAddress = ipAddress;

+			ncConfig.ccPort = clientPort;

+			ncConfig.dataIPAddress = "127.0.0.1";

+			ncConfig.nodeId = "nc" + i;

+			NodeControllerService nc = new NodeControllerService(ncConfig);

+			nc.start();

+			ncs.put(ncConfig.nodeId, nc);

+		}

 

-        IHyracksClientConnection hcc = new HyracksConnection(ccConfig.clientNetIpAddress, clientPort);

-        hcc.createApplication(applicationName, null);

-    }

+		IHyracksClientConnection hcc = new HyracksConnection(

+				ccConfig.clientNetIpAddress, clientPort);

+		hcc.createApplication(applicationName, null);

+	}

 

-    protected void makeDir(String path) throws IOException {

-        dfs.mkdirs(new Path(path));

-    }

+	protected void makeDir(String path) throws IOException {

+		dfs.mkdirs(new Path(path));

+	}

 

-    protected void loadFiles(String src, String dest) throws IOException {

-        dfs.copyFromLocalFile(new Path(src), new Path(dest));

-    }

+	protected void loadFiles(String src, String dest) throws IOException {

+		dfs.copyFromLocalFile(new Path(src), new Path(dest));

+	}

 

-    protected void cleanup() throws Exception {

-        cleanupHdfs();

-        cleanupHyracks();

-    }

+	protected void cleanup() throws Exception {

+		cleanupHdfs();

+		cleanupHyracks();

+	}

 

-    /**

-     * cleanup hdfs cluster

-     */

-    private void cleanupHdfs() throws IOException {

-        dfs.delete(new Path("/"), true);

-        FileSystem.closeAll();

-        dfsCluster.shutdown();

-    }

+	/**

+	 * cleanup hdfs cluster

+	 */

+	private void cleanupHdfs() throws IOException {

+		dfs.delete(new Path("/"), true);

+		FileSystem.closeAll();

+		dfsCluster.shutdown();

+	}

 

-    /**

-     * cleanup hyracks cluster

-     */

-    private void cleanupHyracks() throws Exception {

-        Iterator<NodeControllerService> iterator = ncs.values().iterator();

-        while (iterator.hasNext()) {

-            NodeControllerService nc = iterator.next();

-            nc.stop();

-        }

-        cc.stop();

-    }

+	/**

+	 * cleanup hyracks cluster

+	 */

+	private void cleanupHyracks() throws Exception {

+		Iterator<NodeControllerService> iterator = ncs.values().iterator();

+		while (iterator.hasNext()) {

+			NodeControllerService nc = iterator.next();

+			nc.stop();

+		}

+		cc.stop();

+	}

 

-    protected static List<String> getIgnoreList(String ignorePath) throws FileNotFoundException, IOException {

-        BufferedReader reader = new BufferedReader(new FileReader(ignorePath));

-        String s = null;

-        List<String> ignores = new ArrayList<String>();

-        while ((s = reader.readLine()) != null) {

-            ignores.add(s);

-        }

-        reader.close();

-        return ignores;

-    }

+	protected static List<String> getIgnoreList(String ignorePath)

+			throws FileNotFoundException, IOException {

+		BufferedReader reader = new BufferedReader(new FileReader(ignorePath));

+		String s = null;

+		List<String> ignores = new ArrayList<String>();

+		while ((s = reader.readLine()) != null) {

+			ignores.add(s);

+		}

+		reader.close();

+		return ignores;

+	}

 

-    protected static boolean isIgnored(String q, List<String> ignoreList) {

-        for (String ignore : ignoreList) {

-            if (ignore.equals(q)) {

-                return true;

-            }

-        }

-        return false;

-    }

+	protected static boolean isIgnored(String q, List<String> ignoreList) {

+		for (String ignore : ignoreList) {

+			if (ignore.equals(q)) {

+				return true;

+			}

+		}

+		return false;

+	}

 

-    protected void loadData() throws IOException {

+	protected void loadData() throws IOException {

 

-        makeDir("/tpch");

-        makeDir("/tpch/customer");

-        makeDir("/tpch/lineitem");

-        makeDir("/tpch/orders");

-        makeDir("/tpch/part");

-        makeDir("/tpch/partsupp");

-        makeDir("/tpch/supplier");

-        makeDir("/tpch/nation");

-        makeDir("/tpch/region");

+		makeDir("/tpch");

+		makeDir("/tpch/customer");

+		makeDir("/tpch/lineitem");

+		makeDir("/tpch/orders");

+		makeDir("/tpch/part");

+		makeDir("/tpch/partsupp");

+		makeDir("/tpch/supplier");

+		makeDir("/tpch/nation");

+		makeDir("/tpch/region");

 

-        makeDir("/jarod");

+		makeDir("/jarod");

 

-        loadFiles(PATH_TO_DATA + "customer.tbl", "/tpch/customer/");

-        loadFiles(PATH_TO_DATA + "lineitem.tbl", "/tpch/lineitem/");

-        loadFiles(PATH_TO_DATA + "orders.tbl", "/tpch/orders/");

-        loadFiles(PATH_TO_DATA + "part.tbl", "/tpch/part/");

-        loadFiles(PATH_TO_DATA + "partsupp.tbl", "/tpch/partsupp/");

-        loadFiles(PATH_TO_DATA + "supplier.tbl", "/tpch/supplier/");

-        loadFiles(PATH_TO_DATA + "nation.tbl", "/tpch/nation/");

-        loadFiles(PATH_TO_DATA + "region.tbl", "/tpch/region/");

+		loadFiles(PATH_TO_DATA + "customer.tbl", "/tpch/customer/");

+		loadFiles(PATH_TO_DATA + "lineitem.tbl", "/tpch/lineitem/");

+		loadFiles(PATH_TO_DATA + "orders.tbl", "/tpch/orders/");

+		loadFiles(PATH_TO_DATA + "part.tbl", "/tpch/part/");

+		loadFiles(PATH_TO_DATA + "partsupp.tbl", "/tpch/partsupp/");

+		loadFiles(PATH_TO_DATA + "supplier.tbl", "/tpch/supplier/");

+		loadFiles(PATH_TO_DATA + "nation.tbl", "/tpch/nation/");

+		loadFiles(PATH_TO_DATA + "region.tbl", "/tpch/region/");

 

-        loadFiles(PATH_TO_DATA + "ext-gby.tbl", "/jarod/");

-    }

+		loadFiles(PATH_TO_DATA + "ext-gby.tbl", "/jarod/");

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractHivesterixTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractHivesterixTestCase.java
index ae5fa05..560cef7 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractHivesterixTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractHivesterixTestCase.java
@@ -10,40 +10,43 @@
 import junit.framework.TestCase;

 

 public class AbstractHivesterixTestCase extends TestCase {

-    protected File queryFile;

+	protected File queryFile;

 

-    public AbstractHivesterixTestCase(String testName, File queryFile) {

-        super(testName);

-    }

+	public AbstractHivesterixTestCase(String testName, File queryFile) {

+		super(testName);

+	}

 

-    protected static void readFileToString(File file, StringBuilder buf) throws Exception {

-        BufferedReader result = new BufferedReader(new FileReader(file));

-        while (true) {

-            String s = result.readLine();

-            if (s == null) {

-                break;

-            } else {

-                buf.append(s);

-                buf.append('\n');

-            }

-        }

-        result.close();

-    }

+	protected static void readFileToString(File file, StringBuilder buf)

+			throws Exception {

+		BufferedReader result = new BufferedReader(new FileReader(file));

+		while (true) {

+			String s = result.readLine();

+			if (s == null) {

+				break;

+			} else {

+				buf.append(s);

+				buf.append('\n');

+			}

+		}

+		result.close();

+	}

 

-    protected static void writeStringToFile(File file, StringWriter buf) throws Exception {

-        PrintWriter result = new PrintWriter(new FileWriter(file));

-        result.print(buf);

-        result.close();

-    }

+	protected static void writeStringToFile(File file, StringWriter buf)

+			throws Exception {

+		PrintWriter result = new PrintWriter(new FileWriter(file));

+		result.print(buf);

+		result.close();

+	}

 

-    protected static void writeStringToFile(File file, StringBuilder buf) throws Exception {

-        PrintWriter result = new PrintWriter(new FileWriter(file));

-        result.print(buf);

-        result.close();

-    }

+	protected static void writeStringToFile(File file, StringBuilder buf)

+			throws Exception {

+		PrintWriter result = new PrintWriter(new FileWriter(file));

+		result.print(buf);

+		result.close();

+	}

 

-    protected static String removeExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot);

-    }

+	protected static String removeExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot);

+	}

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractTestSuiteClass.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractTestSuiteClass.java
index 74bde3f..7742adb 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractTestSuiteClass.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/base/AbstractTestSuiteClass.java
@@ -32,180 +32,185 @@
 

 public abstract class AbstractTestSuiteClass extends TestSuite {

 

-    private static final String PATH_TO_HADOOP_CONF = "src/test/resources/runtimefunctionts/hadoop/conf";

-    private static final String PATH_TO_HIVE_CONF = "src/test/resources/runtimefunctionts/hive/conf/hive-default.xml";

+	private static final String PATH_TO_HADOOP_CONF = "src/test/resources/runtimefunctionts/hadoop/conf";

+	private static final String PATH_TO_HIVE_CONF = "src/test/resources/runtimefunctionts/hive/conf/hive-default.xml";

 

-    private static final String PATH_TO_CLUSTER_CONF = "src/test/resources/runtimefunctionts/hive/conf/topology.xml";

-    private static final String PATH_TO_DATA = "src/test/resources/runtimefunctionts/data/";

+	private static final String PATH_TO_CLUSTER_CONF = "src/test/resources/runtimefunctionts/hive/conf/topology.xml";

+	private static final String PATH_TO_DATA = "src/test/resources/runtimefunctionts/data/";

 

-    private MiniDFSCluster dfsCluster;

-    private MiniMRCluster mrCluster;

+	private MiniDFSCluster dfsCluster;

+	private MiniMRCluster mrCluster;

 

-    private JobConf conf = new JobConf();

-    protected FileSystem dfs;

+	private JobConf conf = new JobConf();

+	protected FileSystem dfs;

 

-    private int numberOfNC = 2;

-    private ClusterControllerService cc;

-    private Map<String, NodeControllerService> ncs = new HashMap<String, NodeControllerService>();

+	private int numberOfNC = 2;

+	private ClusterControllerService cc;

+	private Map<String, NodeControllerService> ncs = new HashMap<String, NodeControllerService>();

 

-    /**

-     * setup cluster

-     * 

-     * @throws IOException

-     */

-    protected void setup() throws Exception {

-        setupHdfs();

-        setupHyracks();

-    }

+	/**

+	 * setup cluster

+	 * 

+	 * @throws IOException

+	 */

+	protected void setup() throws Exception {

+		setupHdfs();

+		setupHyracks();

+	}

 

-    private void setupHdfs() throws IOException {

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));

-        conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));

-        HiveConf hconf = new HiveConf(SessionState.class);

-        hconf.addResource(new Path(PATH_TO_HIVE_CONF));

+	private void setupHdfs() throws IOException {

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/core-site.xml"));

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/mapred-site.xml"));

+		conf.addResource(new Path(PATH_TO_HADOOP_CONF + "/hdfs-site.xml"));

+		HiveConf hconf = new HiveConf(SessionState.class);

+		hconf.addResource(new Path(PATH_TO_HIVE_CONF));

 

-        FileSystem lfs = FileSystem.getLocal(new Configuration());

-        lfs.delete(new Path("build"), true);

-        lfs.delete(new Path("metastore_db"), true);

+		FileSystem lfs = FileSystem.getLocal(new Configuration());

+		lfs.delete(new Path("build"), true);

+		lfs.delete(new Path("metastore_db"), true);

 

-        System.setProperty("hadoop.log.dir", "logs");

-        dfsCluster = new MiniDFSCluster(hconf, numberOfNC, true, null);

-        dfs = dfsCluster.getFileSystem();

+		System.setProperty("hadoop.log.dir", "logs");

+		dfsCluster = new MiniDFSCluster(hconf, numberOfNC, true, null);

+		dfs = dfsCluster.getFileSystem();

 

-        mrCluster = new MiniMRCluster(2, dfs.getUri().toString(), 1);

-        hconf.setVar(HiveConf.ConfVars.HADOOPJT, "localhost:" + mrCluster.getJobTrackerPort());

+		mrCluster = new MiniMRCluster(2, dfs.getUri().toString(), 1);

+		hconf.setVar(HiveConf.ConfVars.HADOOPJT,

+				"localhost:" + mrCluster.getJobTrackerPort());

 

-        conf = new JobConf(hconf);

-        ConfUtil.setJobConf(conf);

+		conf = new JobConf(hconf);

+		ConfUtil.setJobConf(conf);

 

-        String fsName = conf.get("fs.default.name");

-        hconf.set("hive.metastore.warehouse.dir", fsName.concat("/tmp/hivesterix"));

-        String warehouse = hconf.get("hive.metastore.warehouse.dir");

-        dfs.mkdirs(new Path(warehouse));

-        ConfUtil.setHiveConf(hconf);

-    }

+		String fsName = conf.get("fs.default.name");

+		hconf.set("hive.metastore.warehouse.dir",

+				fsName.concat("/tmp/hivesterix"));

+		String warehouse = hconf.get("hive.metastore.warehouse.dir");

+		dfs.mkdirs(new Path(warehouse));

+		ConfUtil.setHiveConf(hconf);

+	}

 

-    private void setupHyracks() throws Exception {

-        // read hive conf

-        HiveConf hconf = new HiveConf(SessionState.class);

-        hconf.addResource(new Path(PATH_TO_HIVE_CONF));

-        SessionState.start(hconf);

-        String ipAddress = hconf.get("hive.hyracks.host");

-        int clientPort = Integer.parseInt(hconf.get("hive.hyracks.port"));

-        int netPort = clientPort + 1;

-        String applicationName = hconf.get("hive.hyracks.app");

+	private void setupHyracks() throws Exception {

+		// read hive conf

+		HiveConf hconf = new HiveConf(SessionState.class);

+		hconf.addResource(new Path(PATH_TO_HIVE_CONF));

+		SessionState.start(hconf);

+		String ipAddress = hconf.get("hive.hyracks.host");

+		int clientPort = Integer.parseInt(hconf.get("hive.hyracks.port"));

+		int netPort = clientPort + 1;

+		String applicationName = hconf.get("hive.hyracks.app");

 

-        // start hyracks cc

-        CCConfig ccConfig = new CCConfig();

-        ccConfig.clientNetIpAddress = ipAddress;

-        ccConfig.clientNetPort = clientPort;

-        ccConfig.clusterNetPort = netPort;

-        ccConfig.profileDumpPeriod = 1000;

-        ccConfig.heartbeatPeriod = 200000000;

-        ccConfig.maxHeartbeatLapsePeriods = 200000000;

-        ccConfig.clusterTopologyDefinition = new File(PATH_TO_CLUSTER_CONF);

-        cc = new ClusterControllerService(ccConfig);

-        cc.start();

+		// start hyracks cc

+		CCConfig ccConfig = new CCConfig();

+		ccConfig.clientNetIpAddress = ipAddress;

+		ccConfig.clientNetPort = clientPort;

+		ccConfig.clusterNetPort = netPort;

+		ccConfig.profileDumpPeriod = 1000;

+		ccConfig.heartbeatPeriod = 200000000;

+		ccConfig.maxHeartbeatLapsePeriods = 200000000;

+		ccConfig.clusterTopologyDefinition = new File(PATH_TO_CLUSTER_CONF);

+		cc = new ClusterControllerService(ccConfig);

+		cc.start();

 

-        // start hyracks nc

-        for (int i = 0; i < numberOfNC; i++) {

-            NCConfig ncConfig = new NCConfig();

-            ncConfig.ccHost = ipAddress;

-            ncConfig.clusterNetIPAddress = ipAddress;

-            ncConfig.ccPort = netPort;

-            ncConfig.dataIPAddress = "127.0.0.1";

-            ncConfig.nodeId = "nc" + i;

-            NodeControllerService nc = new NodeControllerService(ncConfig);

-            nc.start();

-            ncs.put(ncConfig.nodeId, nc);

-        }

+		// start hyracks nc

+		for (int i = 0; i < numberOfNC; i++) {

+			NCConfig ncConfig = new NCConfig();

+			ncConfig.ccHost = ipAddress;

+			ncConfig.clusterNetIPAddress = ipAddress;

+			ncConfig.ccPort = netPort;

+			ncConfig.dataIPAddress = "127.0.0.1";

+			ncConfig.nodeId = "nc" + i;

+			NodeControllerService nc = new NodeControllerService(ncConfig);

+			nc.start();

+			ncs.put(ncConfig.nodeId, nc);

+		}

 

-        IHyracksClientConnection hcc = new HyracksConnection(ccConfig.clientNetIpAddress, clientPort);

-        hcc.createApplication(applicationName, null);

-    }

+		IHyracksClientConnection hcc = new HyracksConnection(

+				ccConfig.clientNetIpAddress, clientPort);

+		hcc.createApplication(applicationName, null);

+	}

 

-    protected void makeDir(String path) throws IOException {

-        dfs.mkdirs(new Path(path));

-    }

+	protected void makeDir(String path) throws IOException {

+		dfs.mkdirs(new Path(path));

+	}

 

-    protected void loadFiles(String src, String dest) throws IOException {

-        dfs.copyFromLocalFile(new Path(src), new Path(dest));

-    }

+	protected void loadFiles(String src, String dest) throws IOException {

+		dfs.copyFromLocalFile(new Path(src), new Path(dest));

+	}

 

-    protected void cleanup() throws Exception {

-        cleanupHdfs();

-        cleanupHyracks();

-    }

+	protected void cleanup() throws Exception {

+		cleanupHdfs();

+		cleanupHyracks();

+	}

 

-    /**

-     * cleanup hdfs cluster

-     */

-    private void cleanupHdfs() throws IOException {

-        dfs.delete(new Path("/"), true);

-        FileSystem.closeAll();

-        dfsCluster.shutdown();

-    }

+	/**

+	 * cleanup hdfs cluster

+	 */

+	private void cleanupHdfs() throws IOException {

+		dfs.delete(new Path("/"), true);

+		FileSystem.closeAll();

+		dfsCluster.shutdown();

+	}

 

-    /**

-     * cleanup hyracks cluster

-     */

-    private void cleanupHyracks() throws Exception {

-        Iterator<NodeControllerService> iterator = ncs.values().iterator();

-        while (iterator.hasNext()) {

-            NodeControllerService nc = iterator.next();

-            nc.stop();

-        }

-        cc.stop();

-    }

+	/**

+	 * cleanup hyracks cluster

+	 */

+	private void cleanupHyracks() throws Exception {

+		Iterator<NodeControllerService> iterator = ncs.values().iterator();

+		while (iterator.hasNext()) {

+			NodeControllerService nc = iterator.next();

+			nc.stop();

+		}

+		cc.stop();

+	}

 

-    protected static List<String> getIgnoreList(String ignorePath) throws FileNotFoundException, IOException {

-        BufferedReader reader = new BufferedReader(new FileReader(ignorePath));

-        String s = null;

-        List<String> ignores = new ArrayList<String>();

-        while ((s = reader.readLine()) != null) {

-            ignores.add(s);

-        }

-        reader.close();

-        return ignores;

-    }

+	protected static List<String> getIgnoreList(String ignorePath)

+			throws FileNotFoundException, IOException {

+		BufferedReader reader = new BufferedReader(new FileReader(ignorePath));

+		String s = null;

+		List<String> ignores = new ArrayList<String>();

+		while ((s = reader.readLine()) != null) {

+			ignores.add(s);

+		}

+		reader.close();

+		return ignores;

+	}

 

-    protected static boolean isIgnored(String q, List<String> ignoreList) {

-        for (String ignore : ignoreList) {

-            if (ignore.equals(q)) {

-                return true;

-            }

-        }

-        return false;

-    }

+	protected static boolean isIgnored(String q, List<String> ignoreList) {

+		for (String ignore : ignoreList) {

+			if (ignore.equals(q)) {

+				return true;

+			}

+		}

+		return false;

+	}

 

-    protected void loadData() throws IOException {

+	protected void loadData() throws IOException {

 

-        makeDir("/tpch");

-        makeDir("/tpch/customer");

-        makeDir("/tpch/lineitem");

-        makeDir("/tpch/orders");

-        makeDir("/tpch/part");

-        makeDir("/tpch/partsupp");

-        makeDir("/tpch/supplier");

-        makeDir("/tpch/nation");

-        makeDir("/tpch/region");

+		makeDir("/tpch");

+		makeDir("/tpch/customer");

+		makeDir("/tpch/lineitem");

+		makeDir("/tpch/orders");

+		makeDir("/tpch/part");

+		makeDir("/tpch/partsupp");

+		makeDir("/tpch/supplier");

+		makeDir("/tpch/nation");

+		makeDir("/tpch/region");

 

-        makeDir("/test");

-        makeDir("/test/joinsrc1");

-        makeDir("/test/joinsrc2");

+		makeDir("/test");

+		makeDir("/test/joinsrc1");

+		makeDir("/test/joinsrc2");

 

-        loadFiles(PATH_TO_DATA + "customer.tbl", "/tpch/customer/");

-        loadFiles(PATH_TO_DATA + "lineitem.tbl", "/tpch/lineitem/");

-        loadFiles(PATH_TO_DATA + "orders.tbl", "/tpch/orders/");

-        loadFiles(PATH_TO_DATA + "part.tbl", "/tpch/part/");

-        loadFiles(PATH_TO_DATA + "partsupp.tbl", "/tpch/partsupp/");

-        loadFiles(PATH_TO_DATA + "supplier.tbl", "/tpch/supplier/");

-        loadFiles(PATH_TO_DATA + "nation.tbl", "/tpch/nation/");

-        loadFiles(PATH_TO_DATA + "region.tbl", "/tpch/region/");

+		loadFiles(PATH_TO_DATA + "customer.tbl", "/tpch/customer/");

+		loadFiles(PATH_TO_DATA + "lineitem.tbl", "/tpch/lineitem/");

+		loadFiles(PATH_TO_DATA + "orders.tbl", "/tpch/orders/");

+		loadFiles(PATH_TO_DATA + "part.tbl", "/tpch/part/");

+		loadFiles(PATH_TO_DATA + "partsupp.tbl", "/tpch/partsupp/");

+		loadFiles(PATH_TO_DATA + "supplier.tbl", "/tpch/supplier/");

+		loadFiles(PATH_TO_DATA + "nation.tbl", "/tpch/nation/");

+		loadFiles(PATH_TO_DATA + "region.tbl", "/tpch/region/");

 

-        loadFiles(PATH_TO_DATA + "large_card_join_src.tbl", "/test/joinsrc1/");

-        loadFiles(PATH_TO_DATA + "large_card_join_src_small.tbl", "/test/joinsrc2/");

-    }

+		loadFiles(PATH_TO_DATA + "large_card_join_src.tbl", "/test/joinsrc1/");

+		loadFiles(PATH_TO_DATA + "large_card_join_src_small.tbl",

+				"/test/joinsrc2/");

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/datagen/RecordBalance.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/datagen/RecordBalance.java
index e5746bb..9241dc5 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/datagen/RecordBalance.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/datagen/RecordBalance.java
@@ -20,55 +20,62 @@
 
 public class RecordBalance {
 
-    private static String confPath = System.getenv("HADDOP_HOME");
-    private static Path[] inputPaths = { new Path("/tpch/100x/customer"), new Path("/tpch/100x/nation"),
-            new Path("/tpch/100x/region"), new Path("/tpch/100x/lineitem"), new Path("/tpch/100x/orders"),
-            new Path("/tpch/100x/part"), new Path("/tpch/100x/partsupp"), new Path("/tpch/100x/supplier") };
+	private static String confPath = System.getenv("HADDOP_HOME");
+	private static Path[] inputPaths = { new Path("/tpch/100x/customer"),
+			new Path("/tpch/100x/nation"), new Path("/tpch/100x/region"),
+			new Path("/tpch/100x/lineitem"), new Path("/tpch/100x/orders"),
+			new Path("/tpch/100x/part"), new Path("/tpch/100x/partsupp"),
+			new Path("/tpch/100x/supplier") };
 
-    private static Path[] outputPaths = { new Path("/tpch/100/customer"), new Path("/tpch/100/nation"),
-            new Path("/tpch/100/region"), new Path("/tpch/100/lineitem"), new Path("/tpch/100/orders"),
-            new Path("/tpch/100/part"), new Path("/tpch/100/partsupp"), new Path("/tpch/100/supplier") };
+	private static Path[] outputPaths = { new Path("/tpch/100/customer"),
+			new Path("/tpch/100/nation"), new Path("/tpch/100/region"),
+			new Path("/tpch/100/lineitem"), new Path("/tpch/100/orders"),
+			new Path("/tpch/100/part"), new Path("/tpch/100/partsupp"),
+			new Path("/tpch/100/supplier") };
 
-    public static class MapRecordOnly extends MapReduceBase implements Mapper<LongWritable, Text, LongWritable, Text> {
+	public static class MapRecordOnly extends MapReduceBase implements
+			Mapper<LongWritable, Text, LongWritable, Text> {
 
-        public void map(LongWritable id, Text inputValue, OutputCollector<LongWritable, Text> output, Reporter reporter)
-                throws IOException {
-            output.collect(id, inputValue);
-        }
-    }
+		public void map(LongWritable id, Text inputValue,
+				OutputCollector<LongWritable, Text> output, Reporter reporter)
+				throws IOException {
+			output.collect(id, inputValue);
+		}
+	}
 
-    public static class ReduceRecordOnly extends MapReduceBase implements
-            Reducer<LongWritable, Text, NullWritable, Text> {
+	public static class ReduceRecordOnly extends MapReduceBase implements
+			Reducer<LongWritable, Text, NullWritable, Text> {
 
-        NullWritable key = NullWritable.get();
+		NullWritable key = NullWritable.get();
 
-        public void reduce(LongWritable inputKey, Iterator<Text> inputValue,
-                OutputCollector<NullWritable, Text> output, Reporter reporter) throws IOException {
-            while (inputValue.hasNext())
-                output.collect(key, inputValue.next());
-        }
-    }
+		public void reduce(LongWritable inputKey, Iterator<Text> inputValue,
+				OutputCollector<NullWritable, Text> output, Reporter reporter)
+				throws IOException {
+			while (inputValue.hasNext())
+				output.collect(key, inputValue.next());
+		}
+	}
 
-    public static void main(String[] args) throws IOException {
+	public static void main(String[] args) throws IOException {
 
-        for (int i = 0; i < inputPaths.length; i++) {
-            JobConf job = new JobConf(RecordBalance.class);
-            job.addResource(new Path(confPath + "/core-site.xml"));
-            job.addResource(new Path(confPath + "/mapred-site.xml"));
-            job.addResource(new Path(confPath + "/hdfs-site.xml"));
+		for (int i = 0; i < inputPaths.length; i++) {
+			JobConf job = new JobConf(RecordBalance.class);
+			job.addResource(new Path(confPath + "/core-site.xml"));
+			job.addResource(new Path(confPath + "/mapred-site.xml"));
+			job.addResource(new Path(confPath + "/hdfs-site.xml"));
 
-            job.setJobName(RecordBalance.class.getSimpleName());
-            job.setMapperClass(MapRecordOnly.class);
-            job.setReducerClass(ReduceRecordOnly.class);
-            job.setMapOutputKeyClass(LongWritable.class);
-            job.setMapOutputValueClass(Text.class);
+			job.setJobName(RecordBalance.class.getSimpleName());
+			job.setMapperClass(MapRecordOnly.class);
+			job.setReducerClass(ReduceRecordOnly.class);
+			job.setMapOutputKeyClass(LongWritable.class);
+			job.setMapOutputValueClass(Text.class);
 
-            job.setInputFormat(TextInputFormat.class);
-            FileInputFormat.setInputPaths(job, inputPaths[i]);
-            FileOutputFormat.setOutputPath(job, outputPaths[i]);
-            job.setNumReduceTasks(Integer.parseInt(args[0]));
+			job.setInputFormat(TextInputFormat.class);
+			FileInputFormat.setInputPaths(job, inputPaths[i]);
+			FileOutputFormat.setOutputPath(job, outputPaths[i]);
+			job.setNumReduceTasks(Integer.parseInt(args[0]));
 
-            JobClient.runJob(job);
-        }
-    }
+			JobClient.runJob(job);
+		}
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/legacy/LegacyTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/legacy/LegacyTestCase.java
index a286747..9591c32 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/legacy/LegacyTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/legacy/LegacyTestCase.java
@@ -15,128 +15,130 @@
 import edu.uci.ics.hivesterix.test.base.AbstractHivesterixTestCase;
 
 public class LegacyTestCase extends AbstractHivesterixTestCase {
-    private File resultFile;
-    private FileSystem dfs;
+	private File resultFile;
+	private FileSystem dfs;
 
-    public LegacyTestCase(File queryFile, File resultFile) {
-        super("legacy", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	public LegacyTestCase(File queryFile, File resultFile) {
+		super("legacy", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testRuntimeFunction() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	@Test
+	public void testRuntimeFunction() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
 
-        dfs = FileSystem.get(ConfUtil.getJobConf());
+		dfs = FileSystem.get(ConfUtil.getJobConf());
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            driver.run(query);
-            driver.clear();
-            i++;
-        }
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			driver.run(query);
+			driver.clear();
+			i++;
+		}
 
-        String warehouse = hconf.get("hive.metastore.warehouse.dir");
-        String tableName = removeExt(resultFile.getName());
-        String directory = warehouse + "/" + tableName + "/";
-        String localDirectory = "tmp";
+		String warehouse = hconf.get("hive.metastore.warehouse.dir");
+		String tableName = removeExt(resultFile.getName());
+		String directory = warehouse + "/" + tableName + "/";
+		String localDirectory = "tmp";
 
-        FileStatus[] files = dfs.listStatus(new Path(directory));
-        FileSystem lfs = null;
-        if (files == null) {
-            lfs = FileSystem.getLocal(ConfUtil.getJobConf());
-            files = lfs.listStatus(new Path(directory));
-        }
+		FileStatus[] files = dfs.listStatus(new Path(directory));
+		FileSystem lfs = null;
+		if (files == null) {
+			lfs = FileSystem.getLocal(ConfUtil.getJobConf());
+			files = lfs.listStatus(new Path(directory));
+		}
 
-        File resultDirectory = new File(localDirectory + "/" + tableName);
-        deleteDir(resultDirectory);
-        resultDirectory.mkdir();
+		File resultDirectory = new File(localDirectory + "/" + tableName);
+		deleteDir(resultDirectory);
+		resultDirectory.mkdir();
 
-        for (FileStatus fs : files) {
-            Path src = fs.getPath();
-            if (src.getName().indexOf("crc") >= 0)
-                continue;
+		for (FileStatus fs : files) {
+			Path src = fs.getPath();
+			if (src.getName().indexOf("crc") >= 0)
+				continue;
 
-            String destStr = localDirectory + "/" + tableName + "/" + src.getName();
-            Path dest = new Path(destStr);
-            if (lfs != null) {
-                lfs.copyToLocalFile(src, dest);
-                dfs.copyFromLocalFile(dest, new Path(directory));
-            } else
-                dfs.copyToLocalFile(src, dest);
-        }
+			String destStr = localDirectory + "/" + tableName + "/"
+					+ src.getName();
+			Path dest = new Path(destStr);
+			if (lfs != null) {
+				lfs.copyToLocalFile(src, dest);
+				dfs.copyFromLocalFile(dest, new Path(directory));
+			} else
+				dfs.copyToLocalFile(src, dest);
+		}
 
-        File[] rFiles = resultDirectory.listFiles();
-        StringBuilder sb = new StringBuilder();
-        for (File r : rFiles) {
-            if (r.getName().indexOf("crc") >= 0)
-                continue;
-            readFileToString(r, sb);
-        }
-        deleteDir(resultDirectory);
+		File[] rFiles = resultDirectory.listFiles();
+		StringBuilder sb = new StringBuilder();
+		for (File r : rFiles) {
+			if (r.getName().indexOf("crc") >= 0)
+				continue;
+			readFileToString(r, sb);
+		}
+		deleteDir(resultDirectory);
 
-        StringBuilder buf = new StringBuilder();
-        readFileToString(resultFile, buf);
-        if (!equal(buf, sb)) {
-            throw new Exception("Result for " + queryFile + " changed:\n" + sw.toString());
-        }
-    }
+		StringBuilder buf = new StringBuilder();
+		readFileToString(resultFile, buf);
+		if (!equal(buf, sb)) {
+			throw new Exception("Result for " + queryFile + " changed:\n"
+					+ sw.toString());
+		}
+	}
 
-    private void deleteDir(File resultDirectory) {
-        if (resultDirectory.exists()) {
-            File[] rFiles = resultDirectory.listFiles();
-            for (File r : rFiles)
-                r.delete();
-            resultDirectory.delete();
-        }
-    }
+	private void deleteDir(File resultDirectory) {
+		if (resultDirectory.exists()) {
+			File[] rFiles = resultDirectory.listFiles();
+			for (File r : rFiles)
+				r.delete();
+			resultDirectory.delete();
+		}
+	}
 
-    private boolean equal(StringBuilder sb1, StringBuilder sb2) {
-        String s1 = sb1.toString();
-        String s2 = sb2.toString();
-        String[] rowsOne = s1.split("\n");
-        String[] rowsTwo = s2.split("\n");
+	private boolean equal(StringBuilder sb1, StringBuilder sb2) {
+		String s1 = sb1.toString();
+		String s2 = sb2.toString();
+		String[] rowsOne = s1.split("\n");
+		String[] rowsTwo = s2.split("\n");
 
-        if (rowsOne.length != rowsTwo.length)
-            return false;
+		if (rowsOne.length != rowsTwo.length)
+			return false;
 
-        for (int i = 0; i < rowsOne.length; i++) {
-            String row1 = rowsOne[i];
-            String row2 = rowsTwo[i];
+		for (int i = 0; i < rowsOne.length; i++) {
+			String row1 = rowsOne[i];
+			String row2 = rowsTwo[i];
 
-            if (row1.equals(row2))
-                continue;
+			if (row1.equals(row2))
+				continue;
 
-            String[] fields1 = row1.split("");
-            String[] fields2 = row2.split("");
+			String[] fields1 = row1.split("");
+			String[] fields2 = row2.split("");
 
-            for (int j = 0; j < fields1.length; j++) {
-                if (fields1[j].equals(fields2[j])) {
-                    continue;
-                } else if (fields1[j].indexOf('.') < 0) {
-                    return false;
-                } else {
-                    Float float1 = Float.parseFloat(fields1[j]);
-                    Float float2 = Float.parseFloat(fields2[j]);
+			for (int j = 0; j < fields1.length; j++) {
+				if (fields1[j].equals(fields2[j])) {
+					continue;
+				} else if (fields1[j].indexOf('.') < 0) {
+					return false;
+				} else {
+					Float float1 = Float.parseFloat(fields1[j]);
+					Float float2 = Float.parseFloat(fields2[j]);
 
-                    if (Math.abs(float1 - float2) == 0)
-                        continue;
-                    else
-                        return false;
-                }
-            }
-        }
+					if (Math.abs(float1 - float2) == 0)
+						continue;
+					else
+						return false;
+				}
+			}
+		}
 
-        return true;
-    }
+		return true;
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestCase.java
index f80405f..db13676 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestCase.java
@@ -12,42 +12,46 @@
 import edu.uci.ics.hivesterix.test.base.AbstractHivesterixTestCase;
 
 public class OptimizerTestCase extends AbstractHivesterixTestCase {
-    private File resultFile;
+	private File resultFile;
 
-    OptimizerTestCase(File queryFile, File resultFile) {
-        super("testOptimizer", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	OptimizerTestCase(File queryFile, File resultFile) {
+		super("testOptimizer", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testOptimizer() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	@Test
+	public void testOptimizer() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            if (query.toLowerCase().indexOf("create") >= 0 || query.toLowerCase().indexOf("drop") >= 0
-                    || query.toLowerCase().indexOf("set") >= 0 || query.toLowerCase().startsWith("\n\ncreate")
-                    || query.toLowerCase().startsWith("\n\ndrop") || query.toLowerCase().startsWith("\n\nset"))
-                driver.run(query);
-            else
-                driver.compile(query);
-            driver.clear();
-            i++;
-        }
-        StringBuilder buf = new StringBuilder();
-        readFileToString(resultFile, buf);
-        if (!buf.toString().equals(sw.toString())) {
-            throw new Exception("Result for " + queryFile + " changed:\n" + sw.toString());
-        }
-    }
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			if (query.toLowerCase().indexOf("create") >= 0
+					|| query.toLowerCase().indexOf("drop") >= 0
+					|| query.toLowerCase().indexOf("set") >= 0
+					|| query.toLowerCase().startsWith("\n\ncreate")
+					|| query.toLowerCase().startsWith("\n\ndrop")
+					|| query.toLowerCase().startsWith("\n\nset"))
+				driver.run(query);
+			else
+				driver.compile(query);
+			driver.clear();
+			i++;
+		}
+		StringBuilder buf = new StringBuilder();
+		readFileToString(resultFile, buf);
+		if (!buf.toString().equals(sw.toString())) {
+			throw new Exception("Result for " + queryFile + " changed:\n"
+					+ sw.toString());
+		}
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuitGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuitGenerator.java
index c6b788f..217f67d 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuitGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuitGenerator.java
@@ -11,65 +11,67 @@
 import edu.uci.ics.hivesterix.test.base.AbstractTestSuiteClass;
 
 public class OptimizerTestSuitGenerator extends AbstractTestSuiteClass {
-    private static final String PATH_TO_QUERIES = "src/test/resources/optimizerts/queries/";
-    private static final String PATH_TO_RESULTS = "src/test/resources/optimizerts/results/";
-    private static final String PATH_TO_IGNORES = "src/test/resources/optimizerts/ignore.txt";
+	private static final String PATH_TO_QUERIES = "src/test/resources/optimizerts/queries/";
+	private static final String PATH_TO_RESULTS = "src/test/resources/optimizerts/results/";
+	private static final String PATH_TO_IGNORES = "src/test/resources/optimizerts/ignore.txt";
 
-    private static final String FILE_EXTENSION_OF_RESULTS = "plan";
+	private static final String FILE_EXTENSION_OF_RESULTS = "plan";
 
-    public static Test suite() throws UnsupportedEncodingException, FileNotFoundException, IOException {
-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);
-        File testData = new File(PATH_TO_QUERIES);
-        File[] queries = testData.listFiles();
-        OptimizerTestSuitGenerator testSuite = new OptimizerTestSuitGenerator();
-        // set hdfs and hyracks cluster, and load test data to hdfs
-        try {
-            testSuite.setup();
-            testSuite.loadData();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new IllegalStateException(e.getMessage());
-        }
+	public static Test suite() throws UnsupportedEncodingException,
+			FileNotFoundException, IOException {
+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);
+		File testData = new File(PATH_TO_QUERIES);
+		File[] queries = testData.listFiles();
+		OptimizerTestSuitGenerator testSuite = new OptimizerTestSuitGenerator();
+		// set hdfs and hyracks cluster, and load test data to hdfs
+		try {
+			testSuite.setup();
+			testSuite.loadData();
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new IllegalStateException(e.getMessage());
+		}
 
-        for (File qFile : queries) {
-            if (isIgnored(qFile.getName(), ignores))
-                continue;
+		for (File qFile : queries) {
+			if (isIgnored(qFile.getName(), ignores))
+				continue;
 
-            if (qFile.isFile()) {
-                String resultFileName = aqlExtToResExt(qFile.getName());
-                File rFile = new File(PATH_TO_RESULTS + resultFileName);
-                testSuite.addTest(new OptimizerTestSuiteCaseGenerator(qFile, rFile));
-            }
-        }
-        return testSuite;
-    }
+			if (qFile.isFile()) {
+				String resultFileName = aqlExtToResExt(qFile.getName());
+				File rFile = new File(PATH_TO_RESULTS + resultFileName);
+				testSuite.addTest(new OptimizerTestSuiteCaseGenerator(qFile,
+						rFile));
+			}
+		}
+		return testSuite;
+	}
 
-    private static String aqlExtToResExt(String fname) {
-        int dot = fname.lastIndexOf('.');
-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;
-    }
+	private static String aqlExtToResExt(String fname) {
+		int dot = fname.lastIndexOf('.');
+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;
+	}
 
-    /**
-     * Runs the tests and collects their result in a TestResult.
-     */
-    @Override
-    public void run(TestResult result) {
+	/**
+	 * Runs the tests and collects their result in a TestResult.
+	 */
+	@Override
+	public void run(TestResult result) {
 
-        int testCount = countTestCases();
-        for (int i = 0; i < testCount; i++) {
-            Test each = this.testAt(i);
-            if (result.shouldStop())
-                break;
-            runTest(each, result);
-        }
+		int testCount = countTestCases();
+		for (int i = 0; i < testCount; i++) {
+			Test each = this.testAt(i);
+			if (result.shouldStop())
+				break;
+			runTest(each, result);
+		}
 
-        // cleanup hdfs and hyracks cluster
-        try {
-            cleanup();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new IllegalStateException(e.getMessage());
-        }
-    }
+		// cleanup hdfs and hyracks cluster
+		try {
+			cleanup();
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new IllegalStateException(e.getMessage());
+		}
+	}
 
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuite.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuite.java
index 8ac4e86..e3a4a4e 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuite.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuite.java
@@ -11,43 +11,44 @@
 
 public class OptimizerTestSuite extends AbstractTestSuiteClass {
 
-    private static final String PATH_TO_QUERIES = "src/test/resources/optimizerts/queries/";
-    private static final String PATH_TO_RESULTS = "src/test/resources/optimizerts/results/";
-    private static final String PATH_TO_IGNORES = "src/test/resources/optimizerts/ignore.txt";
+	private static final String PATH_TO_QUERIES = "src/test/resources/optimizerts/queries/";
+	private static final String PATH_TO_RESULTS = "src/test/resources/optimizerts/results/";
+	private static final String PATH_TO_IGNORES = "src/test/resources/optimizerts/ignore.txt";
 
-    private static final String FILE_EXTENSION_OF_RESULTS = "plan";
+	private static final String FILE_EXTENSION_OF_RESULTS = "plan";
 
-    public static Test suite() throws UnsupportedEncodingException, FileNotFoundException, IOException {
-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);
-        File testData = new File(PATH_TO_QUERIES);
-        File[] queries = testData.listFiles();
-        OptimizerTestSuite testSuite = new OptimizerTestSuite();
+	public static Test suite() throws UnsupportedEncodingException,
+			FileNotFoundException, IOException {
+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);
+		File testData = new File(PATH_TO_QUERIES);
+		File[] queries = testData.listFiles();
+		OptimizerTestSuite testSuite = new OptimizerTestSuite();
 
-        // set hdfs and hyracks cluster, and load test data to hdfs
-        try {
-            testSuite.setup();
-            testSuite.loadData();
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new IllegalStateException(e.getMessage());
-        }
+		// set hdfs and hyracks cluster, and load test data to hdfs
+		try {
+			testSuite.setup();
+			testSuite.loadData();
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new IllegalStateException(e.getMessage());
+		}
 
-        for (File qFile : queries) {
-            if (isIgnored(qFile.getName(), ignores))
-                continue;
+		for (File qFile : queries) {
+			if (isIgnored(qFile.getName(), ignores))
+				continue;
 
-            if (qFile.isFile() && qFile.getName().startsWith("h11_")) {
-                String resultFileName = hiveExtToResExt(qFile.getName());
-                File rFile = new File(PATH_TO_RESULTS + resultFileName);
-                testSuite.addTest(new OptimizerTestCase(qFile, rFile));
-            }
-        }
-        return testSuite;
-    }
+			if (qFile.isFile() && qFile.getName().startsWith("h11_")) {
+				String resultFileName = hiveExtToResExt(qFile.getName());
+				File rFile = new File(PATH_TO_RESULTS + resultFileName);
+				testSuite.addTest(new OptimizerTestCase(qFile, rFile));
+			}
+		}
+		return testSuite;
+	}
 
-    private static String hiveExtToResExt(String fname) {
-        int dot = fname.lastIndexOf('.');
-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;
-    }
+	private static String hiveExtToResExt(String fname) {
+		int dot = fname.lastIndexOf('.');
+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;
+	}
 
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuiteCaseGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuiteCaseGenerator.java
index 6a3d242..35710e2 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuiteCaseGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/optimizer/OptimizerTestSuiteCaseGenerator.java
@@ -12,40 +12,43 @@
 import edu.uci.ics.hivesterix.test.base.AbstractHivesterixTestCase;
 
 public class OptimizerTestSuiteCaseGenerator extends AbstractHivesterixTestCase {
-    private File resultFile;
-    private static final String PATH_TO_HIVE_CONF = "src/test/resources/runtimefunctionts/hive/conf/hive-default.xml";
+	private File resultFile;
+	private static final String PATH_TO_HIVE_CONF = "src/test/resources/runtimefunctionts/hive/conf/hive-default.xml";
 
-    OptimizerTestSuiteCaseGenerator(File queryFile, File resultFile) {
-        super("testOptimizer", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	OptimizerTestSuiteCaseGenerator(File queryFile, File resultFile) {
+		super("testOptimizer", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testOptimizer() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	@Test
+	public void testOptimizer() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            if (query.toLowerCase().indexOf("create") >= 0 || query.toLowerCase().indexOf("drop") >= 0
-                    || query.toLowerCase().indexOf("set") >= 0 || query.toLowerCase().startsWith("\n\ncreate")
-                    || query.toLowerCase().startsWith("\n\ndrop") || query.toLowerCase().startsWith("\n\nset"))
-                driver.run(query);
-            else
-                driver.compile(query);
-            driver.clear();
-            i++;
-        }
-        sw.close();
-        writeStringToFile(resultFile, sw);
-    }
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			if (query.toLowerCase().indexOf("create") >= 0
+					|| query.toLowerCase().indexOf("drop") >= 0
+					|| query.toLowerCase().indexOf("set") >= 0
+					|| query.toLowerCase().startsWith("\n\ncreate")
+					|| query.toLowerCase().startsWith("\n\ndrop")
+					|| query.toLowerCase().startsWith("\n\nset"))
+				driver.run(query);
+			else
+				driver.compile(query);
+			driver.clear();
+			i++;
+		}
+		sw.close();
+		writeStringToFile(resultFile, sw);
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestCase.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestCase.java
index 60a8b13..078de9a 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestCase.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestCase.java
@@ -15,133 +15,138 @@
 import edu.uci.ics.hivesterix.test.base.AbstractHivesterixTestCase;
 
 public class RuntimeFunctionTestCase extends AbstractHivesterixTestCase {
-    private File resultFile;
-    private FileSystem dfs;
+	private File resultFile;
+	private FileSystem dfs;
 
-    RuntimeFunctionTestCase(File queryFile, File resultFile) {
-        super("testRuntimeFunction", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+	RuntimeFunctionTestCase(File queryFile, File resultFile) {
+		super("testRuntimeFunction", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-    @Test
-    public void testRuntimeFunction() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	@Test
+	public void testRuntimeFunction() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
-        // Driver driver = new Driver(hconf);
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
+		// Driver driver = new Driver(hconf);
 
-        dfs = FileSystem.get(ConfUtil.getJobConf());
+		dfs = FileSystem.get(ConfUtil.getJobConf());
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            driver.run(query);
-            driver.clear();
-            i++;
-        }
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			driver.run(query);
+			driver.clear();
+			i++;
+		}
 
-        String warehouse = hconf.get("hive.metastore.warehouse.dir");
-        String tableName = removeExt(resultFile.getName());
-        String directory = warehouse + "/" + tableName + "/";
-        String localDirectory = "tmp";
+		String warehouse = hconf.get("hive.metastore.warehouse.dir");
+		String tableName = removeExt(resultFile.getName());
+		String directory = warehouse + "/" + tableName + "/";
+		String localDirectory = "tmp";
 
-        FileStatus[] files = dfs.listStatus(new Path(directory));
-        FileSystem lfs = null;
-        if (files == null) {
-            lfs = FileSystem.getLocal(ConfUtil.getJobConf());
-            files = lfs.listStatus(new Path(directory));
-        }
+		FileStatus[] files = dfs.listStatus(new Path(directory));
+		FileSystem lfs = null;
+		if (files == null) {
+			lfs = FileSystem.getLocal(ConfUtil.getJobConf());
+			files = lfs.listStatus(new Path(directory));
+		}
 
-        File resultDirectory = new File(localDirectory + "/" + tableName);
-        deleteDir(resultDirectory);
-        resultDirectory.mkdir();
+		File resultDirectory = new File(localDirectory + "/" + tableName);
+		deleteDir(resultDirectory);
+		resultDirectory.mkdir();
 
-        for (FileStatus fs : files) {
-            Path src = fs.getPath();
-            if (src.getName().indexOf("crc") >= 0)
-                continue;
+		for (FileStatus fs : files) {
+			Path src = fs.getPath();
+			if (src.getName().indexOf("crc") >= 0)
+				continue;
 
-            String destStr = localDirectory + "/" + tableName + "/" + src.getName();
-            Path dest = new Path(destStr);
-            if (lfs != null) {
-                lfs.copyToLocalFile(src, dest);
-                dfs.copyFromLocalFile(dest, new Path(directory));
-            } else
-                dfs.copyToLocalFile(src, dest);
-        }
+			String destStr = localDirectory + "/" + tableName + "/"
+					+ src.getName();
+			Path dest = new Path(destStr);
+			if (lfs != null) {
+				lfs.copyToLocalFile(src, dest);
+				dfs.copyFromLocalFile(dest, new Path(directory));
+			} else
+				dfs.copyToLocalFile(src, dest);
+		}
 
-        File[] rFiles = resultDirectory.listFiles();
-        StringBuilder sb = new StringBuilder();
-        for (File r : rFiles) {
-            if (r.getName().indexOf("crc") >= 0)
-                continue;
-            readFileToString(r, sb);
-        }
+		File[] rFiles = resultDirectory.listFiles();
+		StringBuilder sb = new StringBuilder();
+		for (File r : rFiles) {
+			if (r.getName().indexOf("crc") >= 0)
+				continue;
+			readFileToString(r, sb);
+		}
 
-        StringBuilder buf = new StringBuilder();
-        readFileToString(resultFile, buf);
-        StringBuffer errorMsg = new StringBuffer();
-        if (!equal(buf, sb, errorMsg)) {
-            throw new Exception("Result for " + queryFile + " changed:\n" + errorMsg.toString());
-        }
-        deleteDir(resultDirectory);
-    }
+		StringBuilder buf = new StringBuilder();
+		readFileToString(resultFile, buf);
+		StringBuffer errorMsg = new StringBuffer();
+		if (!equal(buf, sb, errorMsg)) {
+			throw new Exception("Result for " + queryFile + " changed:\n"
+					+ errorMsg.toString());
+		}
+		deleteDir(resultDirectory);
+	}
 
-    private void deleteDir(File resultDirectory) {
-        if (resultDirectory.exists()) {
-            File[] rFiles = resultDirectory.listFiles();
-            for (File r : rFiles)
-                r.delete();
-            resultDirectory.delete();
-        }
-    }
+	private void deleteDir(File resultDirectory) {
+		if (resultDirectory.exists()) {
+			File[] rFiles = resultDirectory.listFiles();
+			for (File r : rFiles)
+				r.delete();
+			resultDirectory.delete();
+		}
+	}
 
-    private boolean equal(StringBuilder sb1, StringBuilder sb2, StringBuffer errorMsg) {
-        String s1 = sb1.toString();
-        String s2 = sb2.toString();
-        String[] rowsOne = s1.split("\n");
-        String[] rowsTwo = s2.split("\n");
+	private boolean equal(StringBuilder sb1, StringBuilder sb2,
+			StringBuffer errorMsg) {
+		String s1 = sb1.toString();
+		String s2 = sb2.toString();
+		String[] rowsOne = s1.split("\n");
+		String[] rowsTwo = s2.split("\n");
 
-        if (rowsOne.length != rowsTwo.length)
-            return false;
+		if (rowsOne.length != rowsTwo.length)
+			return false;
 
-        for (int i = 0; i < rowsOne.length; i++) {
-            String row1 = rowsOne[i];
-            String row2 = rowsTwo[i];
+		for (int i = 0; i < rowsOne.length; i++) {
+			String row1 = rowsOne[i];
+			String row2 = rowsTwo[i];
 
-            if (row1.equals(row2))
-                continue;
+			if (row1.equals(row2))
+				continue;
 
-            String[] fields1 = row1.split("");
-            String[] fields2 = row2.split("");
+			String[] fields1 = row1.split("");
+			String[] fields2 = row2.split("");
 
-            for (int j = 0; j < fields1.length; j++) {
-                if (fields1[j].equals(fields2[j])) {
-                    continue;
-                } else if (fields1[j].indexOf('.') < 0) {
-                    errorMsg.append("line " + i + " column " + j + ": " + fields2[j] + " expected " + fields1[j]);
-                    return false;
-                } else {
-                    Float float1 = Float.parseFloat(fields1[j]);
-                    Float float2 = Float.parseFloat(fields2[j]);
+			for (int j = 0; j < fields1.length; j++) {
+				if (fields1[j].equals(fields2[j])) {
+					continue;
+				} else if (fields1[j].indexOf('.') < 0) {
+					errorMsg.append("line " + i + " column " + j + ": "
+							+ fields2[j] + " expected " + fields1[j]);
+					return false;
+				} else {
+					Float float1 = Float.parseFloat(fields1[j]);
+					Float float2 = Float.parseFloat(fields2[j]);
 
-                    if (Math.abs(float1 - float2) == 0)
-                        continue;
-                    else {
-                        errorMsg.append("line " + i + " column " + j + ": " + fields2[j] + " expected " + fields1[j]);
-                        return false;
-                    }
-                }
-            }
-        }
+					if (Math.abs(float1 - float2) == 0)
+						continue;
+					else {
+						errorMsg.append("line " + i + " column " + j + ": "
+								+ fields2[j] + " expected " + fields1[j]);
+						return false;
+					}
+				}
+			}
+		}
 
-        return true;
-    }
+		return true;
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuite.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuite.java
index 9610497..2093b1d 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuite.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuite.java
@@ -9,66 +9,66 @@
 

 public class RuntimeFunctionTestSuite extends AbstractTestSuiteClass {

 

-    private static final String PATH_TO_QUERIES = "src/test/resources/runtimefunctionts/queries/";

-    private static final String PATH_TO_RESULTS = "src/test/resources/runtimefunctionts/results/";

-    private static final String PATH_TO_IGNORES = "src/test/resources/runtimefunctionts/ignore.txt";

+	private static final String PATH_TO_QUERIES = "src/test/resources/runtimefunctionts/queries/";

+	private static final String PATH_TO_RESULTS = "src/test/resources/runtimefunctionts/results/";

+	private static final String PATH_TO_IGNORES = "src/test/resources/runtimefunctionts/ignore.txt";

 

-    private static final String FILE_EXTENSION_OF_RESULTS = "result";

+	private static final String FILE_EXTENSION_OF_RESULTS = "result";

 

-    public static Test suite() throws Exception {

-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

-        File testData = new File(PATH_TO_QUERIES);

-        File[] queries = testData.listFiles();

-        RuntimeFunctionTestSuite testSuite = new RuntimeFunctionTestSuite();

+	public static Test suite() throws Exception {

+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

+		File testData = new File(PATH_TO_QUERIES);

+		File[] queries = testData.listFiles();

+		RuntimeFunctionTestSuite testSuite = new RuntimeFunctionTestSuite();

 

-        // set hdfs and hyracks cluster, and load test data to hdfs

-        try {

-            testSuite.setup();

-            testSuite.loadData();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

+		// set hdfs and hyracks cluster, and load test data to hdfs

+		try {

+			testSuite.setup();

+			testSuite.loadData();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

 

-        for (File qFile : queries) {

-            if (isIgnored(qFile.getName(), ignores))

-                continue;

+		for (File qFile : queries) {

+			if (isIgnored(qFile.getName(), ignores))

+				continue;

 

-            if (qFile.isFile()) {

-                String resultFileName = hiveExtToResExt(qFile.getName());

-                File rFile = new File(PATH_TO_RESULTS + resultFileName);

-                testSuite.addTest(new RuntimeFunctionTestCase(qFile, rFile));

-            }

-        }

-        return testSuite;

-    }

+			if (qFile.isFile()) {

+				String resultFileName = hiveExtToResExt(qFile.getName());

+				File rFile = new File(PATH_TO_RESULTS + resultFileName);

+				testSuite.addTest(new RuntimeFunctionTestCase(qFile, rFile));

+			}

+		}

+		return testSuite;

+	}

 

-    private static String hiveExtToResExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

-    }

+	private static String hiveExtToResExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

+	}

 

-    /**

-     * Runs the tests and collects their result in a TestResult.

-     */

-    @Override

-    public void run(TestResult result) {

+	/**

+	 * Runs the tests and collects their result in a TestResult.

+	 */

+	@Override

+	public void run(TestResult result) {

 

-        int testCount = countTestCases();

-        for (int i = 0; i < testCount; i++) {

-            Test each = this.testAt(i);

-            if (result.shouldStop())

-                break;

-            runTest(each, result);

-        }

+		int testCount = countTestCases();

+		for (int i = 0; i < testCount; i++) {

+			Test each = this.testAt(i);

+			if (result.shouldStop())

+				break;

+			runTest(each, result);

+		}

 

-        // cleanup hdfs and hyracks cluster

-        try {

-            cleanup();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

-    }

+		// cleanup hdfs and hyracks cluster

+		try {

+			cleanup();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteCaseGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteCaseGenerator.java
index 9a90a33..1b45b41 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteCaseGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteCaseGenerator.java
@@ -14,86 +14,88 @@
 import edu.uci.ics.hivesterix.runtime.config.ConfUtil;
 import edu.uci.ics.hivesterix.test.base.AbstractHivesterixTestCase;
 
-public class RuntimeFunctionTestSuiteCaseGenerator extends AbstractHivesterixTestCase {
-    private File resultFile;
-    private FileSystem dfs;
-    
-    RuntimeFunctionTestSuiteCaseGenerator(File queryFile, File resultFile) {
-        super("testRuntimeFunction", queryFile);
-        this.queryFile = queryFile;
-        this.resultFile = resultFile;
-    }
+public class RuntimeFunctionTestSuiteCaseGenerator extends
+		AbstractHivesterixTestCase {
+	private File resultFile;
+	private FileSystem dfs;
 
-    @Test
-    public void testRuntimeFunction() throws Exception {
-        StringBuilder queryString = new StringBuilder();
-        readFileToString(queryFile, queryString);
-        String[] queries = queryString.toString().split(";");
-        StringWriter sw = new StringWriter();
+	RuntimeFunctionTestSuiteCaseGenerator(File queryFile, File resultFile) {
+		super("testRuntimeFunction", queryFile);
+		this.queryFile = queryFile;
+		this.resultFile = resultFile;
+	}
 
-        HiveConf hconf = ConfUtil.getHiveConf();
-        Driver driver = new Driver(hconf, new PrintWriter(sw));
-        driver.init();
+	@Test
+	public void testRuntimeFunction() throws Exception {
+		StringBuilder queryString = new StringBuilder();
+		readFileToString(queryFile, queryString);
+		String[] queries = queryString.toString().split(";");
+		StringWriter sw = new StringWriter();
 
-        dfs = FileSystem.get(ConfUtil.getJobConf());
+		HiveConf hconf = ConfUtil.getHiveConf();
+		Driver driver = new Driver(hconf, new PrintWriter(sw));
+		driver.init();
 
-        int i = 0;
-        for (String query : queries) {
-            if (i == queries.length - 1)
-                break;
-            driver.run(query);
-            driver.clear();
-            i++;
-        }
+		dfs = FileSystem.get(ConfUtil.getJobConf());
 
-        String warehouse = hconf.get("hive.metastore.warehouse.dir");
-        String tableName = removeExt(resultFile.getName());
-        String directory = warehouse + "/" + tableName + "/";
-        String localDirectory = "tmp";
+		int i = 0;
+		for (String query : queries) {
+			if (i == queries.length - 1)
+				break;
+			driver.run(query);
+			driver.clear();
+			i++;
+		}
 
-        FileStatus[] files = dfs.listStatus(new Path(directory));
-        FileSystem lfs = null;
-        if (files == null) {
-            lfs = FileSystem.getLocal(ConfUtil.getJobConf());
-            files = lfs.listStatus(new Path(directory));
-        }
+		String warehouse = hconf.get("hive.metastore.warehouse.dir");
+		String tableName = removeExt(resultFile.getName());
+		String directory = warehouse + "/" + tableName + "/";
+		String localDirectory = "tmp";
 
-        File resultDirectory = new File(localDirectory + "/" + tableName);
-        deleteDir(resultDirectory);
-        resultDirectory.mkdir();
+		FileStatus[] files = dfs.listStatus(new Path(directory));
+		FileSystem lfs = null;
+		if (files == null) {
+			lfs = FileSystem.getLocal(ConfUtil.getJobConf());
+			files = lfs.listStatus(new Path(directory));
+		}
 
-        for (FileStatus fs : files) {
-            Path src = fs.getPath();
-            if (src.getName().indexOf("crc") >= 0)
-                continue;
+		File resultDirectory = new File(localDirectory + "/" + tableName);
+		deleteDir(resultDirectory);
+		resultDirectory.mkdir();
 
-            String destStr = localDirectory + "/" + tableName + "/" + src.getName();
-            Path dest = new Path(destStr);
-            if (lfs != null) {
-                lfs.copyToLocalFile(src, dest);
-                dfs.copyFromLocalFile(dest, new Path(directory));
-            } else
-                dfs.copyToLocalFile(src, dest);
-        }
+		for (FileStatus fs : files) {
+			Path src = fs.getPath();
+			if (src.getName().indexOf("crc") >= 0)
+				continue;
 
-        File[] rFiles = resultDirectory.listFiles();
-        StringBuilder sb = new StringBuilder();
-        for (File r : rFiles) {
-            if (r.getName().indexOf("crc") >= 0)
-                continue;
-            readFileToString(r, sb);
-        }
-        deleteDir(resultDirectory);
+			String destStr = localDirectory + "/" + tableName + "/"
+					+ src.getName();
+			Path dest = new Path(destStr);
+			if (lfs != null) {
+				lfs.copyToLocalFile(src, dest);
+				dfs.copyFromLocalFile(dest, new Path(directory));
+			} else
+				dfs.copyToLocalFile(src, dest);
+		}
 
-        writeStringToFile(resultFile, sb);
-    }
+		File[] rFiles = resultDirectory.listFiles();
+		StringBuilder sb = new StringBuilder();
+		for (File r : rFiles) {
+			if (r.getName().indexOf("crc") >= 0)
+				continue;
+			readFileToString(r, sb);
+		}
+		deleteDir(resultDirectory);
 
-    private void deleteDir(File resultDirectory) {
-        if (resultDirectory.exists()) {
-            File[] rFiles = resultDirectory.listFiles();
-            for (File r : rFiles)
-                r.delete();
-            resultDirectory.delete();
-        }
-    }
+		writeStringToFile(resultFile, sb);
+	}
+
+	private void deleteDir(File resultDirectory) {
+		if (resultDirectory.exists()) {
+			File[] rFiles = resultDirectory.listFiles();
+			for (File r : rFiles)
+				r.delete();
+			resultDirectory.delete();
+		}
+	}
 }
diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteGenerator.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteGenerator.java
index ca2bd6d..a67f475 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteGenerator.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/runtimefunction/RuntimeFunctionTestSuiteGenerator.java
@@ -9,66 +9,67 @@
 

 public class RuntimeFunctionTestSuiteGenerator extends AbstractTestSuiteClass {

 

-    private static final String PATH_TO_QUERIES = "src/test/resources/runtimefunctionts/queries/";

-    private static final String PATH_TO_RESULTS = "src/test/resources/runtimefunctionts/results/";

-    private static final String PATH_TO_IGNORES = "src/test/resources/runtimefunctionts/ignore.txt";

+	private static final String PATH_TO_QUERIES = "src/test/resources/runtimefunctionts/queries/";

+	private static final String PATH_TO_RESULTS = "src/test/resources/runtimefunctionts/results/";

+	private static final String PATH_TO_IGNORES = "src/test/resources/runtimefunctionts/ignore.txt";

 

-    private static final String FILE_EXTENSION_OF_RESULTS = "result";

+	private static final String FILE_EXTENSION_OF_RESULTS = "result";

 

-    public static Test suite() throws Exception {

-        List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

-        File testData = new File(PATH_TO_QUERIES);

-        File[] queries = testData.listFiles();

-        RuntimeFunctionTestSuiteGenerator testSuite = new RuntimeFunctionTestSuiteGenerator();

+	public static Test suite() throws Exception {

+		List<String> ignores = getIgnoreList(PATH_TO_IGNORES);

+		File testData = new File(PATH_TO_QUERIES);

+		File[] queries = testData.listFiles();

+		RuntimeFunctionTestSuiteGenerator testSuite = new RuntimeFunctionTestSuiteGenerator();

 

-        // set hdfs and hyracks cluster, and load test data to hdfs

-        try {

-            testSuite.setup();

-            testSuite.loadData();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

+		// set hdfs and hyracks cluster, and load test data to hdfs

+		try {

+			testSuite.setup();

+			testSuite.loadData();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

 

-        for (File qFile : queries) {

-            if (isIgnored(qFile.getName(), ignores))

-                continue;

+		for (File qFile : queries) {

+			if (isIgnored(qFile.getName(), ignores))

+				continue;

 

-            if (qFile.isFile() && qFile.getName().startsWith("q16_")) {

-                String resultFileName = hiveExtToResExt(qFile.getName());

-                File rFile = new File(PATH_TO_RESULTS + resultFileName);

-                testSuite.addTest(new RuntimeFunctionTestSuiteCaseGenerator(qFile, rFile));

-            }

-        }

-        return testSuite;

-    }

+			if (qFile.isFile() && qFile.getName().startsWith("q16_")) {

+				String resultFileName = hiveExtToResExt(qFile.getName());

+				File rFile = new File(PATH_TO_RESULTS + resultFileName);

+				testSuite.addTest(new RuntimeFunctionTestSuiteCaseGenerator(

+						qFile, rFile));

+			}

+		}

+		return testSuite;

+	}

 

-    private static String hiveExtToResExt(String fname) {

-        int dot = fname.lastIndexOf('.');

-        return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

-    }

+	private static String hiveExtToResExt(String fname) {

+		int dot = fname.lastIndexOf('.');

+		return fname.substring(0, dot + 1) + FILE_EXTENSION_OF_RESULTS;

+	}

 

-    /**

-     * Runs the tests and collects their result in a TestResult.

-     */

-    @Override

-    public void run(TestResult result) {

+	/**

+	 * Runs the tests and collects their result in a TestResult.

+	 */

+	@Override

+	public void run(TestResult result) {

 

-        int testCount = countTestCases();

-        for (int i = 0; i < testCount; i++) {

-            Test each = this.testAt(i);

-            if (result.shouldStop())

-                break;

-            runTest(each, result);

-        }

+		int testCount = countTestCases();

+		for (int i = 0; i < testCount; i++) {

+			Test each = this.testAt(i);

+			if (result.shouldStop())

+				break;

+			runTest(each, result);

+		}

 

-        // cleanup hdfs and hyracks cluster

-        try {

-            cleanup();

-        } catch (Exception e) {

-            e.printStackTrace();

-            throw new IllegalStateException(e.getMessage());

-        }

-    }

+		// cleanup hdfs and hyracks cluster

+		try {

+			cleanup();

+		} catch (Exception e) {

+			e.printStackTrace();

+			throw new IllegalStateException(e.getMessage());

+		}

+	}

 

 }

diff --git a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/serde/SerDeTest.java b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/serde/SerDeTest.java
index 576d648..b3aedc6 100644
--- a/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/serde/SerDeTest.java
+++ b/hivesterix/src/test/java/edu/uci/ics/hivesterix/test/serde/SerDeTest.java
@@ -47,172 +47,187 @@
  */
 public class SerDeTest extends TestCase {
 
-    /**
-     * Test the LazySimpleSerDe class.
-     */
-    public void testLazySimpleSerDe() throws Throwable {
-        try {
-            // Create the SerDe
-            LazySimpleSerDe serDe = new LazySimpleSerDe();
-            Configuration conf = new Configuration();
-            Properties tbl = createProperties();
-            serDe.initialize(conf, tbl);
+	/**
+	 * Test the LazySimpleSerDe class.
+	 */
+	public void testLazySimpleSerDe() throws Throwable {
+		try {
+			// Create the SerDe
+			LazySimpleSerDe serDe = new LazySimpleSerDe();
+			Configuration conf = new Configuration();
+			Properties tbl = createProperties();
+			serDe.initialize(conf, tbl);
 
-            LazySerDe outputSerde = new LazySerDe();
-            outputSerde.initialize(conf, tbl);
+			LazySerDe outputSerde = new LazySerDe();
+			outputSerde.initialize(conf, tbl);
 
-            // Data
-            Text t = new Text("123\t456\t789\t1000\t5.3\thive and hadoop\t1.\tNULL");
-            String s = "123\t456\t789\t1000\t5.3\thive and hadoop\t1\tqf";
+			// Data
+			Text t = new Text(
+					"123\t456\t789\t1000\t5.3\thive and hadoop\t1.\tNULL");
+			String s = "123\t456\t789\t1000\t5.3\thive and hadoop\t1\tqf";
 
-            byte[] bytes = s.getBytes();
-            Writable bytesWritable = new BytesWritable(bytes);
+			byte[] bytes = s.getBytes();
+			Writable bytesWritable = new BytesWritable(bytes);
 
-            // Test
-            // deserializeAndSerialize(serDe, t, s, expectedFieldsData);
-            Object row = serDe.deserialize(bytesWritable); // test my serde
-            StructObjectInspector simpleInspector = (StructObjectInspector) serDe.getObjectInspector();
-            List<Object> fields = simpleInspector.getStructFieldsDataAsList(row);
-            List<? extends StructField> fieldRefs = simpleInspector.getAllStructFieldRefs();
+			// Test
+			// deserializeAndSerialize(serDe, t, s, expectedFieldsData);
+			Object row = serDe.deserialize(bytesWritable); // test my serde
+			StructObjectInspector simpleInspector = (StructObjectInspector) serDe
+					.getObjectInspector();
+			List<Object> fields = simpleInspector
+					.getStructFieldsDataAsList(row);
+			List<? extends StructField> fieldRefs = simpleInspector
+					.getAllStructFieldRefs();
 
-            int i = 0;
-            for (Object field : fields) {
-                BytesWritable fieldWritable = (BytesWritable) outputSerde.serialize(field, fieldRefs.get(i)
-                        .getFieldObjectInspector());
-                System.out.print(fieldWritable.getSize() + "|");
-                i++;
-            }
+			int i = 0;
+			for (Object field : fields) {
+				BytesWritable fieldWritable = (BytesWritable) outputSerde
+						.serialize(field, fieldRefs.get(i)
+								.getFieldObjectInspector());
+				System.out.print(fieldWritable.getSize() + "|");
+				i++;
+			}
 
-            // Writable output = outputSerde.serialize(row, serDe
-            // .getObjectInspector());
-            // System.out.println(output);
-            //
-            // Object row2 = outputSerde.deserialize(output);
-            // Writable output2 = serDe.serialize(row2, outputSerde
-            // .getObjectInspector());
-            // System.out.println(output2);
+			// Writable output = outputSerde.serialize(row, serDe
+			// .getObjectInspector());
+			// System.out.println(output);
+			//
+			// Object row2 = outputSerde.deserialize(output);
+			// Writable output2 = serDe.serialize(row2, outputSerde
+			// .getObjectInspector());
+			// System.out.println(output2);
 
-            // System.out.println(output);
-            // deserializeAndSerialize(outputSerde, t, s, expectedFieldsData);
+			// System.out.println(output);
+			// deserializeAndSerialize(outputSerde, t, s, expectedFieldsData);
 
-        } catch (Throwable e) {
-            e.printStackTrace();
-            throw e;
-        }
-    }
+		} catch (Throwable e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
 
-    private void deserializeAndSerialize(SerDe serDe, Text t, String s, Object[] expectedFieldsData)
-            throws SerDeException {
-        // Get the row structure
-        StructObjectInspector oi = (StructObjectInspector) serDe.getObjectInspector();
-        List<? extends StructField> fieldRefs = oi.getAllStructFieldRefs();
-        assertEquals(8, fieldRefs.size());
+	private void deserializeAndSerialize(SerDe serDe, Text t, String s,
+			Object[] expectedFieldsData) throws SerDeException {
+		// Get the row structure
+		StructObjectInspector oi = (StructObjectInspector) serDe
+				.getObjectInspector();
+		List<? extends StructField> fieldRefs = oi.getAllStructFieldRefs();
+		assertEquals(8, fieldRefs.size());
 
-        // Deserialize
-        Object row = serDe.deserialize(t);
-        for (int i = 0; i < fieldRefs.size(); i++) {
-            Object fieldData = oi.getStructFieldData(row, fieldRefs.get(i));
-            if (fieldData != null) {
-                fieldData = ((LazyPrimitive) fieldData).getWritableObject();
-            }
-            assertEquals("Field " + i, expectedFieldsData[i], fieldData);
-        }
-        // Serialize
-        assertEquals(Text.class, serDe.getSerializedClass());
-        Text serializedText = (Text) serDe.serialize(row, oi);
-        assertEquals("Serialized data", s, serializedText.toString());
-    }
+		// Deserialize
+		Object row = serDe.deserialize(t);
+		for (int i = 0; i < fieldRefs.size(); i++) {
+			Object fieldData = oi.getStructFieldData(row, fieldRefs.get(i));
+			if (fieldData != null) {
+				fieldData = ((LazyPrimitive) fieldData).getWritableObject();
+			}
+			assertEquals("Field " + i, expectedFieldsData[i], fieldData);
+		}
+		// Serialize
+		assertEquals(Text.class, serDe.getSerializedClass());
+		Text serializedText = (Text) serDe.serialize(row, oi);
+		assertEquals("Serialized data", s, serializedText.toString());
+	}
 
-    private Properties createProperties() {
-        Properties tbl = new Properties();
+	private Properties createProperties() {
+		Properties tbl = new Properties();
 
-        // Set the configuration parameters
-        tbl.setProperty(Constants.SERIALIZATION_FORMAT, "9");
-        tbl.setProperty("columns", "abyte,ashort,aint,along,adouble,astring,anullint,anullstring");
-        tbl.setProperty("columns.types", "tinyint:smallint:int:bigint:double:string:int:string");
-        tbl.setProperty(Constants.SERIALIZATION_NULL_FORMAT, "NULL");
-        return tbl;
-    }
+		// Set the configuration parameters
+		tbl.setProperty(Constants.SERIALIZATION_FORMAT, "9");
+		tbl.setProperty("columns",
+				"abyte,ashort,aint,along,adouble,astring,anullint,anullstring");
+		tbl.setProperty("columns.types",
+				"tinyint:smallint:int:bigint:double:string:int:string");
+		tbl.setProperty(Constants.SERIALIZATION_NULL_FORMAT, "NULL");
+		return tbl;
+	}
 
-    /**
-     * Test the LazySimpleSerDe class with LastColumnTakesRest option.
-     */
-    public void testLazySimpleSerDeLastColumnTakesRest() throws Throwable {
-        try {
-            // Create the SerDe
-            LazySimpleSerDe serDe = new LazySimpleSerDe();
-            Configuration conf = new Configuration();
-            Properties tbl = createProperties();
-            tbl.setProperty(Constants.SERIALIZATION_LAST_COLUMN_TAKES_REST, "true");
-            serDe.initialize(conf, tbl);
+	/**
+	 * Test the LazySimpleSerDe class with LastColumnTakesRest option.
+	 */
+	public void testLazySimpleSerDeLastColumnTakesRest() throws Throwable {
+		try {
+			// Create the SerDe
+			LazySimpleSerDe serDe = new LazySimpleSerDe();
+			Configuration conf = new Configuration();
+			Properties tbl = createProperties();
+			tbl.setProperty(Constants.SERIALIZATION_LAST_COLUMN_TAKES_REST,
+					"true");
+			serDe.initialize(conf, tbl);
 
-            // Data
-            Text t = new Text("123\t456\t789\t1000\t5.3\thive and hadoop\t1.\ta\tb\t");
-            String s = "123\t456\t789\t1000\t5.3\thive and hadoop\tNULL\ta\tb\t";
-            Object[] expectedFieldsData = { new ByteWritable((byte) 123), new ShortWritable((short) 456),
-                    new IntWritable(789), new LongWritable(1000), new DoubleWritable(5.3), new Text("hive and hadoop"),
-                    null, new Text("a\tb\t") };
+			// Data
+			Text t = new Text(
+					"123\t456\t789\t1000\t5.3\thive and hadoop\t1.\ta\tb\t");
+			String s = "123\t456\t789\t1000\t5.3\thive and hadoop\tNULL\ta\tb\t";
+			Object[] expectedFieldsData = { new ByteWritable((byte) 123),
+					new ShortWritable((short) 456), new IntWritable(789),
+					new LongWritable(1000), new DoubleWritable(5.3),
+					new Text("hive and hadoop"), null, new Text("a\tb\t") };
 
-            // Test
-            deserializeAndSerialize(serDe, t, s, expectedFieldsData);
+			// Test
+			deserializeAndSerialize(serDe, t, s, expectedFieldsData);
 
-        } catch (Throwable e) {
-            e.printStackTrace();
-            throw e;
-        }
-    }
+		} catch (Throwable e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
 
-    /**
-     * Test the LazySimpleSerDe class with extra columns.
-     */
-    public void testLazySimpleSerDeExtraColumns() throws Throwable {
-        try {
-            // Create the SerDe
-            LazySimpleSerDe serDe = new LazySimpleSerDe();
-            Configuration conf = new Configuration();
-            Properties tbl = createProperties();
-            serDe.initialize(conf, tbl);
+	/**
+	 * Test the LazySimpleSerDe class with extra columns.
+	 */
+	public void testLazySimpleSerDeExtraColumns() throws Throwable {
+		try {
+			// Create the SerDe
+			LazySimpleSerDe serDe = new LazySimpleSerDe();
+			Configuration conf = new Configuration();
+			Properties tbl = createProperties();
+			serDe.initialize(conf, tbl);
 
-            // Data
-            Text t = new Text("123\t456\t789\t1000\t5.3\thive and hadoop\t1.\ta\tb\t");
-            String s = "123\t456\t789\t1000\t5.3\thive and hadoop\tNULL\ta";
-            Object[] expectedFieldsData = { new ByteWritable((byte) 123), new ShortWritable((short) 456),
-                    new IntWritable(789), new LongWritable(1000), new DoubleWritable(5.3), new Text("hive and hadoop"),
-                    null, new Text("a") };
+			// Data
+			Text t = new Text(
+					"123\t456\t789\t1000\t5.3\thive and hadoop\t1.\ta\tb\t");
+			String s = "123\t456\t789\t1000\t5.3\thive and hadoop\tNULL\ta";
+			Object[] expectedFieldsData = { new ByteWritable((byte) 123),
+					new ShortWritable((short) 456), new IntWritable(789),
+					new LongWritable(1000), new DoubleWritable(5.3),
+					new Text("hive and hadoop"), null, new Text("a") };
 
-            // Test
-            deserializeAndSerialize(serDe, t, s, expectedFieldsData);
+			// Test
+			deserializeAndSerialize(serDe, t, s, expectedFieldsData);
 
-        } catch (Throwable e) {
-            e.printStackTrace();
-            throw e;
-        }
-    }
+		} catch (Throwable e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
 
-    /**
-     * Test the LazySimpleSerDe class with missing columns.
-     */
-    public void testLazySimpleSerDeMissingColumns() throws Throwable {
-        try {
-            // Create the SerDe
-            LazySimpleSerDe serDe = new LazySimpleSerDe();
-            Configuration conf = new Configuration();
-            Properties tbl = createProperties();
-            serDe.initialize(conf, tbl);
+	/**
+	 * Test the LazySimpleSerDe class with missing columns.
+	 */
+	public void testLazySimpleSerDeMissingColumns() throws Throwable {
+		try {
+			// Create the SerDe
+			LazySimpleSerDe serDe = new LazySimpleSerDe();
+			Configuration conf = new Configuration();
+			Properties tbl = createProperties();
+			serDe.initialize(conf, tbl);
 
-            // Data
-            Text t = new Text("123\t456\t789\t1000\t5.3\t");
-            String s = "123\t456\t789\t1000\t5.3\t\tNULL\tNULL";
-            Object[] expectedFieldsData = { new ByteWritable((byte) 123), new ShortWritable((short) 456),
-                    new IntWritable(789), new LongWritable(1000), new DoubleWritable(5.3), new Text(""), null, null };
+			// Data
+			Text t = new Text("123\t456\t789\t1000\t5.3\t");
+			String s = "123\t456\t789\t1000\t5.3\t\tNULL\tNULL";
+			Object[] expectedFieldsData = { new ByteWritable((byte) 123),
+					new ShortWritable((short) 456), new IntWritable(789),
+					new LongWritable(1000), new DoubleWritable(5.3),
+					new Text(""), null, null };
 
-            // Test
-            deserializeAndSerialize(serDe, t, s, expectedFieldsData);
+			// Test
+			deserializeAndSerialize(serDe, t, s, expectedFieldsData);
 
-        } catch (Throwable e) {
-            e.printStackTrace();
-            throw e;
-        }
-    }
+		} catch (Throwable e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
 
 }