Java Code Examples for com.esotericsoftware.kryo.Serializer#write()
The following examples show how to use
com.esotericsoftware.kryo.Serializer#write() .
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: KryoTest.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testSQLRef() throws Exception { SQLRef sqlRef = new SQLRef(new HBaseRowLocation(new byte[] {0, 1, 2,3,4,5,6,7,8,9})); Output output = new Output(new byte[30],30); Serializer serializer = kryo.getSerializer(SQLRef.class); serializer.write(kryo, output, sqlRef); byte[] bytes = output.toBytes(); assertNotNull(bytes); Input input = new Input(new ByteArrayInputStream(bytes), bytes.length); SQLRef out = (SQLRef) serializer.read(kryo, input, SQLRef.class); assertNotNull(out); assertEquals(sqlRef, out); }
Example 2
Source File: KryoTest.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testDataValueStorage() throws Exception { SQLRef sqlRef = new SQLRef(new HBaseRowLocation(ByteSlice.wrap(new byte[] {0, 1, 2,3,4,5,6,7,8,9}, 6, 4))); ActivationSerializer.DataValueStorage dvdStore = new ActivationSerializer.DataValueStorage(sqlRef); assertNotNull(dvdStore.getValue(null)); Output output = new Output(new byte[30],30); Serializer serializer = kryo.getSerializer(ActivationSerializer.DataValueStorage.class); serializer.write(kryo, output, dvdStore); byte[] bytes = output.toBytes(); assertNotNull(bytes); Input input = new Input(new ByteArrayInputStream(bytes), bytes.length); assertNotNull(input); ActivationSerializer.DataValueStorage out = (ActivationSerializer.DataValueStorage) serializer.read(kryo, input, ActivationSerializer.DataValueStorage.class); assertNotNull(out); assertNotNull(out.getValue(null)); assertEquals(dvdStore.getValue(null), out.getValue(null)); }
Example 3
Source File: FloatOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new FloatOperand.Mp4jFloatArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new FloatOperand.Mp4jFloatMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 4
Source File: StringOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new StringOperand.Mp4jStringArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new StringOperand.Mp4jStringMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 5
Source File: ObjectOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new ObjectOperand.Mp4jObjectArraySerializer( metaData.convertToArrayMetaData(), serializer, type); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new ObjectOperand.Mp4jObjectMapSerializer( metaData.convertToMapMetaData(), serializer, type); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 6
Source File: DoubleOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new Mp4jDoubleArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new Mp4jDoubleMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 7
Source File: ShortOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new ShortOperand.Mp4jShortArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new ShortOperand.Mp4jShortMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 8
Source File: LongOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new LongOperand.Mp4jLongArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new LongOperand.Mp4jLongMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 9
Source File: IntOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new IntOperand.Mp4jIntArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new IntOperand.Mp4jIntMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }
Example 10
Source File: ByteOperand.java From ytk-mp4j with MIT License | 5 votes |
@Override public void send(Output output, MetaData metaData) throws IOException, Mp4jException { Kryo kryo = KryoUtils.getKryo(); try { switch (container) { case ARRAY: Serializer arrSerializer = new ByteOperand.Mp4jByteArraySerializer(metaData.convertToArrayMetaData()); if (compress) { arrSerializer = new DeflateSerializer(arrSerializer); } arrSerializer.write(kryo, output, null); break; case MAP: Serializer mapSerializer = new ByteOperand.Mp4jByteMapSerializer(metaData.convertToMapMetaData()); if (compress) { mapSerializer = new DeflateSerializer(mapSerializer); } mapSerializer.write(kryo, output, null); break; default: throw new Mp4jException("unsupported container:" + container); } } catch (Exception e) { LOG.error("send exception", e); throw new Mp4jException(e); } finally { output.close(); } }