use of it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap in project pinot by linkedin.
the class PinotLLCRealtimeSegmentManager method updateFlushThresholdForSegmentMetadata.
void updateFlushThresholdForSegmentMetadata(LLCRealtimeSegmentZKMetadata segmentZKMetadata, ZNRecord partitionAssignment, int tableFlushSize) {
// Only update the flush threshold if there is a valid table flush size
if (tableFlushSize < 1) {
return;
}
// Gather list of instances for this partition
Object2IntMap<String> partitionCountForInstance = new Object2IntLinkedOpenHashMap<>();
String segmentPartitionId = new LLCSegmentName(segmentZKMetadata.getSegmentName()).getPartitionRange();
for (String instanceName : partitionAssignment.getListField(segmentPartitionId)) {
partitionCountForInstance.put(instanceName, 0);
}
// Find the maximum number of partitions served for each instance that is serving this segment
int maxPartitionCountPerInstance = 1;
for (Map.Entry<String, List<String>> partitionAndInstanceList : partitionAssignment.getListFields().entrySet()) {
for (String instance : partitionAndInstanceList.getValue()) {
if (partitionCountForInstance.containsKey(instance)) {
int partitionCountForThisInstance = partitionCountForInstance.getInt(instance);
partitionCountForThisInstance++;
partitionCountForInstance.put(instance, partitionCountForThisInstance);
if (maxPartitionCountPerInstance < partitionCountForThisInstance) {
maxPartitionCountPerInstance = partitionCountForThisInstance;
}
}
}
}
// Configure the segment size flush limit based on the maximum number of partitions allocated to a replica
int segmentFlushSize = (int) (((float) tableFlushSize) / maxPartitionCountPerInstance);
segmentZKMetadata.setSizeThresholdToFlushSegment(segmentFlushSize);
}
Aggregations