当前位置: 首页>>代码示例>>Java>>正文


Java Kryo.writeClassAndObject方法代码示例

本文整理汇总了Java中com.esotericsoftware.kryo.Kryo.writeClassAndObject方法的典型用法代码示例。如果您正苦于以下问题:Java Kryo.writeClassAndObject方法的具体用法?Java Kryo.writeClassAndObject怎么用?Java Kryo.writeClassAndObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esotericsoftware.kryo.Kryo的用法示例。


在下文中一共展示了Kryo.writeClassAndObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public byte[] apply(Object value) {
    try {
        Kryo kryo = kryoThreadLocal.get();
        ByteArrayOutputStream bos = new ByteArrayOutputStream(256);
        Output output = new Output(bos);
        output.writeInt(IDENTITY_NUMBER);
        kryo.writeClassAndObject(output, value);
        output.close();
        return bos.toByteArray();
    } catch (Exception e) {
        StringBuilder sb = new StringBuilder("Kryo Encode error. ");
        sb.append("msg=").append(e.getMessage());
        throw new CacheEncodeException(sb.toString(), e);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:17,代码来源:KryoValueEncoder.java

示例2: serializationObject

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private byte[] serializationObject(Kryo kryo, byte[] obj) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:18,代码来源:TestKryo.java

示例3: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, SortedIntList list) {
    output.writeVarInt(list.size(), true);
    Serializer serializer = null;
    if (genericType != null) {
        if (serializer == null) serializer = kryo.getSerializer(genericType);
        genericType = null;
    }
    for (Iterator<SortedIntList.Node> iter = list.iterator(); iter.hasNext();){
        SortedIntList.Node node = iter.next();
        output.writeInt(node.index);
        if (serializer != null) {
            kryo.writeObjectOrNull(output, node.value, serializer);
        } else {
            kryo.writeClassAndObject(output, node.value);
        }
    }
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:19,代码来源:SortedIntListSerializer.java

示例4: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public void write (Kryo kryo, Output output, LongMap map) {
    int length = map.size;
    output.writeVarInt(length, true);
    output.writeBoolean(false); // whether type is written (in case future version of LongMap supports type awareness)

    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
        valueGenericType = null;
    }

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        LongMap.Entry entry = (LongMap.Entry)iter.next();
        output.writeLong(entry.key);
        if (valueSerializer != null) {
            kryo.writeObjectOrNull(output, entry.value, valueSerializer);
        } else
            kryo.writeClassAndObject(output, entry.value);
    }
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:21,代码来源:LongMapSerializer.java

示例5: serializationObject

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
private <T extends Serializable> byte[] serializationObject(T obj) {
    Kryo kryo = new Kryo();
    kryo.setReferences(false);
    kryo.register(obj.getClass(), new JavaSerializer());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Output output = new Output(baos);
    kryo.writeClassAndObject(output, obj);
    output.flush();
    output.close();

    byte[] b = baos.toByteArray();
    try {
        baos.flush();
        baos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return b;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:22,代码来源:TestMapDataSerialization.java

示例6: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public void write (Kryo kryo, Output output, ObjectIntMap map) {
    int length = map.size;
    output.writeVarInt(length, true);
    output.writeBoolean(false); // whether type is written (in case future version of ObjectIntMap supports type awareness)

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyGenericType);
        keyGenericType = null;
    }

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        ObjectIntMap.Entry entry = (ObjectIntMap.Entry)iter.next();
        if (keySerializer != null) {
            kryo.writeObject(output, entry.key, keySerializer);
        } else
            kryo.writeClassAndObject(output, entry.key);
        output.writeInt(entry.value);
    }
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:21,代码来源:ObjectIntMapSerializer.java

示例7: serialize

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
/**
 * Serializes given object to byte array using Kryo instance in pool.
 *
 * @param obj Object to serialize
 * @param bufferSize maximum size of serialized bytes
 * @return serialized bytes
 */
public byte[] serialize(final Object obj, final int bufferSize) {
    ByteBufferOutput out = new ByteBufferOutput(bufferSize, MAX_BUFFER_SIZE);
    try {
        Kryo kryo = borrow();
        try {
            kryo.writeClassAndObject(out, obj);
            out.flush();
            return out.toBytes();
        } finally {
            release(kryo);
        }
    } finally {
        out.release();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:KryoNamespace.java

示例8: serialize

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void serialize(OutputStream output, Object object) throws IOException {
    Kryo kryo = pool.borrow();
    Output out = new Output(output);
    kryo.writeClassAndObject(out, object);
    out.close();
    output.close();
    pool.release(kryo);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:10,代码来源:KryoSerialize.java

示例9: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, ImmutableList<?> object) {
    output.writeInt(object.size());
    for (Object e : object) {
        kryo.writeClassAndObject(output, e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:ImmutableListSerializer.java

示例10: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, EncodedDiscreteResources object) {
    List<ClosedOpenRange> ranges = object.rangeSet().asRanges().stream()
            .map(ClosedOpenRange::of)
            .collect(Collectors.toList());
    kryo.writeObject(output, ranges);
    kryo.writeClassAndObject(output, object.codec());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:EncodedResourcesSerializer.java

示例11: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(final Kryo kryo, final Output output, final ImmutableList<Object> object) {
  output.writeInt(object.size(), true);
  final UnmodifiableIterator iterator = object.iterator();

  while (iterator.hasNext()) {
    final Object value = iterator.next();
    kryo.writeClassAndObject(output, value);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:ImmutableCollectionSerializers.java

示例12: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
public void write (Kryo kryo, Output output, ArrayMap map) {
    output.writeBoolean(map.ordered);
    int length = map.size;
    output.writeVarInt(length, true);
    kryo.writeClass(output, map.keys.getClass().getComponentType());
    kryo.writeClass(output, map.values.getClass().getComponentType());

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyGenericType);
        keyGenericType = null;
    }
    Serializer valueSerializer = null;
    if (valueGenericType != null) {
        if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
        valueGenericType = null;
    }

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        ObjectMap.Entry entry = (ObjectMap.Entry)iter.next();
        if (keySerializer != null) {
            kryo.writeObject(output, entry.key, keySerializer);
        } else
            kryo.writeClassAndObject(output, entry.key);
        if (valueSerializer != null) {
            kryo.writeObjectOrNull(output, entry.value, valueSerializer);
        } else
            kryo.writeClassAndObject(output, entry.value);
    }
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:31,代码来源:ArrayMapSerializer.java

示例13: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, DefaultLink object) {
    kryo.writeClassAndObject(output, object.providerId());
    kryo.writeClassAndObject(output, object.src());
    kryo.writeClassAndObject(output, object.dst());
    kryo.writeClassAndObject(output, object.type());
    kryo.writeClassAndObject(output, object.state());
    output.writeBoolean(object.isDurable());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DefaultLinkSerializer.java

示例14: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, ConnectPoint object) {
    kryo.writeClassAndObject(output, object.elementId());
    kryo.writeClassAndObject(output, object.port());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:ConnectPointSerializer.java

示例15: write

import com.esotericsoftware.kryo.Kryo; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, InternalPortEvent event) {
    kryo.writeClassAndObject(output, event.providerId());
    kryo.writeClassAndObject(output, event.deviceId());
    kryo.writeClassAndObject(output, event.portDescriptions());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:InternalPortEventSerializer.java


注:本文中的com.esotericsoftware.kryo.Kryo.writeClassAndObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。