private static void serializePlan(Object plan, OutputStream out, boolean cloningPlan) {
   Kryo kryo = borrowKryo();
   try {
     serializePlan(kryo, plan, out, cloningPlan);
   } finally {
     releaseKryo(kryo);
   }
 }
 private static <T> T deserializePlan(InputStream in, Class<T> planClass, boolean cloningPlan) {
   Kryo kryo = borrowKryo();
   T result = null;
   try {
     result = deserializePlan(kryo, in, planClass, cloningPlan);
   } finally {
     releaseKryo(kryo);
   }
   return result;
 }
 private static byte[] serializeObjectToKryo(Serializable object) {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   Output output = new Output(baos);
   Kryo kryo = borrowKryo();
   try {
     kryo.writeObject(output, object);
   } finally {
     releaseKryo(kryo);
   }
   output.close();
   return baos.toByteArray();
 }
 private static <T extends Serializable> T deserializeObjectFromKryo(
     byte[] bytes, Class<T> clazz) {
   Input inp = new Input(new ByteArrayInputStream(bytes));
   Kryo kryo = borrowKryo();
   T func = null;
   try {
     func = kryo.readObject(inp, clazz);
   } finally {
     releaseKryo(kryo);
   }
   inp.close();
   return func;
 }