com.esotericsoftware.kryo.Kryo.writeClass()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中com.esotericsoftware.kryo.Kryo.writeClass()方法的一些代码示例,展示了Kryo.writeClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.writeClass()方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:writeClass

Kryo.writeClass介绍

[英]Writes a class and returns its registration.
[中]写入类并返回其注册。

代码示例

代码示例来源:origin: orbit/orbit

@Override
public void write(Kryo kryo, Output output, ReferenceReplacement object)
{
  kryo.writeClass(output, object.interfaceClass);
  kryo.writeClassAndObject(output, object.id);
  writeNodeAddress(output, object.address);
}

代码示例来源:origin: com.esotericsoftware/kryo

public void write (Kryo kryo, Output output, Class object) {
  kryo.writeClass(output, object);
  output.writeByte((object != null && object.isPrimitive()) ? 1 : 0);
}

代码示例来源:origin: apache/hive

@Override
public void write(final Kryo kryo, final Output output, final List<?> obj) {
 try {
  final Object[] array = (Object[]) _arrayField.get(obj);
  output.writeInt(array.length, true);
  final Class<?> componentType = array.getClass().getComponentType();
  kryo.writeClass(output, componentType);
  for (final Object item : array) {
   kryo.writeClassAndObject(output, item);
  }
 } catch (final RuntimeException e) {
  // Don't eat and wrap RuntimeExceptions because the ObjectBuffer.write...
  // handles SerializationException specifically (resizing the buffer)...
  throw e;
 } catch (final Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.no-hope/serialization

@Override
public void writeObject(
    @Nonnull final OutputStream stream, @Nonnull final Serializable object) {
  try (final Output output = new Output(stream)) {
    kryoThreadLocal.get().writeClass(output, object.getClass());
    kryoThreadLocal.get().writeObject(output, object);
  }
}

代码示例来源:origin: de.javakaffee/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final EnumMap<? extends Enum<?>, ?> map) {
  kryo.writeClass( output, getKeyType( map ) );
  output.writeInt(map.size(), true);
  for ( final Map.Entry<? extends Enum<?>,?> entry :  map.entrySet() ) {
    output.writeVarInt(entry.getKey().ordinal(), true);
    kryo.writeClassAndObject(output, entry.getValue());
  }
  if ( TRACE ) trace( "kryo", "Wrote EnumMap: " + map );
}

代码示例来源:origin: org.apache.beam/beam-runners-apex

@Override
public void write(Kryo kryo, Output output) {
 try {
  kryo.writeClass(output, coder.getClass());
  kryo.writeObject(output, coder, JAVA_SERIALIZER);
  coder.encode(value, output, Context.OUTER);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: magro/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final EnumMap<? extends Enum<?>, ?> map) {
  kryo.writeClass( output, getKeyType( map ) );
  output.writeInt(map.size(), true);
  for ( final Map.Entry<? extends Enum<?>,?> entry :  map.entrySet() ) {
    output.writeVarInt(entry.getKey().ordinal(), true);
    kryo.writeClassAndObject(output, entry.getValue());
  }
  if ( TRACE ) trace( "kryo", "Wrote EnumMap: " + map );
}

代码示例来源:origin: de.javakaffee/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final Object obj) {
  kryo.writeClass( output, obj.getClass().getSuperclass() );
  kryo.writeObject( output, obj.getClass().getInterfaces() );
  kryo.writeObject( output, ((Factory)obj).getCallbacks() );
}

代码示例来源:origin: magro/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final Object obj) {
  kryo.writeClass( output, obj.getClass().getSuperclass() );
  kryo.writeObject( output, obj.getClass().getInterfaces() );
  kryo.writeObject( output, ((Factory)obj).getCallbacks() );
}

代码示例来源:origin: srikalyc/Sql4D

@Override
public void write(Kryo kryo, Output output, T t) {
  Map<String, Object> map = toMap();
  for (String key:map.keySet()) {
    Object value = map.get(key);
    kryo.writeClass(output, value.getClass());
    kryo.writeObjectOrNull(output, key, String.class);
    kryo.writeObjectOrNull(output, value, value.getClass());
  }
}

代码示例来源:origin: com.yahoo.sql4d/Sql4Ddriver

@Override
public void write(Kryo kryo, Output output, T t) {
  Map<String, Object> map = toMap();
  for (String key:map.keySet()) {
    Object value = map.get(key);
    kryo.writeClass(output, value.getClass());
    kryo.writeObjectOrNull(output, key, String.class);
    kryo.writeObjectOrNull(output, value, value.getClass());
  }
}

代码示例来源:origin: co.paralleluniverse/quasar-core

@Override
public Registration writeClass(Output output, Class type) {
  if (type == null || getMethods(type).writeReplace == null)
    return super.writeClass(output, type);
  return super.getRegistration(type); // do nothing. write object will write the class too
}

代码示例来源:origin: co.paralleluniverse/galaxy

@Override
public Registration writeClass(Output output, Class type) {
  if (type == null || getMethods(type).writeReplace == null)
    return super.writeClass(output, type);
  return super.getRegistration(type); // do nothing. write object will write the class too
}

代码示例来源:origin: co.paralleluniverse/quasar-core

@Override
  public void writeObject(Output output, Object object, Serializer serializer) {
    Method m = getMethods(object.getClass()).writeReplace;
    if (m != null) {
      object = getReplacement(m, object);
      Registration reg = super.writeClass(output, object.getClass());
      serializer = reg.getSerializer();
    }
    super.writeObject(output, object, serializer);
//        System.out.println("wrote2 an object "+object+" id "+getRegistration(object.getClass()).getId());

  }

代码示例来源:origin: magro/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final EnumSet<? extends Enum<?>> set) {
  kryo.writeClass( output, getElementType( set ) );
  output.writeInt( set.size(), true );
  for (final Enum item : set) {
    output.writeInt(item.ordinal(), true);
  }
  if ( TRACE ) trace( "kryo", "Wrote EnumSet: " + set );
}

代码示例来源:origin: de.javakaffee/kryo-serializers

@Override
public void write(final Kryo kryo, final Output output, final EnumSet<? extends Enum<?>> set) {
  kryo.writeClass( output, getElementType( set ) );
  output.writeInt( set.size(), true );
  for (final Enum item : set) {
    output.writeInt(item.ordinal(), true);
  }
  if ( TRACE ) trace( "kryo", "Wrote EnumSet: " + set );
}

代码示例来源:origin: DataSystemsLab/GeoSpark

private void writeUserData(Kryo kryo, Output out, Geometry geometry)
{
  out.writeBoolean(geometry.getUserData() != null);
  if (geometry.getUserData() != null) {
    kryo.writeClass(out, geometry.getUserData().getClass());
    kryo.writeObject(out, geometry.getUserData());
  }
}

代码示例来源:origin: org.datasyslab/geospark

private void writeUserData(Kryo kryo, Output out, Geometry geometry)
{
  out.writeBoolean(geometry.getUserData() != null);
  if (geometry.getUserData() != null) {
    kryo.writeClass(out, geometry.getUserData().getClass());
    kryo.writeObject(out, geometry.getUserData());
  }
}

代码示例来源:origin: uk.gov.gchq.gaffer/spark-library

@Override
public void write(final Kryo kryo, final Output output, final Edge edge) {
  output.writeString(edge.getGroup());
  kryo.writeClass(output, edge.getSource().getClass());
  kryo.writeObject(output, edge.getSource());
  kryo.writeClass(output, edge.getDestination().getClass());
  kryo.writeObject(output, edge.getDestination());
  output.writeBoolean(edge.isDirected());
  kryo.writeObjectOrNull(output, edge.getProperties(), Properties.class);
}

代码示例来源:origin: uk.gov.gchq.gaffer/spark-library

@Override
public void write(final Kryo kryo, final Output output, final Entity entity) {
  output.writeString(entity.getGroup());
  kryo.writeClass(output, entity.getVertex().getClass());
  kryo.writeObject(output, entity.getVertex());
  kryo.writeObjectOrNull(output, entity.getProperties(), Properties.class);
}

相关文章