com.esotericsoftware.kryo.KryoSerializable Java Examples

The following examples show how to use com.esotericsoftware.kryo.KryoSerializable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KryoCVAwareSerializableSerializer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, KryoSerializable object) {
    if (object instanceof Document) {
        ((Document) object).write(kryo, output, getReducedResponse());
    } else {
        object.write(kryo, output);
    }
}
 
Example #2
Source File: ValueUtils.java    From hgraphdb with Apache License 2.0 4 votes vote down vote up
public static ValueType getValueType(Object o) {
    if (o == null) {
        return ValueType.NULL;
    } else if (o instanceof Boolean) {
        return ValueType.BOOLEAN;
    } else if (o instanceof String) {
        return ValueType.STRING;
    } else if (o instanceof Byte) {
        return ValueType.BYTE;
    } else if (o instanceof Short) {
        return ValueType.SHORT;
    } else if (o instanceof Integer) {
        return ValueType.INT;
    } else if (o instanceof Long) {
        return ValueType.LONG;
    } else if (o instanceof Float) {
        return ValueType.FLOAT;
    } else if (o instanceof Double) {
        return ValueType.DOUBLE;
    } else if (o instanceof BigDecimal) {
        return ValueType.DECIMAL;
    } else if (o instanceof LocalDate) {
        return ValueType.DATE;
    } else if (o instanceof LocalTime) {
        return ValueType.TIME;
    } else if (o instanceof LocalDateTime) {
        return ValueType.TIMESTAMP;
    } else if (o instanceof Duration) {
        return ValueType.INTERVAL;
    } else if (o instanceof byte[]) {
        return ValueType.BINARY;
    } else if (o instanceof Enum) {
        return ValueType.ENUM;
    } else if (o instanceof UUID) {
        return ValueType.UUID;
    } else if (o instanceof KryoSerializable) {
        return ValueType.KRYO_SERIALIZABLE;
    } else if (o instanceof Serializable) {
        return ValueType.SERIALIZABLE;
    } else {
        throw new IllegalArgumentException("Unexpected data of type : " + o.getClass().getName());
    }
}
 
Example #3
Source File: KryoCodec.java    From jvm-serializer with Apache License 2.0 4 votes vote down vote up
protected Kryo initialValue() {
    Kryo kryo = new Kryo();

    kryo.register(byte[].class);
    kryo.register(char[].class);
    kryo.register(short[].class);
    kryo.register(int[].class);
    kryo.register(long[].class);
    kryo.register(float[].class);
    kryo.register(double[].class);
    kryo.register(boolean[].class);
    kryo.register(String[].class);
    kryo.register(Object[].class);
    kryo.register(KryoSerializable.class);
    kryo.register(BigInteger.class);
    kryo.register(BigDecimal.class);
    kryo.register(Class.class);
    kryo.register(Date.class);
    //kryo.register(Enum.class);
    kryo.register(EnumSet.class);
    kryo.register(Currency.class);
    kryo.register(StringBuffer.class);
    kryo.register(StringBuilder.class);
    kryo.register(Collections.EMPTY_LIST.getClass());
    kryo.register(Collections.EMPTY_MAP.getClass());
    kryo.register(Collections.EMPTY_SET.getClass());
    kryo.register(Collections.singletonList(null).getClass());
    kryo.register(Collections.singletonMap(null, null).getClass());
    kryo.register(Collections.singleton(null).getClass());
    kryo.register(TreeSet.class);
    kryo.register(Collection.class);
    kryo.register(TreeMap.class);
    kryo.register(Map.class);
    try {
        kryo.register(Class.forName("sun.util.calendar.ZoneInfo"));
    } catch (ClassNotFoundException e) {
        //Noop
    }
    kryo.register(Calendar.class);
    kryo.register(Locale.class);

    kryo.register(BitSet.class);
    kryo.register(HashMap.class);
    kryo.register(Timestamp.class);
    kryo.register(ArrayList.class);

    int size = idList.size();
    for (int i = 0; i < size; i++) {
        kryo.register(classList
                        .get(i),
                serializerList
                        .get(i),
                idList.get(i));
    }
    kryo.setRegistrationRequired(true);
    kryo.setReferences(false);
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
 
Example #4
Source File: KryoCodec.java    From jvm-serializer with Apache License 2.0 4 votes vote down vote up
protected Kryo initialValue() {
    Kryo kryo = new Kryo();

    kryo.register(byte[].class);
    kryo.register(char[].class);
    kryo.register(short[].class);
    kryo.register(int[].class);
    kryo.register(long[].class);
    kryo.register(float[].class);
    kryo.register(double[].class);
    kryo.register(boolean[].class);
    kryo.register(String[].class);
    kryo.register(Object[].class);
    kryo.register(KryoSerializable.class);
    kryo.register(BigInteger.class);
    kryo.register(BigDecimal.class);
    kryo.register(Class.class);
    kryo.register(Date.class);
    //kryo.register(Enum.class);
    kryo.register(EnumSet.class);
    kryo.register(Currency.class);
    kryo.register(StringBuffer.class);
    kryo.register(StringBuilder.class);
    kryo.register(Collections.EMPTY_LIST.getClass());
    kryo.register(Collections.EMPTY_MAP.getClass());
    kryo.register(Collections.EMPTY_SET.getClass());
    kryo.register(Collections.singletonList(null).getClass());
    kryo.register(Collections.singletonMap(null, null).getClass());
    kryo.register(Collections.singleton(null).getClass());
    kryo.register(TreeSet.class);
    kryo.register(Collection.class);
    kryo.register(TreeMap.class);
    kryo.register(Map.class);
    try {
        kryo.register(Class.forName("sun.util.calendar.ZoneInfo"));
    } catch (ClassNotFoundException e) {
        //Noop
    }
    kryo.register(Calendar.class);
    kryo.register(Locale.class);

    kryo.register(BitSet.class);
    kryo.register(HashMap.class);
    kryo.register(Timestamp.class);
    kryo.register(ArrayList.class);

    int size = idList.size();
    for (int i = 0; i < size; i++) {
        kryo.register(classList
                        .get(i),
                serializerList
                        .get(i),
                idList.get(i));
    }
    kryo.setRegistrationRequired(true);
    kryo.setReferences(false);
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}