/** Determines if this class requires the fall-back {@code JavaSerializer}. If the class does not require any specialized Java * serialization features then null will be returned. * * @param type the type we wish to externalize * @return a {@code JavaSerializer} if the type requires more than simple externalization. */ private JavaSerializer getJavaSerializerIfRequired (Class type) { JavaSerializer javaSerializer = getCachedSerializer(type); if (javaSerializer == null && isJavaSerializerRequired(type)) { javaSerializer = new JavaSerializer(); } return javaSerializer; }
@Override public Object read (Kryo kryo, Input input, Class type) { JavaSerializer serializer = getJavaSerializerIfRequired(type); if (serializer == null) { return readExternal(kryo, input, type); } else { return serializer.read(kryo, input, type); } }
private boolean isJavaSerializerRequired (Class type) { return (hasInheritableReplaceMethod(type, "writeReplace") || hasInheritableReplaceMethod(type, "readResolve")); }
@Override public void write (Kryo kryo, Output output, Object object) { JavaSerializer serializer = getJavaSerializerIfRequired(object.getClass()); if (serializer == null) { writeExternal(kryo, output, object); } else { serializer.write(kryo, output, object); } }
private void writeExternal (Kryo kryo, Output output, Object object) { try { ((Externalizable)object).writeExternal(getObjectOutput(kryo, output)); } catch (ClassCastException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } }
private Object readExternal (Kryo kryo, Input input, Class type) { try { Externalizable object = (Externalizable)type.newInstance(); object.readExternal(getObjectInput(kryo, input)); return object; } catch (ClassCastException e) { throw new KryoException(e); } catch (ClassNotFoundException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } catch (InstantiationException e) { throw new KryoException(e); } catch (IllegalAccessException e) { throw new KryoException(e); } }
kryo.addDefaultSerializer(RelOptNamespaceTable.class, new RelOptNamespaceTableSerializer(catalog, context.getCluster())); kryo.addDefaultSerializer(TableMetadata.class, new TableMetadataSerializer(catalog)); kryo.addDefaultSerializer(SourceConfig.class, new ExternalizableSerializer()); kryo.addDefaultSerializer(ConnectionConf.class, new ExternalizableSerializer());
@Override public void write (Kryo kryo, Output output, Object object) { JavaSerializer serializer = getJavaSerializerIfRequired(object.getClass()); if (serializer == null) { writeExternal(kryo, output, object); } else { serializer.write(kryo, output, object); } }
private void writeExternal (Kryo kryo, Output output, Object object) { try { ((Externalizable)object).writeExternal(getObjectOutput(kryo, output)); } catch (ClassCastException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } }
private Object readExternal (Kryo kryo, Input input, Class type) { try { Externalizable object = (Externalizable)kryo.newInstance(type); object.readExternal(getObjectInput(kryo, input)); return object; } catch (ClassCastException e) { throw new KryoException(e); } catch (ClassNotFoundException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } }
/** Determines if this class requires the fall-back {@code JavaSerializer}. If the class does not require any specialized Java * serialization features then null will be returned. * * @param type the type we wish to externalize * @return a {@code JavaSerializer} if the type requires more than simple externalization. */ private JavaSerializer getJavaSerializerIfRequired (Class type) { JavaSerializer javaSerializer = getCachedSerializer(type); if (javaSerializer == null && isJavaSerializerRequired(type)) { javaSerializer = new JavaSerializer(); } return javaSerializer; }
@Override public Object read (Kryo kryo, Input input, Class type) { JavaSerializer serializer = getJavaSerializerIfRequired(type); if (serializer == null) { return readExternal(kryo, input, type); } else { return serializer.read(kryo, input, type); } }
@Override public void write (Kryo kryo, Output output, Object object) { JavaSerializer serializer = getJavaSerializerIfRequired(object.getClass()); if (serializer == null) { writeExternal(kryo, output, object); } else { serializer.write(kryo, output, object); } }
private void writeExternal (Kryo kryo, Output output, Object object) { try { ((Externalizable)object).writeExternal(getObjectOutput(kryo, output)); } catch (ClassCastException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } }
private Object readExternal (Kryo kryo, Input input, Class type) { try { Externalizable object = (Externalizable)kryo.newInstance(type); object.readExternal(getObjectInput(kryo, input)); return object; } catch (ClassCastException e) { throw new KryoException(e); } catch (ClassNotFoundException e) { throw new KryoException(e); } catch (IOException e) { throw new KryoException(e); } }
private boolean isJavaSerializerRequired (Class type) { return (hasInheritableReplaceMethod(type, "writeReplace") || hasInheritableReplaceMethod(type, "readResolve")); }
/** * Determines if this class requires the fall-back {@code JavaSerializer}. If the class does * not require any specialized Java serialization features then null will be returned. * * @param type the type we wish to externalize * @return a {@code JavaSerializer} if the type requires more than simple externalization. */ private JavaSerializer getJavaSerializerIfRequired (Class type) { JavaSerializer javaSerializer = getCachedSerializer(type); if (javaSerializer == null && isJavaSerializerRequired(type)) { javaSerializer = new JavaSerializer(); } return javaSerializer; }
@Override public Object read (Kryo kryo, Input input, Class type) { JavaSerializer serializer = getJavaSerializerIfRequired(type); if (serializer == null) { return readExternal(kryo, input, type); } else { return serializer.read(kryo, input, type); } }
private boolean isJavaSerializerRequired (Class type) { return (hasInheritableReplaceMethod(type, "writeReplace") || hasInheritableReplaceMethod(type, "readResolve")); }