Java Code Examples for com.esotericsoftware.kryo.io.Output#writeByte()

The following examples show how to use com.esotericsoftware.kryo.io.Output#writeByte() . 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: ByteOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
public void write(Kryo kryo, Output output, ArrayMetaData<byte[]> object) {
    try {
        byte[] arrData = arrayMetaData.getArrData();
        arrayMetaData.send(output);
        int arrSegNum = arrayMetaData.getSegNum();
        for (int i = 0; i < arrSegNum; i++) {
            int from = arrayMetaData.getFrom(i);
            int to = arrayMetaData.getTo(i);
            for (int j = from; j < to; j++) {
                output.writeByte(arrData[j]);
            }
        }
    } catch (IOException e) {
        LOG.error("double array write exception", e);
        System.exit(1);
    }
}
 
Example 2
Source File: ByteOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
public void write(Kryo kryo, Output output, MapMetaData<Byte> object) {
    try {
        List<Map<String, Byte>> mapDataList = mapMetaData.getMapDataList();
        mapMetaData.send(output);
        int mapSegNum = mapMetaData.getSegNum();
        for (int i = 0; i < mapSegNum; i++) {
            Map<String, Byte> mapData = mapDataList.get(i);
            for (Map.Entry<String, Byte> entry : mapData.entrySet()) {
                output.writeString(entry.getKey());
                output.writeByte(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: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 6 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, Interpolation.Bounce object) {
	try {
		float[] widths = (float[]) fieldW.get(object);
		float[] heights = (float[]) fieldH.get(object);
		byte widthLength = (byte) widths.length;
		byte heightLength = (byte) heights.length;

		output.writeByte(widthLength);
		output.writeByte(heightLength);
		output.writeFloats(widths);
		output.writeFloats(heights);
	} catch (IllegalAccessException e) {
		throw new RuntimeException(e);
	}
}
 
Example 4
Source File: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 6 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, Interpolation.BounceIn object) {
	try {
		float[] widths = (float[]) fieldW.get(object);
		float[] heights = (float[]) fieldH.get(object);
		byte widthLength = (byte) widths.length;
		byte heightLength = (byte) heights.length;

		output.writeByte(widthLength);
		output.writeByte(heightLength);
		output.writeFloats(widths);
		output.writeFloats(heights);
	} catch (IllegalAccessException e) {
		throw new RuntimeException(e);
	}
}
 
Example 5
Source File: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 6 votes vote down vote up
@Override
public void write(Kryo kryo, Output output, Interpolation.BounceOut object) {
	try {
		float[] widths = (float[]) fieldW.get(object);
		float[] heights = (float[]) fieldH.get(object);
		byte widthLength = (byte) widths.length;
		byte heightLength = (byte) heights.length;

		output.writeByte(widthLength);
		output.writeByte(heightLength);
		output.writeFloats(widths);
		output.writeFloats(heights);
	} catch (IllegalAccessException e) {
		throw new RuntimeException(e);
	}
}
 
Example 6
Source File: NovelAdjacencyAndAltHaplotype.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void serialize(final Kryo kryo, final Output output) {
    output.writeString(leftJustifiedLeftRefLoc.getContig());
    output.writeInt(leftJustifiedLeftRefLoc.getStart());
    output.writeInt(leftJustifiedLeftRefLoc.getEnd());
    output.writeString(leftJustifiedRightRefLoc.getContig());
    output.writeInt(leftJustifiedRightRefLoc.getStart());
    output.writeInt(leftJustifiedRightRefLoc.getEnd());
    output.writeInt(strandSwitch.ordinal());

    kryo.writeClassAndObject(output, complication);

    output.writeInt(type.ordinal());

    if (altHaplotypeSequence==null) {
        output.writeBoolean(true);
    } else {
        output.writeBoolean(false);
        output.writeInt(altHaplotypeSequence.length);
        for (final byte b : altHaplotypeSequence) {
            output.writeByte(b);
        }
    }
}
 
Example 7
Source File: ObjectSpace.java    From kryonet with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void write (Kryo kryo, Output output) {
	output.writeInt(objectID, true);
	output.writeInt(cachedMethod.methodClassID, true);
	output.writeByte(cachedMethod.methodIndex);

	Serializer[] serializers = cachedMethod.serializers;
	Object[] args = this.args;
	for (int i = 0, n = serializers.length; i < n; i++) {
		Serializer serializer = serializers[i];
		if (serializer != null)
			kryo.writeObjectOrNull(output, args[i], serializer);
		else
			kryo.writeClassAndObject(output, args[i]);
	}

	output.writeByte(responseData);
}
 
Example 8
Source File: ObjectSpace.java    From RuinsOfRevenge with MIT License 6 votes vote down vote up
public void write (Kryo kryo, Output output) {
	output.writeInt(objectID, true);

	int methodClassID = kryo.getRegistration(method.getDeclaringClass()).getId();
	output.writeInt(methodClassID, true);

	CachedMethod[] cachedMethods = getMethods(kryo, method.getDeclaringClass());
	CachedMethod cachedMethod = null;
	for (int i = 0, n = cachedMethods.length; i < n; i++) {
		cachedMethod = cachedMethods[i];
		if (cachedMethod.method.equals(method)) {
			output.writeByte(i);
			break;
		}
	}

	for (int i = 0, n = cachedMethod.serializers.length; i < n; i++) {
		Serializer serializer = cachedMethod.serializers[i];
		if (serializer != null)
			kryo.writeObjectOrNull(output, args[i], serializer);
		else
			kryo.writeClassAndObject(output, args[i]);
	}

	output.writeByte(responseID);
}
 
Example 9
Source File: KryoQuickTypeSerializer.java    From vertexium with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] objectToBytes(Object value) {
    Output output = new UnsafeOutput(2000, -1);
    output.writeByte(MARKER_KRYO);
    kryo.get().writeClassAndObject(output, value);
    return output.toBytes();
}
 
Example 10
Source File: BreakpointEvidence.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void serialize( final Kryo kryo, final Output output ) {
    super.serialize(kryo, output);
    output.writeString(templateName);
    output.writeByte(fragmentOrdinal.ordinal());
    output.writeBoolean(forwardStrand);
    output.writeString(cigarString);
    output.writeInt(mappingQuality);
    output.writeInt(templateSize);
    output.writeString(readGroup);
}
 
Example 11
Source File: ValueSerializer.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void write(final Kryo kryo, final Output output, final Value object) {
    if (object.getObservableObjectId() == null) {
        if (object.getSimpleObjectValue() == null) {
            output.writeByte(0);
        } else {
            output.writeByte(1);
            kryo.writeClassAndObject(output, object.getSimpleObjectValue());
        }
    } else {
        output.writeByte(2);
        kryo.writeObject(output, object.getObservableObjectId());
    }
}
 
Example 12
Source File: AlignedContig.java    From gatk with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
void serialize(final Kryo kryo, final Output output) {

        output.writeString(contigName);

        output.writeInt(contigSequence.length);
        for (final byte base : contigSequence) {
            output.writeByte(base);
        }

        output.writeInt(alignmentIntervals.size());
        alignmentIntervals.forEach(it -> it.serialize(kryo, output));

    }