public EstimatedHistogram deserialize(DataInputPlus in) throws IOException { int size = in.readInt(); long[] offsets = new long[size - 1]; long[] buckets = new long[size]; for (int i = 0; i < size; i++) { offsets[i == 0 ? 0 : i - 1] = in.readLong(); buckets[i] = in.readLong(); } return new EstimatedHistogram(offsets, buckets); }
private static Collection<Mutation> decodeMutations(DataInputPlus in, int version) throws IOException { int count = (int) in.readUnsignedVInt(); ArrayList<Mutation> mutations = new ArrayList<>(count); for (int i = 0; i < count; i++) { in.readUnsignedVInt(); // skip mutation size mutations.add(Mutation.serializer.deserialize(in, version)); } return mutations; }
private static Collection<ByteBuffer> readEncodedMutations(DataInputPlus in) throws IOException { int count = (int) in.readUnsignedVInt(); ArrayList<ByteBuffer> mutations = new ArrayList<>(count); for (int i = 0; i < count; i++) mutations.add(ByteBufferUtil.readWithVIntLength(in)); return mutations; }
public Batch deserialize(DataInputPlus in, int version) throws IOException { UUID id = UUIDSerializer.serializer.deserialize(in, version); long creationTime = in.readLong(); /* * If version doesn't match the current one, we cannot not just read the encoded mutations verbatim, * so we decode them instead, to deal with compatibility. */ return version == MessagingService.current_version ? createRemote(id, creationTime, readEncodedMutations(in)) : createLocal(id, creationTime, decodeMutations(in, version)); }
public PrepareResponse deserialize(DataInputPlus in, int version) throws IOException { boolean success = in.readBoolean(); Commit inProgress = Commit.serializer.deserialize(in, version); Commit mostRecent; if (version < MessagingService.VERSION_30) { UUID ballot = UUIDSerializer.serializer.deserialize(in, version); PartitionUpdate update = PartitionUpdate.serializer.deserialize( in, version, SerializationHelper.Flag.LOCAL, inProgress.update.partitionKey()); mostRecent = new Commit(ballot, update); } else { mostRecent = Commit.serializer.deserialize(in, version); } return new PrepareResponse(success, inProgress, mostRecent); }
public Slices deserialize(DataInputPlus in, int version, CFMetaData metadata) throws IOException { int size = (int) in.readVInt(); if (size == 0) return NONE; Slice[] slices = new Slice[size]; for (int i = 0; i < size; i++) slices[i] = Slice.serializer.deserialize(in, version, metadata.comparator.subtypes()); if (size == 1 && slices[0].start() == Slice.Bound.BOTTOM && slices[0].end() == Slice.Bound.TOP) return ALL; return new ArrayBackedSlices(metadata.comparator, slices); }