belliottsmith commented on code in PR #4202:
URL: https://github.com/apache/cassandra/pull/4202#discussion_r2192756702
##########
src/java/org/apache/cassandra/service/accord/serializers/TopologySerializers.java:
##########
@@ -159,4 +167,127 @@ public long serializedSize(Topology topology)
return size;
}
};
+
+ public static final UnversionedSerializer<Topology> compactTopology = new
UnversionedSerializer<>()
+ {
+ @Override
+ public void serialize(Topology topology, DataOutputPlus out) throws
IOException
+ {
+ out.writeLong(topology.epoch());
+ CollectionSerializers.serializeList(topology.staleIds(), out,
TopologySerializers.nodeId);
+
+ List<Shard> shards = topology.shards();
+
+ // need to loop twice; once to collect tables/ranges, and another
to save shards
+ ImmutableUniqueList<TableId> tables;
Review Comment:
In fact, you can even do this dynamically - which is another common
technique in our serializers. When you go to serialise a value, you deserialize
the index, and if the index is some sentinel (e.g. 0), then you deserialize a
new value and insert it into the List. Otherwise you lookup the relevant index
that has already been deserialised. On serialization, when you lookup the
index, if it isn't there you write the sentinel and then the value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]