/**
* Serialize the object. This helper function mainly makes sure that enums,
* counters, etc are handled properly.
*/
public static void serializeObject(Object plan, OutputStream out) {
XMLEncoder e = new XMLEncoder(out);
e.setExceptionListener(new ExceptionListener() {
public void exceptionThrown(Exception e) {
LOG.warn(org.apache.hadoop.util.StringUtils.stringifyException(e));
throw new RuntimeException("Cannot serialize object", e);
}
});
// workaround for java 1.5
e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
e.setPersistenceDelegate(Operator.ProgressCounter.class, new EnumDelegate());
e.setPersistenceDelegate(java.sql.Date.class, new DatePersistenceDelegate());
e.setPersistenceDelegate(Timestamp.class, new TimestampPersistenceDelegate());
e.setPersistenceDelegate(org.datanucleus.store.types.backed.Map.class, new MapDelegate());
e.setPersistenceDelegate(org.datanucleus.store.types.backed.List.class, new ListDelegate());
e.setPersistenceDelegate(org.antlr.runtime.CommonToken.class, new CommonTokenDelegate());
e.writeObject(plan);
e.close();
}