use of com.ms.silverking.cloud.dht.daemon.storage.convergence.AbstractChecksumNode in project SilverKing by Morgan-Stanley.
the class ProtoChecksumTreeMessageGroup method deserialize.
public static ChecksumNode deserialize(ByteBuffer buffer) {
NodeType type;
RingRegion region;
int numChildren;
AbstractChecksumNode root;
type = NodeType.values()[buffer.get()];
if (type != NodeType.NULL) {
region = deserializeRegion(buffer);
numChildren = buffer.getInt();
} else {
region = null;
numChildren = 0;
}
switch(type) {
case NON_LEAF:
List<ChecksumNode> children;
children = new ArrayList<>(numChildren);
for (int i = 0; i < numChildren; i++) {
children.add(deserialize(buffer));
}
root = new NonLeafChecksumNode(region, children);
break;
case LEAF:
List<KeyAndVersionChecksum> keyAndVersionChecksums;
keyAndVersionChecksums = deserializeKeyAndVersionChecksums(buffer);
root = new LeafChecksumNode(region, keyAndVersionChecksums);
break;
case NULL:
root = null;
break;
default:
throw new RuntimeException("panic");
}
if (root != null) {
root.freezeIfNotFrozen();
}
return root;
}
Aggregations