Record Class PartitionAssignment
java.lang.Object
java.lang.Record
com.loomcache.server.sharding.PartitionAssignment
- Record Components:
numPartitions- the total number of partitions (must be > 0)numGroups- the total number of Raft groups (must be > 0)partitionToGroup- mapping from partitionId (index) to raftGroupId (value), defensively copied
public record PartitionAssignment(int numPartitions, int numGroups, int[] partitionToGroup)
extends Record
Immutable snapshot of the current partition-to-group mapping.
This record captures a point-in-time view of how partitions are
distributed across Raft groups. The partitionToGroup array is
defensively copied on construction to guarantee immutability.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionPartitionAssignment(int numPartitions, int numGroups, int[] partitionToGroup) Compact constructor with validation and defensive copy. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.intReturns the value of thenumGroupsrecord component.intReturns the value of thenumPartitionsrecord component.int[]Returns a defensive copy of the partition-to-group mapping.toString()Returns a string representation of this record class.
-
Constructor Details
-
PartitionAssignment
public PartitionAssignment(int numPartitions, int numGroups, int[] partitionToGroup) Compact constructor with validation and defensive copy.
-
-
Method Details
-
partitionToGroup
public int[] partitionToGroup()Returns a defensive copy of the partition-to-group mapping.- Returns:
- copy of the mapping array (never null)
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
hashCode
-
toString
-
numPartitions
public int numPartitions()Returns the value of thenumPartitionsrecord component.- Returns:
- the value of the
numPartitionsrecord component
-
numGroups
-