Java Code Examples for com.esotericsoftware.kryo.io.Input#readByte()

The following examples show how to use com.esotericsoftware.kryo.io.Input#readByte() . 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 ArrayMetaData<byte[]> read(Kryo kryo, Input input, Class<ArrayMetaData<byte[]>> type) {
    try {
        byte[] arrData = arrayMetaData.getArrData();
        thatArrMetaData = arrayMetaData.recv(input);
        int arrSegNum = thatArrMetaData.getSegNum();
        for (int i = 0; i < arrSegNum; i++) {
            int from = thatArrMetaData.getFrom(i);
            int to = thatArrMetaData.getTo(i);
            for (int j = from; j < to; j++) {
                arrData[j] = input.readByte();
            }
        }
        thatArrMetaData.setArrData(arrData);
    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatArrMetaData;

}
 
Example 2
Source File: ByteOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
@Override
public MapMetaData<Byte> read(Kryo kryo, Input input, Class<MapMetaData<Byte>> type) {
    try {
        thatMapMetaData = mapMetaData.recv(input);
        int thatMapSegNum = thatMapMetaData.getSegNum();
        List<Map<String, Byte>> mapDataList = new ArrayList<>(thatMapSegNum);
        thatMapMetaData.setMapDataList(mapDataList);

        for (int i = 0; i < thatMapSegNum; i++) {
            int dataNum = thatMapMetaData.getDataNum(i);
            Map<String, Byte> mapData = new HashMap<>(dataNum);
            mapDataList.add(mapData);
            for (int j = 0; j < dataNum; j++) {
                String key = input.readString();
                Byte val = input.readByte();
                mapData.put(key, val);
            }
        }
    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatMapMetaData;
}
 
Example 3
Source File: AlignedContig.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
AlignedContig(final Kryo kryo, final Input input) {

        contigName = input.readString();

        final int nBases = input.readInt();
        contigSequence = new byte[nBases];
        for (int b = 0; b < nBases; ++b) {
            contigSequence[b] = input.readByte();
        }

        final int nAlignments = input.readInt();
        alignmentIntervals = new ArrayList<>(nAlignments);
        for (int i = 0; i < nAlignments; ++i) {
            alignmentIntervals.add(new AlignmentInterval(kryo, input));
        }
    }
 
Example 4
Source File: ObjectSpace.java    From RuinsOfRevenge with MIT License 6 votes vote down vote up
public void read (Kryo kryo, Input input) {
	objectID = input.readInt(true);

	int methodClassID = input.readInt(true);
	Class methodClass = kryo.getRegistration(methodClassID).getType();
	byte methodIndex = input.readByte();
	CachedMethod cachedMethod;
	try {
		cachedMethod = getMethods(kryo, methodClass)[methodIndex];
	} catch (IndexOutOfBoundsException ex) {
		throw new KryoException("Invalid method index " + methodIndex + " for class: " + methodClass.getName());
	}
	method = cachedMethod.method;

	args = new Object[cachedMethod.serializers.length];
	for (int i = 0, n = args.length; i < n; i++) {
		Serializer serializer = cachedMethod.serializers[i];
		if (serializer != null)
			args[i] = kryo.readObjectOrNull(input, method.getParameterTypes()[i], serializer);
		else
			args[i] = kryo.readClassAndObject(input);
	}

	responseID = input.readByte();
}
 
Example 5
Source File: ByteOperand.java    From ytk-mp4j with MIT License 5 votes vote down vote up
public MapMetaData<Byte> read(Kryo kryo, Input input, Class<MapMetaData<Byte>> type) {
    try {
        thatMapMetaData = mapMetaData.recv(input);
        int thatMapSegNum = thatMapMetaData.getSegNum();
        List<Map<String, Byte>> thatMapListData = new ArrayList<>(thatMapSegNum);
        List<Integer> thatDataNums = new ArrayList<>(thatMapSegNum);
        for (int i = 0; i < thatMapSegNum; i++) {
            Map<String, Byte> thisMapData = mapMetaData.getMapDataList().get(i);
            int dataNum = thatMapMetaData.getDataNum(i);
            for (int j = 0; j < dataNum; j++) {
                String key = input.readString();
                Byte val = input.readByte();

                Byte thisVal = thisMapData.get(key);
                if (thisVal == null) {
                    thisMapData.put(key, val);
                } else {
                    thisMapData.put(key, operator.apply(thisVal, val));
                }
            }
            thatMapListData.add(thisMapData);
            thatDataNums.add(thisMapData.size());
        }

        thatMapMetaData.setMapDataList(thatMapListData);
        thatMapMetaData.setDataNums(thatDataNums);

    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatMapMetaData;
}
 
Example 6
Source File: NovelAdjacencyAndAltHaplotype.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected NovelAdjacencyAndAltHaplotype(final Kryo kryo, final Input input) {
    final String contig1 = input.readString();
    final int start1 = input.readInt();
    final int end1 = input.readInt();
    this.leftJustifiedLeftRefLoc = new SimpleInterval(contig1, start1, end1);
    final String contig2 = input.readString();
    final int start2 = input.readInt();
    final int end2 = input.readInt();
    this.leftJustifiedRightRefLoc = new SimpleInterval(contig2, start2, end2);

    this.strandSwitch = StrandSwitch.values()[input.readInt()];

    this.complication = (BreakpointComplications) kryo.readClassAndObject(input);

    this.type = TypeInferredFromSimpleChimera.values()[ input.readInt() ];

    final boolean altSeqIsNull = input.readBoolean();
    if (altSeqIsNull) {
        altHaplotypeSequence = null;
    } else {
        final int arraySize = input.readInt();
        altHaplotypeSequence = new byte[arraySize];
        for (int i = 0 ; i < arraySize; ++i) {
            altHaplotypeSequence[i] = input.readByte();
        }
    }
}
 
Example 7
Source File: BreakpointEvidence.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * a technical constructor for use in Kryo (de-)serialization.
 * this creates an object by reading a Kryo-serialized stream.
 * it will be called by subclasses in their own constructors from Kryo streams (as super(kryo, input)).
 */
protected ReadEvidence( final Kryo kryo, final Input input ) {
    super(kryo, input);
    this.templateName = input.readString();
    this.fragmentOrdinal = TemplateFragmentOrdinal.values()[input.readByte()];
    this.forwardStrand = input.readBoolean();
    this.cigarString = input.readString();
    this.mappingQuality = input.readInt();
    this.templateSize = input.readInt();
    this.readGroup = input.readString();
}
 
Example 8
Source File: ObjectSpace.java    From kryonet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void read (Kryo kryo, Input input) {
	objectID = input.readInt(true);

	int methodClassID = input.readInt(true);
	Class methodClass = kryo.getRegistration(methodClassID).getType();

	byte methodIndex = input.readByte();
	try {
		cachedMethod = getMethods(kryo, methodClass)[methodIndex];
	} catch (IndexOutOfBoundsException ex) {
		throw new KryoException("Invalid method index " + methodIndex + " for class: " + methodClass.getName());
	}

	Serializer[] serializers = cachedMethod.serializers;
	Class[] parameterTypes = cachedMethod.method.getParameterTypes();
	Object[] args = new Object[serializers.length];
	this.args = args;
	for (int i = 0, n = args.length; i < n; i++) {
		Serializer serializer = serializers[i];
		if (serializer != null)
			args[i] = kryo.readObjectOrNull(input, parameterTypes[i], serializer);
		else
			args[i] = kryo.readClassAndObject(input);
	}

	responseData = input.readByte();
}
 
Example 9
Source File: ValueSerializer.java    From SynchronizeFX with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Value read(final Kryo kryo, final Input input, final Class<Value> type) {
    switch (input.readByte()) {
        case 0:
            return new Value(null);
        case 1:
            return new Value(kryo.readClassAndObject(input));
        case 2:
            return new Value(kryo.readObject(input, UUID.class));
        default:
            throw new SynchronizeFXException("Received a Value message of an unknown type.");
    }
}
 
Example 10
Source File: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
@Override
public Interpolation.Bounce read(Kryo kryo, Input input, Class<Interpolation.Bounce> type) {
	int widths = input.readByte();
	int heights = input.readByte();
	return new Interpolation.Bounce(input.readFloats(widths), input.readFloats(heights));
}
 
Example 11
Source File: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
@Override
public Interpolation.BounceIn read(Kryo kryo, Input input, Class<Interpolation.BounceIn> type) {
	int widths = input.readByte();
	int heights = input.readByte();
	return new Interpolation.BounceIn(input.readFloats(widths), input.readFloats(heights));
}
 
Example 12
Source File: OrionKryoSerialization.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
@Override
public Interpolation.BounceOut read(Kryo kryo, Input input, Class<Interpolation.BounceOut> type) {
	int widths = input.readByte();
	int heights = input.readByte();
	return new Interpolation.BounceOut(input.readFloats(widths), input.readFloats(heights));
}