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

The following examples show how to use com.esotericsoftware.kryo.io.Input#readLong() . 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: PSTreeNode.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private PSTreeNode(final Kryo kryo, final Input input) {
    final boolean oldReferences = kryo.getReferences();
    kryo.setReferences(false);

    name = input.readString();
    rank = input.readString();
    parent = input.readInt();
    length = input.readLong();
    final int numChildren = input.readInt();
    children = new HashSet<>(numChildren);
    for (int i = 0; i < numChildren; i++) {
        children.add(Integer.valueOf(input.readString()));
    }

    kryo.setReferences(oldReferences);
}
 
Example 2
Source File: LongOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
public ArrayMetaData<long[]> read(Kryo kryo, Input input, Class<ArrayMetaData<long[]>> type) {
    try {
        long[] 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.readLong();
            }
        }
        thatArrMetaData.setArrData(arrData);
    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatArrMetaData;

}
 
Example 3
Source File: FeatureSerializer.java    From StormCV with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected Feature readObject(Kryo kryo, Input input, Class<Feature> clas, long requestId, String streamId, long sequenceNr) throws Exception {
	String name = input.readString();
	long duration = input.readLong();
	List<Descriptor> sparseDescriptors = kryo.readObject(input, ArrayList.class);
	
		int xl = input.readInt();
		float[][][] denseDescriptor = null;
		if(xl > 0){
			int yl = input.readInt();
			int zl = input.readInt();
			denseDescriptor = new float[xl][yl][zl];
			for(int x=0; x<xl; x++){
				for(int y=0; y<yl; y++){
					for(int z=0; z<zl; z++){
						denseDescriptor[x][y][z] = input.readFloat();
					}
				}
			}
		}
	
	Feature feature = new Feature(streamId, sequenceNr, name, duration, sparseDescriptors, denseDescriptor);
	feature.setRequestId(requestId);
	return feature;
}
 
Example 4
Source File: CVParticleSerializer.java    From StormCV with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Type read(Kryo kryo, Input input, Class<Type> clas) {
	long requestId = input.readLong();
	String streamId = input.readString();
	long sequenceNr = input.readLong();
	HashMap<String, Object> metadata = kryo.readObject(input, HashMap.class);
	try {
		Type result = readObject(kryo, input, clas, requestId, streamId, sequenceNr);
		result.setMetadata(metadata);
		return result;
	} catch (Exception e) {
		//TODO
	}
	return null;
}
 
Example 5
Source File: DefaultPortSerializer.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public DefaultPort read(Kryo kryo, Input input, Class<DefaultPort> aClass) {
    Element element = (Element) kryo.readClassAndObject(input);
    PortNumber number = kryo.readObject(input, PortNumber.class);
    boolean isEnabled = input.readBoolean();
    Port.Type type = kryo.readObject(input, Port.Type.class);
    long portSpeed = input.readLong();
    Annotations annotations = (Annotations) kryo.readClassAndObject(input);

    return new DefaultPort(element, number, isEnabled, type, portSpeed, annotations);
}
 
Example 6
Source File: PairSerializer.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public Pair read(Kryo kryo, Input input, Class<Pair> arg2) {
    
    long value = input.readLong();
    String key = input.readString();
    Pair inner = new Pair();
    inner.setKey(key);
    inner.setValue(value);
    return inner;
}
 
Example 7
Source File: IntHistogram.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CDF( final Kryo kryo, final Input input ) {
    final int len = input.readInt();
    cdfFractions = new float[len];
    for ( int idx = 0; idx != len; ++idx ) {
        cdfFractions[idx] = input.readFloat();
    }
    nCounts = input.readLong();
}
 
Example 8
Source File: ComputeContentEvent.java    From samoa with Apache License 2.0 5 votes vote down vote up
@Override
public ComputeContentEvent read(Kryo kryo, Input input,
		Class<ComputeContentEvent> type) {
	long splitId = input.readLong(true);
	long learningNodeId = input.readLong(true);
	
	int dataLength = input.readInt(true);
	double[] preSplitDist = new double[dataLength];
	
	for(int i = 0; i < dataLength; i++){
		preSplitDist[i] = input.readDouble(PRECISION, true);
	}
	
	return new ComputeContentEvent(splitId, learningNodeId, preSplitDist);
}
 
Example 9
Source File: IntHistogram.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private IntHistogram( final Kryo kryo, final Input input ) {
    final int len = input.readInt();
    counts = new long[len];
    long total = 0L;
    for ( int idx = 0; idx != len; ++idx ) {
        final long val = input.readLong();
        final double idxSum = val * idx;
        total += val;
        counts[idx] = val;
    }
    totalObservations = total;
}
 
Example 10
Source File: TradeCustomerSerializer.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public TradeCustomer read(Kryo kryo, Input input, Class<TradeCustomer> arg2) {
    
    Pair custormer = kryo.readObject(input, Pair.class);
    Pair trade = kryo.readObject(input, Pair.class);
    
    long timeStamp = input.readLong();
    String buffer = input.readString();
    
    TradeCustomer inner = new TradeCustomer(timeStamp, trade, custormer, buffer);
    return inner;
}
 
Example 11
Source File: ComputeContentEvent.java    From incubator-samoa with Apache License 2.0 5 votes vote down vote up
@Override
public ComputeContentEvent read(Kryo kryo, Input input,
    Class<ComputeContentEvent> type) {
  long splitId = input.readLong(true);
  long learningNodeId = input.readLong(true);

  int dataLength = input.readInt(true);
  double[] preSplitDist = new double[dataLength];

  for (int i = 0; i < dataLength; i++) {
    preSplitDist[i] = input.readDouble();
  }

  return new ComputeContentEvent(splitId, learningNodeId, preSplitDist);
}
 
Example 12
Source File: PairSerializer.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
public Pair read(Kryo kryo, Input input, Class<Pair> arg2) {

    long value = input.readLong();
    String key = input.readString();
    Pair inner = new Pair();
    inner.setKey(key);
    inner.setValue(value);
    return inner;
}
 
Example 13
Source File: KryoTupleDeserializer.java    From jstorm with Apache License 2.0 4 votes vote down vote up
public Tuple deserialize(Input input) {
    int targetTaskId = 0;
    long timeStamp = 0l;
    int taskId = 0;
    int streamId = 0;
    String componentName = null;
    String streamName = null;
    MessageId id = null;
    boolean isBatchTuple = false;

    try {
        targetTaskId = input.readInt();
        timeStamp = input.readLong();
        isBatchTuple = input.readBoolean();
        taskId = input.readInt(true);
        streamId = input.readInt(true);
        componentName = _context.getComponentId(taskId);
        streamName = _ids.getStreamName(componentName, streamId);

        List<Object> values;
        int groupId = -1;
        long batchId =  -1;
        if (isBatchTuple) {
            if(_isTransactionTuple) {
                batchId = input.readLong(true);
            }
            values = new ArrayList<>();
            int len = input.readInt(true);
            if (_ackerNum > 0) {
                for (int i = 0; i < len; i++) {
                    values.add(new Pair<>(MessageId.deserialize(input), _kryo.deserializeFrom(input)));
                }
            } else {
                for (int i = 0; i < len; i++) {
                    values.add(new Pair<MessageId, List<Object>>(null, _kryo.deserializeFrom(input)));
                }
            }
        } else {
            id = MessageId.deserialize(input);
            values = _kryo.deserializeFrom(input);
        }

        TupleImplExt tuple = new TupleImplExt(_context, values, taskId, streamName, id);
        tuple.setBatchTuple(isBatchTuple);
        tuple.setTargetTaskId(targetTaskId);
        tuple.setCreationTimeStamp(timeStamp);
        if (_isTransactionTuple) {
            tuple.setBatchId(batchId);
        }
        return tuple;
    } catch (Exception e) {
        StringBuilder sb = new StringBuilder();

        sb.append("Deserialize error:");
        sb.append("targetTaskId:").append(targetTaskId);
        sb.append(",creationTimeStamp:").append(timeStamp);
        sb.append(",isBatchTuple:").append(isBatchTuple);
        sb.append(",taskId:").append(taskId);
        sb.append(",streamId:").append(streamId);
        sb.append(",componentName:").append(componentName);
        sb.append(",streamName:").append(streamName);
        sb.append(",MessageId:").append(id);
        LOG.error("Kryo error!!! {}", sb.toString());
        LOG.error("Exception: ", e);
        throw new RuntimeException(e);
    }
}
 
Example 14
Source File: PSKmerBloomFilter.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private PSKmerBloomFilter(final Kryo kryo, final Input input) {
    this.kmerSize = input.readInt();
    this.kmerMask = new SVKmerShort(input.readLong());
    this.kmerSet = kryo.readObject(input, LongBloomFilter.class);
    this.falsePositiveProbability = input.readDouble();
}
 
Example 15
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public ConstantLongDistribution read (Kryo kryo, Input input, Class<ConstantLongDistribution> type) {
	return new ConstantLongDistribution(input.readLong());
}
 
Example 16
Source File: Person.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public void read(Kryo kryo, Input input) {
    name = input.readString();
    birthDate = new Date(input.readLong());
    age = input.readInt();
}
 
Example 17
Source File: MastershipBasedTimestampSerializer.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public MastershipBasedTimestamp read(Kryo kryo, Input input, Class<MastershipBasedTimestamp> type) {
    final long term = input.readLong();
    final long sequence = input.readLong();
    return new MastershipBasedTimestamp(term, sequence);
}
 
Example 18
Source File: PSKmerSet.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private PSKmerSet(final Kryo kryo, final Input input) {
    this.kmerSize = input.readInt();
    this.kmerMask = new SVKmerShort(input.readLong());
    this.kmerSet = kryo.readObject(input, LargeLongHopscotchSet.class);
}
 
Example 19
Source File: ReadMetadata.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private ReadMetadata( final Kryo kryo, final Input input ) {
    final int crossContigIgnoreSetSize = input.readInt();
    this.crossContigIgnoreSet = new HashSet<>(SVUtils.hashMapCapacity(crossContigIgnoreSetSize));
    for ( int idx = 0; idx != crossContigIgnoreSetSize; ++idx ) {
        crossContigIgnoreSet.add(input.readInt());
    }

    final int groupMapSize = input.readInt();
    readGroupToLibrary = new HashMap<>(SVUtils.hashMapCapacity(groupMapSize));
    for ( int idx = 0; idx != groupMapSize; ++idx ) {
        final String groupName = input.readString();
        final String libName = input.readString();
        readGroupToLibrary.put(groupName, libName);
    }

    final int contigMapSize = input.readInt();
    contigNameToID = new HashMap<>(SVUtils.hashMapCapacity(contigMapSize));
    for ( int idx = 0; idx != contigMapSize; ++idx ) {
        final String contigName = input.readString();
        final int contigId = input.readInt();
        contigNameToID.put(contigName, contigId);
    }
    contigIDToName = buildContigIDToNameArray(contigNameToID);

    nReads = input.readLong();
    avgReadLen = input.readInt();
    nRefBases = input.readLong();
    maxReadsInPartition = input.readLong();
    coverage = input.readFloat();
    meanBaseQuality = input.readFloat();

    final int nPartitions = input.readInt();
    partitionBounds = new PartitionBounds[nPartitions];
    final PartitionBounds.Serializer boundsSerializer = new PartitionBounds.Serializer();
    for ( int idx = 0; idx != nPartitions; ++idx ) {
        partitionBounds[idx] = boundsSerializer.read(kryo, input, PartitionBounds.class);
    }

    final int libMapSize = input.readInt();
    final LibraryStatistics.Serializer statsSerializer = new LibraryStatistics.Serializer();
    libraryToFragmentStatistics = new HashMap<>(SVUtils.hashMapCapacity(libMapSize));
    for ( int idx = 0; idx != libMapSize; ++idx ) {
        final String libraryName = input.readString();
        final LibraryStatistics stats = statsSerializer.read(kryo, input, LibraryStatistics.class);
        libraryToFragmentStatistics.put(libraryName, stats);
    }

}
 
Example 20
Source File: SVKmerShort.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private SVKmerShort(final Kryo kryo, final Input input) {
    valLow = input.readLong();
}