Java Code Examples for com.esotericsoftware.kryo.io.Input#readBytes()
The following examples show how to use
com.esotericsoftware.kryo.io.Input#readBytes() .
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: KryoSerializer.java From flink-htm with GNU Affero General Public License v3.0 | 6 votes |
/** * Read an instance of the given class from the given input. * * @param kryo instance of {@link Kryo} object * @param input a Kryo {@link Input} * @param aClass The class of the object to be read in. * @return an instance of type <T> */ @Override public T read(Kryo kryo, Input input, Class<T> aClass) { // read the serialized data byte[] data = new byte[input.readInt()]; input.readBytes(data); try { try(ByteArrayInputStream stream = new ByteArrayInputStream(data)) { HTMObjectInput reader = serializer.getObjectInput(stream); T t = (T) reader.readObject(aClass); postDeSerialize(t); return t; } } catch(Exception e) { throw new KryoException(e); } }
Example 2
Source File: IpPrefixSerializer.java From onos with Apache License 2.0 | 6 votes |
@Override public IpPrefix read(Kryo kryo, Input input, Class<IpPrefix> type) { int octLen = input.readInt(); checkArgument(octLen <= IpAddress.INET6_BYTE_LENGTH); byte[] octs = new byte[octLen]; input.readBytes(octs); int prefLen = input.readInt(); // Use the address size to decide whether it is IPv4 or IPv6 address if (octLen == IpAddress.INET_BYTE_LENGTH) { return IpPrefix.valueOf(IpAddress.Version.INET, octs, prefLen); } if (octLen == IpAddress.INET6_BYTE_LENGTH) { return IpPrefix.valueOf(IpAddress.Version.INET6, octs, prefLen); } return null; // Shouldn't be reached }
Example 3
Source File: NiciraNatSerializer.java From onos with Apache License 2.0 | 6 votes |
@Override public NiciraNat read(Kryo kryo, Input input, Class<NiciraNat> type) { int natFlags = input.readInt(); int natPresentFlags = input.readInt(); int natPortMin = input.readInt(); int natPortMax = input.readInt(); // TODO: IPv6 address should also be supported byte[] minOcts = new byte[4]; byte[] maxOcts = new byte[4]; input.readBytes(minOcts); input.readBytes(maxOcts); IpAddress natIpAddressMin = IpAddress.valueOf(IpAddress.Version.INET, minOcts); IpAddress natIpAddressMax = IpAddress.valueOf(IpAddress.Version.INET, maxOcts); return new NiciraNat(natFlags, natPresentFlags, natPortMin, natPortMax, natIpAddressMin, natIpAddressMax); }
Example 4
Source File: FeatureSerializer.java From geowave with Apache License 2.0 | 5 votes |
@Override public SimpleFeature read(final Kryo arg0, final Input arg1, final Class<SimpleFeature> arg2) { final FeatureWritable fw = new FeatureWritable(); final byte[] data = arg1.readBytes(arg1.readInt()); try (DataInputStream is = new DataInputStream(new ByteArrayInputStream(data))) { fw.readFields(is); } catch (final IOException e) { LOGGER.error("Cannot deserialize Simple Feature", e); return null; } return fw.getFeature(); }
Example 5
Source File: VideoChunkSerializer.java From StormCV with Apache License 2.0 | 5 votes |
@Override protected VideoChunk readObject(Kryo kryo, Input input, Class<VideoChunk> clas, long requestId, String streamId, long sequenceNr) throws Exception { long duration = input.readLong(); int length = input.readInt(); byte[] video = input.readBytes(length); String container = input.readString(); VideoChunk chunk = new VideoChunk(streamId, sequenceNr, duration, video, container); chunk.setRequestId(requestId); return chunk; }
Example 6
Source File: SVFastqUtils.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
private FastqRead( final Kryo kryo, final Input input ) { header = input.readString(); final int nBases = input.readInt(); bases = new byte[nBases]; input.readBytes(bases); quals = new byte[nBases]; input.readBytes(quals); }
Example 7
Source File: ConcatMap.java From metron with Apache License 2.0 | 5 votes |
@Override public void read(Kryo kryo, Input input) { int numVariableMappings = input.readShort(); variableMappings = new ArrayList<>(numVariableMappings); for(int i = 0;i < numVariableMappings;++i) { int size = input.readInt(); if(size > 0) { byte[] bytes = input.readBytes(size); Map m = SerDeUtils.fromBytes(bytes, Map.class); variableMappings.add(m); } } }
Example 8
Source File: GridCoverageWritableSerializer.java From geowave with Apache License 2.0 | 5 votes |
@Override public GridCoverageWritable read( final Kryo arg0, final Input arg1, final Class<GridCoverageWritable> arg2) { final GridCoverageWritable gcw = new GridCoverageWritable(); final byte[] data = arg1.readBytes(arg1.readInt()); try (DataInputStream is = new DataInputStream(new ByteArrayInputStream(data))) { gcw.readFields(is); } catch (final IOException e) { LOGGER.error("Cannot deserialize GridCoverageWritable", e); return null; } return gcw; }
Example 9
Source File: PassThruSliceSerde.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public Slice deserialize(Input input) { if (input.getInputStream() != null) { // The input is backed by a stream, cannot directly use its internal buffer try { return new Slice(input.readBytes(input.available())); } catch (IOException ex) { throw Throwables.propagate(ex); } } else { return new Slice(input.getBuffer(), input.position(), input.limit() - input.position()); } }
Example 10
Source File: ClusterSerializableSerializer.java From atomix-vertx with Apache License 2.0 | 5 votes |
@Override public T read(Kryo kryo, Input input, Class<T> type) { try { byte[] bytes = input.readBytes(input.readVarInt(true)); Buffer buffer = Buffer.buffer(bytes); T object = type.newInstance(); object.readFromBuffer(0, buffer); return object; } catch (InstantiationException | IllegalAccessException e) { throw new VertxException("failed to instantiate serializable type: " + type); } }
Example 11
Source File: KryoClearedBufferTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TestRecord read(Kryo kryo, Input input, Class<TestRecord> type) { int length = input.readInt(); byte[] buffer = input.readBytes(length); return new TestRecord(buffer); }
Example 12
Source File: SerializableSerializer.java From samoa with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public Object read(Kryo kryo, Input input, Class c) { int len = input.readInt(); byte[] ser = new byte[len]; input.readBytes(ser); ByteArrayInputStream bis = new ByteArrayInputStream(ser); try { ObjectInputStream ois = new ObjectInputStream(bis); return ois.readObject(); } catch(Exception e) { throw new RuntimeException(e); } }
Example 13
Source File: SerializableSerializer.java From incubator-heron with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public Object read(Kryo kryo, Input input, Class c) { int len = input.readInt(); byte[] ser = new byte[len]; input.readBytes(ser); try (ByteArrayInputStream bis = new ByteArrayInputStream(ser); ObjectInputStream ois = new ObjectInputStream(bis)) { return ois.readObject(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); } }
Example 14
Source File: Ip4AddressSerializer.java From onos with Apache License 2.0 | 5 votes |
@Override public Ip4Address read(Kryo kryo, Input input, Class<Ip4Address> type) { final int octLen = input.readInt(); checkArgument(octLen == Ip4Address.BYTE_LENGTH); byte[] octs = new byte[octLen]; input.readBytes(octs); return Ip4Address.valueOf(octs); }
Example 15
Source File: Ip4PrefixSerializer.java From onos with Apache License 2.0 | 5 votes |
@Override public Ip4Prefix read(Kryo kryo, Input input, Class<Ip4Prefix> type) { int octLen = input.readInt(); checkArgument(octLen <= Ip4Address.BYTE_LENGTH); byte[] octs = new byte[octLen]; input.readBytes(octs); int prefLen = input.readInt(); return Ip4Prefix.valueOf(octs, prefLen); }
Example 16
Source File: KryoClearedBufferTest.java From flink with Apache License 2.0 | 5 votes |
@Override public TestRecord read(Kryo kryo, Input input, Class<TestRecord> type) { int length = input.readInt(); byte[] buffer = input.readBytes(length); return new TestRecord(buffer); }
Example 17
Source File: PTContainer.java From Bats with Apache License 2.0 | 5 votes |
@Override public void read(final Object object, final Input in) throws KryoException { PhysicalPlan plan = (PhysicalPlan)object; int containerId = in.readInt(); for (PTContainer c : plan.getContainers()) { if (c.getId() == containerId) { int stateOrd = in.readInt(); c.state = PTContainer.State.values()[stateOrd]; c.containerId = in.readString(); c.resourceRequestPriority = in.readInt(); c.requiredMemoryMB = in.readInt(); c.allocatedMemoryMB = in.readInt(); c.requiredVCores = in.readInt(); c.allocatedVCores = in.readInt(); String bufferServerHost = in.readString(); if (bufferServerHost != null) { c.bufferServerAddress = InetSocketAddress.createUnresolved(bufferServerHost, in.readInt()); } c.host = in.readString(); c.nodeHttpAddress = in.readString(); int tokenLength = in.readInt(); if (tokenLength != -1) { c.bufferServerToken = in.readBytes(tokenLength); } else { c.bufferServerToken = null; } break; } } }
Example 18
Source File: QNameAndInterval.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
private QNameAndInterval( final Kryo kryo, final Input input ) { final int nameLen = input.readInt(); qName = input.readBytes(nameLen); hashVal = input.readInt(); intervalId = input.readInt(); }
Example 19
Source File: PyLongSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public PyLong read(Kryo kryo, Input input, Class<PyLong> type) { int length = input.readShort(); return new PyLong(new BigInteger(input.readBytes(length))); }
Example 20
Source File: JSONKryoSerializer.java From opensoc-streaming with Apache License 2.0 | 3 votes |
@Override public JSONObject read(Kryo kryo, Input input, Class<JSONObject> type) { // Get number of Entries int size = input.readInt(); byte[] bytes = input.readBytes(size); JSONObject json = jsonSerde.fromBytes(bytes); return json; }