/** * Serialize an Aggregator into a byte array * @param aggFuncs list of aggregator to serialize * @return serialized byte array respresentation of aggregator */ public static byte[] serialize(List<SingleAggregateFunction> aggFuncs, int minNullableIndex) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { DataOutputStream output = new DataOutputStream(stream); WritableUtils.writeVInt(output, minNullableIndex); WritableUtils.writeVInt(output, aggFuncs.size()); for (int i = 0; i < aggFuncs.size(); i++) { SingleAggregateFunction aggFunc = aggFuncs.get(i); WritableUtils.writeVInt(output, ExpressionType.valueOf(aggFunc).ordinal()); aggFunc.write(output); } return stream.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } finally { try { stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Serialize an Aggregator into a byte array * @param aggFuncs list of aggregator to serialize * @return serialized byte array respresentation of aggregator */ public static byte[] serialize(List<SingleAggregateFunction> aggFuncs, int minNullableIndex) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { DataOutputStream output = new DataOutputStream(stream); WritableUtils.writeVInt(output, minNullableIndex); WritableUtils.writeVInt(output, aggFuncs.size()); for (int i = 0; i < aggFuncs.size(); i++) { SingleAggregateFunction aggFunc = aggFuncs.get(i); WritableUtils.writeVInt(output, ExpressionType.valueOf(aggFunc).ordinal()); aggFunc.write(output); } return stream.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } finally { try { stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } }
/** * Serialize an Aggregator into a byte array * @param aggFuncs list of aggregator to serialize * @return serialized byte array respresentation of aggregator */ public static byte[] serialize(List<SingleAggregateFunction> aggFuncs, int minNullableIndex) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { DataOutputStream output = new DataOutputStream(stream); WritableUtils.writeVInt(output, minNullableIndex); WritableUtils.writeVInt(output, aggFuncs.size()); for (int i = 0; i < aggFuncs.size(); i++) { SingleAggregateFunction aggFunc = aggFuncs.get(i); WritableUtils.writeVInt(output, ExpressionType.valueOf(aggFunc).ordinal()); aggFunc.write(output); } return stream.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } finally { try { stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } }