@Override protected void decode(ChannelHandlerContext ctx, InboundRpcMessage msg, List<Object> out) throws Exception { if (msg.mode == RpcMode.REQUEST && msg.rpcType == RpcType.QUERY_DATA.getNumber()) { final QueryData oldHeader = QueryData.parseFrom(msg.pBody); final ByteBuf oldData = msg.dBody; final QueryBatch oldBatch = new QueryBatch(oldHeader, oldData); final QueryBatch newBatch = handler.makeBatchCompatible(oldBatch); // A copy might be needed to consolidate all buffers as client expect // one contiguous Arrow buffer. final ByteBuf newBuffer = consolidateBuffers(newBatch.getBuffers()); out.add(new InboundRpcMessage(msg.mode, msg.rpcType, msg.coordinationId, newBatch.getHeader().toByteArray(), newBuffer)); } else { out.add(msg); } }