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

The following examples show how to use com.esotericsoftware.kryo.io.Input#readDouble() . 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: PercentileCounterSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 2
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 3
Source File: PercentileCounterSerializer.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 4
Source File: OnlineStatisticsProvider.java    From metron with Apache License 2.0 6 votes vote down vote up
@Override
public void read(Kryo kryo, Input input) {
  int digestSize = input.readInt();
  byte[] digestBytes = input.readBytes(digestSize);
  ByteBuffer digestBuff = ByteBuffer.wrap(digestBytes);
  digest = AVLTreeDigest.fromBytes(digestBuff);
  n = input.readLong();
  sum = input.readDouble();
  sumOfSquares = input.readDouble();
  sumOfLogs = input.readDouble();
  min = input.readDouble();
  max = input.readDouble();
  M1 = input.readDouble();
  M2 = input.readDouble();
  M3 = input.readDouble();
  M4 = input.readDouble();
}
 
Example 5
Source File: DoubleOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
@Override
public MapMetaData<Double> read(Kryo kryo, Input input, Class<MapMetaData<Double>> type) {
    try {
        thatMapMetaData = mapMetaData.recv(input);
        int thatMapSegNum = thatMapMetaData.getSegNum();
        List<Map<String, Double>> mapDataList = new ArrayList<>(thatMapSegNum);
        thatMapMetaData.setMapDataList(mapDataList);

        for (int i = 0; i < thatMapSegNum; i++) {
            int dataNum = thatMapMetaData.getDataNum(i);
            Map<String, Double> mapData = new HashMap<>(dataNum);
            mapDataList.add(mapData);
            for (int j = 0; j < dataNum; j++) {
                String key = input.readString();
                Double val = input.readDouble();
                mapData.put(key, val);
            }
        }
    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatMapMetaData;
}
 
Example 6
Source File: DoubleOperand.java    From ytk-mp4j with MIT License 6 votes vote down vote up
public ArrayMetaData<double[]> read(Kryo kryo, Input input, Class<ArrayMetaData<double[]>> type) {
    try {
        double[] 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.readDouble();
            }
        }
        thatArrMetaData.setArrData(arrData);
    } catch (IOException e) {
        LOG.error("double array read exception", e);
        System.exit(1);
    }
    return thatArrMetaData;

}
 
Example 7
Source File: PercentileCounterSerializer.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public PercentileCounter read(Kryo kryo, Input input, Class type) {
    double compression = input.readDouble();
    double quantileRatio = input.readDouble();
    int length = input.readInt();
    byte[] buffer = new byte[length];

    int offset = 0;
    int bytesRead;
    while ((bytesRead = input.read(buffer, offset, buffer.length - offset)) != -1) {
        offset += bytesRead;
        if (offset >= buffer.length) {
            break;
        }
    }

    PercentileCounter counter = new PercentileCounter(compression, quantileRatio);
    counter.readRegisters(ByteBuffer.wrap(buffer));
    return counter;
}
 
Example 8
Source File: DoubleOperand.java    From ytk-mp4j with MIT License 5 votes vote down vote up
public MapMetaData<Double> read(Kryo kryo, Input input, Class<MapMetaData<Double>> type) {
    try {
        thatMapMetaData = mapMetaData.recv(input);
        int thatMapSegNum = thatMapMetaData.getSegNum();
        List<Map<String, Double>> thatMapListData = new ArrayList<>(thatMapSegNum);
        List<Integer> thatDataNums = new ArrayList<>(thatMapSegNum);
        for (int i = 0; i < thatMapSegNum; i++) {
            Map<String, Double> thisMapData = mapMetaData.getMapDataList().get(i);
            int dataNum = thatMapMetaData.getDataNum(i);
            for (int j = 0; j < dataNum; j++) {
                String key = input.readString();
                Double val = input.readDouble();

                Double 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 9
Source File: KryoReadingSerializer.java    From kafka-serializer-example with MIT License 5 votes vote down vote up
@Override
public SensorReading read(Kryo kryo, Input input, Class<SensorReading> aClass) {
    String id = input.readString();
    Sensor.Type type = Sensor.Type.valueOf(input.readString());

    return new SensorReading(new Sensor(id, type), input.readLong(true), input.readDouble());
}
 
Example 10
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();
	}
	
	return new ComputeContentEvent(splitId, learningNodeId, preSplitDist);
}
 
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: 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 13
Source File: AtomicDoubleSerializer.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public AtomicDouble read(Kryo kryo, Input input, Class<AtomicDouble> a) {
    return new AtomicDouble(input.readDouble());
}
 
Example 14
Source File: PyFloatSerializer.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public PyFloat read(Kryo kryo, Input input, Class<PyFloat> type) {
	return new PyFloat(input.readDouble());
}
 
Example 15
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 16
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public ConstantDoubleDistribution read (Kryo kryo, Input input, Class<ConstantDoubleDistribution> type) {
	return new ConstantDoubleDistribution(input.readDouble());
}
 
Example 17
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public GaussianDoubleDistribution read (Kryo kryo, Input input, Class<GaussianDoubleDistribution> type) {
	return new GaussianDoubleDistribution(input.readDouble(), input.readDouble());
}
 
Example 18
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public TriangularDoubleDistribution read (Kryo kryo, Input input, Class<TriangularDoubleDistribution> type) {
	return new TriangularDoubleDistribution(input.readDouble(), input.readDouble(), input.readDouble());
}
 
Example 19
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public TriangularLongDistribution read (Kryo kryo, Input input, Class<TriangularLongDistribution> type) {
	return new TriangularLongDistribution(input.readLong(), input.readLong(), input.readDouble());
}
 
Example 20
Source File: KryoUtils.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public UniformDoubleDistribution read (Kryo kryo, Input input, Class<UniformDoubleDistribution> type) {
	return new UniformDoubleDistribution(input.readDouble(), input.readDouble());
}