Java Code Examples for com.esotericsoftware.kryo.io.Output#writeInt()
The following examples show how to use
com.esotericsoftware.kryo.io.Output#writeInt() .
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 |
/** * Write the given instance to the given output. * * @param kryo instance of {@link Kryo} object * @param output a Kryo {@link Output} object * @param t instance to serialize */ @Override public void write(Kryo kryo, Output output, T t) { try { preSerialize(t); try(ByteArrayOutputStream stream = new ByteArrayOutputStream(4096)) { // write the object using the HTM serializer HTMObjectOutput writer = serializer.getObjectOutput(stream); writer.writeObject(t, t.getClass()); writer.close(); // write the serialized data output.writeInt(stream.size()); stream.writeTo(output); LOGGER.debug("wrote {} bytes", stream.size()); } } catch(IOException e) { throw new KryoException(e); } }
Example 2
Source File: IntOperand.java From ytk-mp4j with MIT License | 6 votes |
public void write(Kryo kryo, Output output, MapMetaData<Integer> object) { try { List<Map<String, Integer>> mapDataList = mapMetaData.getMapDataList(); mapMetaData.send(output); int mapSegNum = mapMetaData.getSegNum(); for (int i = 0; i < mapSegNum; i++) { Map<String, Integer> mapData = mapDataList.get(i); for (Map.Entry<String, Integer> entry : mapData.entrySet()) { output.writeString(entry.getKey()); output.writeInt(entry.getValue()); } if (mapMetaData.getCollective() == Collective.GATHER || mapMetaData.getCollective() == Collective.SCATTER || mapMetaData.getCollective() == Collective.REDUCE_SCATTER) { mapData.clear(); } } } catch (IOException e) { LOG.error("double array write exception", e); System.exit(1); } }
Example 3
Source File: AddToListSerializer.java From SynchronizeFX with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void write(final Kryo kryo, final Output output, final AddToList object) { kryo.writeObject(output, object.getListId()); kryo.writeObject(output, object.getListVersionChange().getFromVersion()); kryo.writeObject(output, object.getListVersionChange().getToVersion()); kryo.writeObject(output, object.getValue()); output.writeInt(object.getPosition()); }
Example 4
Source File: IntHistogram.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void serialize( final Kryo kryo, final Output output ) { output.writeInt(cdfFractions.length); for ( final float val : cdfFractions ) { output.writeFloat(val); } output.writeLong(nCounts); }
Example 5
Source File: RyaStatementSerializer.java From rya with Apache License 2.0 | 5 votes |
/** * Uses Kryo to write RyaStatement to {@lin Output} * @param kryo - writes statement to output * @param output - output stream that statement is written to * @param object - statement written to output */ public static void writeToKryo(Kryo kryo, Output output, RyaStatement object) { Preconditions.checkNotNull(kryo); Preconditions.checkNotNull(output); Preconditions.checkNotNull(object); output.writeString(object.getSubject().getData()); output.writeString(object.getPredicate().getData()); output.writeString(object.getObject().getDataType().toString()); output.writeString(object.getObject().getData()); boolean hasContext = object.getContext() != null; output.writeBoolean(hasContext); if(hasContext){ output.writeString(object.getContext().getData()); } boolean shouldWrite = object.getColumnVisibility() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeInt(object.getColumnVisibility().length); output.writeBytes(object.getColumnVisibility()); } shouldWrite = object.getQualifer() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeString(object.getQualifer()); } shouldWrite = object.getTimestamp() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeLong(object.getTimestamp()); } shouldWrite = object.getValue() != null; output.writeBoolean(shouldWrite); if(shouldWrite){ output.writeBytes(object.getValue()); } }
Example 6
Source File: BitSetSerializer.java From onos with Apache License 2.0 | 5 votes |
@Override public void write(Kryo kryo, Output output, BitSet bitSet) { final int len = bitSet.length(); output.writeInt(len, true); byte[] bytes = bitSet.toByteArray(); output.writeInt(bytes.length, true); output.writeBytes(bitSet.toByteArray()); }
Example 7
Source File: AvroKryoSerializerUtils.java From flink with Apache License 2.0 | 5 votes |
@Override public void write(Kryo kryo, Output output, LocalTime object) { final int time = object.getMillisOfDay(); output.writeInt(time, true); final Chronology chronology = object.getChronology(); if (chronology != null && chronology != ISOChronology.getInstanceUTC()) { throw new RuntimeException("Unsupported chronology: " + chronology); } }
Example 8
Source File: AlignmentInterval.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
void serialize(final Kryo kryo, final Output output) { output.writeString(referenceSpan.getContig()); output.writeInt(referenceSpan.getStart()); output.writeInt(referenceSpan.getEnd()); output.writeInt(startInAssembledContig); output.writeInt(endInAssembledContig); output.writeString(TextCigarCodec.encode(cigarAlong5to3DirectionOfContig)); output.writeBoolean(forwardStrand); output.writeInt(mapQual); output.writeInt(mismatches); output.writeInt(alnScore); output.writeInt(alnModType.ordinal()); }
Example 9
Source File: KryoValuesSerializer.java From jstorm with Apache License 2.0 | 5 votes |
private void serializeStrings(List<Object> values, Output out) { out.writeInt(values.size(), true); for (Object o : values) { String str = (String) o; out.writeString(str); } }
Example 10
Source File: ImmutableSetSerializer.java From onos with Apache License 2.0 | 5 votes |
@Override public void write(Kryo kryo, Output output, ImmutableSet<?> object) { output.writeInt(object.size()); for (Object e : object) { kryo.writeClassAndObject(output, e); } }
Example 11
Source File: AvroKryoSerializerUtils.java From flink with Apache License 2.0 | 5 votes |
@Override public void write(Kryo kryo, Output output, LocalDate localDate) { output.writeInt(localDate.getYear()); output.writeInt(localDate.getMonthOfYear()); output.writeInt(localDate.getDayOfMonth()); final Chronology chronology = localDate.getChronology(); if (chronology != null && chronology != ISOChronology.getInstanceUTC()) { throw new RuntimeException("Unsupported chronology: " + chronology); } }
Example 12
Source File: Ip4AddressSerializer.java From onos with Apache License 2.0 | 5 votes |
@Override public void write(Kryo kryo, Output output, Ip4Address object) { byte[] octs = object.toOctets(); // It is always Ip4Address.BYTE_LENGTH output.writeInt(octs.length); output.writeBytes(octs); }
Example 13
Source File: ProcessCommSlave.java From ytk-mp4j with MIT License | 5 votes |
@Override public void write(Kryo kryo, Output output, List<T> object) { output.writeInt(object.size()); for (T val : object) { valSerializer.write(kryo, output, val); } }
Example 14
Source File: BreakpointEvidence.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void serialize( final Kryo kryo, final Output output ) { super.serialize(kryo, output); output.writeInt(mateStartPosition); output.writeBoolean(mateReverseStrand); }
Example 15
Source File: IntHistogram.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void serialize( final Kryo kryo, final Output output ) { output.writeInt(counts.length); for ( final long val : counts ) { output.writeLong(val); } }
Example 16
Source File: Person.java From tutorials with MIT License | 4 votes |
@Override public void write(Kryo kryo, Output output) { output.writeString(name); output.writeLong(birthDate.getTime()); output.writeInt(age); }
Example 17
Source File: QNameAndInterval.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void serialize( final Kryo kryo, final Output output ) { output.writeInt(qName.length); output.writeBytes(qName); output.writeInt(hashVal); output.writeInt(intervalId); }
Example 18
Source File: KryoWithCustomSerializersTest.java From flink with Apache License 2.0 | 4 votes |
@Override public void write(Kryo kryo, Output output, LocalDate object) { output.writeInt(object.getYear()); output.writeInt(object.getMonthOfYear()); output.writeInt(object.getDayOfMonth()); }
Example 19
Source File: SVFastqUtils.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void serialize( final Kryo kryo, final Output output ) { output.writeAscii(header); output.writeInt(bases.length); output.writeBytes(bases); output.writeBytes(quals); }
Example 20
Source File: ObjectSpace.java From kryonet with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void write (Kryo kryo, Output output, Object object) { Connection connection = (Connection)kryo.getContext().get("connection"); int id = getRegisteredID(connection, object); if (id == Integer.MAX_VALUE) throw new KryoNetException("Object not found in an ObjectSpace: " + object); output.writeInt(id, true); }