use of com.esotericsoftware.kryo.Kryo in project flink by apache.
the class StateDescriptorPassingTest method validateStateDescriptorConfigured.
// ------------------------------------------------------------------------
// generic validation
// ------------------------------------------------------------------------
private void validateStateDescriptorConfigured(SingleOutputStreamOperator<?> result) {
OneInputTransformation<?, ?> transform = (OneInputTransformation<?, ?>) result.getTransformation();
WindowOperator<?, ?, ?, ?, ?> op = (WindowOperator<?, ?, ?, ?, ?>) transform.getOperator();
StateDescriptor<?, ?> descr = op.getStateDescriptor();
// this would be the first statement to fail if state descriptors were not properly initialized
TypeSerializer<?> serializer = descr.getSerializer();
assertTrue(serializer instanceof KryoSerializer);
Kryo kryo = ((KryoSerializer<?>) serializer).getKryo();
assertTrue("serializer registration was not properly passed on", kryo.getSerializer(File.class) instanceof JavaSerializer);
}
use of com.esotericsoftware.kryo.Kryo in project storm by apache.
the class KinesisConnectionInfo method getKryoDeserializedObject.
private Object getKryoDeserializedObject(final byte[] ser) {
final Kryo kryo = new Kryo();
final Input input = new Input(new ByteArrayInputStream(ser));
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
return kryo.readClassAndObject(input);
}
use of com.esotericsoftware.kryo.Kryo in project hive by apache.
the class TestInputOutputFormat method toKryo.
public static String toKryo(SearchArgument sarg) {
Output out = new Output(4 * 1024, 10 * 1024 * 1024);
new Kryo().writeObject(out, sarg);
out.close();
return Base64.encodeBase64String(out.toBytes());
}
use of com.esotericsoftware.kryo.Kryo in project hive by apache.
the class KryoSerializer method serialize.
public static byte[] serialize(Object object) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Output output = new Output(stream);
Kryo kryo = SerializationUtilities.borrowKryo();
kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
try {
kryo.writeObject(output, object);
} finally {
SerializationUtilities.releaseKryo(kryo);
}
// close() also calls flush()
output.close();
return stream.toByteArray();
}
use of com.esotericsoftware.kryo.Kryo in project hive by apache.
the class KryoSerializer method deserialize.
public static <T> T deserialize(byte[] buffer, Class<T> clazz) {
Kryo kryo = SerializationUtilities.borrowKryo();
kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
T result = null;
try {
result = kryo.readObject(new Input(new ByteArrayInputStream(buffer)), clazz);
} finally {
SerializationUtilities.releaseKryo(kryo);
}
return result;
}
Aggregations