com.google.protobuf.CodedInputStream# readDouble ( ) 源码实例Demo

下面列出了com.google.protobuf.CodedInputStream# readDouble ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: blueflood   文件: RawSerDes.java

private Object deserializeSimpleMetric(CodedInputStream in) throws IOException {
    byte metricValueType = in.readRawByte() /* type field */;
    switch (metricValueType) {
        case Constants.I32:
            return in.readRawVarint32();
        case Constants.I64:
            return in.readRawVarint64();
        case Constants.DOUBLE:
            return in.readDouble();
        case Constants.STR:
            throw new UnexpectedStringSerializationException("We don't rollup strings");
        default:
            throw new SerializationException(String.format("Unexpected raw metric type=%s for full res " +
                                                            "metric", (char)metricValueType));
    }
}
 
源代码2 项目: blueflood   文件: AbstractSerDes.java

protected Number getUnversionedDoubleOrLong(CodedInputStream in) throws IOException {
    byte type = in.readRawByte();
    if (type == Constants.B_DOUBLE)
        return in.readDouble();
    else
        return in.readRawVarint64();
}
 
源代码3 项目: jprotobuf   文件: CodedConstant.java

/**
 * Read a field of any primitive type for immutable messages from a CodedInputStream. Enums, groups, and embedded
 * messages are not handled by this method.
 *
 * @param input The stream from which to read.
 * @param type Declared type of the field.
 * @param checkUtf8 When true, check that the input is valid utf8.
 * @return An object representing the field's value, of the exact type which would be returned by
 *         {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static Object readPrimitiveField(CodedInputStream input, final WireFormat.FieldType type, boolean checkUtf8)
        throws IOException {
    switch (type) {
        case DOUBLE:
            return input.readDouble();
        case FLOAT:
            return input.readFloat();
        case INT64:
            return input.readInt64();
        case UINT64:
            return input.readUInt64();
        case INT32:
            return input.readInt32();
        case FIXED64:
            return input.readFixed64();
        case FIXED32:
            return input.readFixed32();
        case BOOL:
            return input.readBool();
        case STRING:
            if (checkUtf8) {
                return input.readStringRequireUtf8();
            } else {
                return input.readString();
            }
        case BYTES:
            return input.readByteArray();
        case UINT32:
            return input.readUInt32();
        case SFIXED32:
            return input.readSFixed32();
        case SFIXED64:
            return input.readSFixed64();
        case SINT32:
            return input.readSInt32();
        case SINT64:
            return input.readSInt64();

        case GROUP:
            throw new IllegalArgumentException("readPrimitiveField() cannot handle nested groups.");
        case MESSAGE:
            throw new IllegalArgumentException("readPrimitiveField() cannot handle embedded messages.");
        case ENUM:
            // We don't handle enums because we don't know what to do if the
            // value is not recognized.
            throw new IllegalArgumentException("readPrimitiveField() cannot handle enums.");
    }

    throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
}
 
源代码4 项目: blueflood   文件: CounterSerDes.java

private BluefloodCounterRollup deserializeV1CounterRollup(CodedInputStream in) throws IOException {
    Number value = getUnversionedDoubleOrLong(in);
    double rate = in.readDouble();
    int sampleCount = in.readRawVarint32();
    return new BluefloodCounterRollup().withCount(value.longValue()).withRate(rate).withSampleCount(sampleCount);
}
 
源代码5 项目: blueflood   文件: TimerRollupSerDes.java

private BluefloodTimerRollup deserializeTimer(CodedInputStream in, byte timerVersion) throws IOException {
    // note: type and version have already been read.
    final double sum;
    if (timerVersion == VERSION_1_TIMER) {
        sum = in.readRawVarint64();
    } else if (timerVersion == VERSION_2_TIMER) {
        sum = in.readDouble();
    } else {
        throw new SerializationException(String.format("Unexpected timer deserialization version: %d", (int)timerVersion));
    }

    final long count = in.readRawVarint64();
    final double countPs = in.readDouble();
    final int sampleCount = in.readRawVarint32();

    // average
    byte statType = in.readRawByte();
    Average average = new Average();
    averageStatDeSer.deserialize(average, in);

    // max
    statType = in.readRawByte();
    MaxValue maxValue = new MaxValue();
    maxStatDeSer.deserialize(maxValue, in);

    // min
    statType = in.readRawByte();
    MinValue minValue = new MinValue();
    minStatDeSer.deserialize(minValue, in);

    // var
    statType = in.readRawByte();
    Variance variance = new Variance();
    varianceStatDeSer.deserialize(variance, in);

    BluefloodTimerRollup rollup = new BluefloodTimerRollup()
            .withSum(sum)
            .withCount(count)
            .withCountPS(countPs)
            .withSampleCount(sampleCount)
            .withAverage(average)
            .withMaxValue(maxValue)
            .withMinValue(minValue)
            .withVariance(variance);

    int numPercentiles = in.readRawVarint32();
    for (int i = 0; i < numPercentiles; i++) {
        String name = in.readString();
        Number mean = getUnversionedDoubleOrLong(in);
        rollup.setPercentile(name, mean);
    }

    return rollup;
}