Search in sources :

Example 1 with Object2IntLinkedOpenHashMap

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);
}
Also used : Object2IntLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap) List(java.util.List) ArrayList(java.util.ArrayList) LLCSegmentName(com.linkedin.pinot.common.utils.LLCSegmentName) Object2IntLinkedOpenHashMap(it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap) Map(java.util.Map) HashMap(java.util.HashMap) Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap)

Aggregations

LLCSegmentName (com.linkedin.pinot.common.utils.LLCSegmentName)1 Object2IntLinkedOpenHashMap (it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap)1 Object2IntMap (it.unimi.dsi.fastutil.objects.Object2IntMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1