public static void serializePlan(Kryo kryo, Object plan, OutputStream out) {
    PerfLogger perfLogger = SessionState.getPerfLogger();
    perfLogger.perfLogBegin(CLASS_NAME, PerfLogger.SERIALIZE_PLAN);
    LOG.info("Serializing " + plan.getClass().getSimpleName() + " using kryo");
    serializeObjectByKryo(kryo, plan, out);
    perfLogger.perfLogEnd(CLASS_NAME, PerfLogger.SERIALIZE_PLAN);
  }
Serializes the plan.

@param plan The plan, such as QueryPlan, MapredWork, etc.
@param out  The stream to write to.
ql/src/java/org/apache/hadoop/hive/ql/exec/SerializationUtilities.java