private static String readString(Bytes in) { byte[] bytes = new byte[in.readShort()]; in.read(bytes); return new String(bytes); }
private static String readString(Bytes in) { byte[] bytes = new byte[in.readShort()]; in.read(bytes); return new String(bytes); }
@NotNull @Override public AgentDigest read(Bytes in, long size, @Nullable AgentDigest using) { Preconditions.checkArgument(size >= FIXED_SIZE); short compression = in.readShort(); if (using == null || using.compression != compression) { using = new AgentDigest(compression, in.readLong()); } else { using.dispatchTimeMillis = in.readLong(); } using.totalWeight = 0d; using.lastUsedCell = (int) ((size - FIXED_SIZE) / PER_CENTROID_SIZE); using.tempUsed = 0; using.unmergedWeight = 0D; // need explicit nulling of weight past lastUsedCell Arrays.fill(using.weight, using.lastUsedCell, using.weight.length, 0D); for (int i = 0; i < using.lastUsedCell; ++i) { float weight = in.readFloat(); using.weight[i] = weight; using.mean[i] = in.readFloat(); using.totalWeight += weight; } return using; }
@NotNull @Override public AgentDigest read(Bytes in, long size, @Nullable AgentDigest using) { Preconditions.checkArgument(size >= FIXED_SIZE); short compression = in.readShort(); if (using == null || using.compression != compression) { using = new AgentDigest(compression, in.readLong()); } else { using.dispatchTimeMillis = in.readLong(); } using.totalWeight = 0d; using.lastUsedCell = (int) ((size - FIXED_SIZE) / PER_CENTROID_SIZE); using.tempUsed = 0; using.unmergedWeight = 0D; // need explicit nulling of weight past lastUsedCell Arrays.fill(using.weight, using.lastUsedCell, using.weight.length, 0D); for (int i = 0; i < using.lastUsedCell; ++i) { float weight = in.readFloat(); using.weight[i] = weight; using.mean[i] = in.readFloat(); using.totalWeight += weight; } return using; }
@NotNull @Override public HistogramKey read(Bytes in, @Nullable HistogramKey using) { if (using == null) { using = new HistogramKey(); } using.granularityOrdinal = in.readByte(); using.binId = in.readInt(); using.metric = readString(in); using.source = readString(in); int numTags = in.readShort(); if (numTags > 0) { using.tags = new String[numTags]; for (int i = 0; i < numTags; ++i) { using.tags[i] = readString(in); } } return using; }
@NotNull @Override public HistogramKey read(Bytes in, @Nullable HistogramKey using) { if (using == null) { using = new HistogramKey(); } using.granularityOrdinal = in.readByte(); using.binId = in.readInt(); using.metric = readString(in); using.source = readString(in); int numTags = in.readShort(); if (numTags > 0) { using.tags = new String[numTags]; for (int i = 0; i < numTags; ++i) { using.tags[i] = readString(in); } } return using; }