Search in sources :

Example 1 with Object2IntMap

use of it.unimi.dsi.fastutil.objects.Object2IntMap in project druid by druid-io.

the class ListFilteredDimensionSpecDimensionSelectorTest method testAllowList.

private void testAllowList(boolean unknownCardinality, boolean validIdLookup, boolean nameLookupPossibleInAdvance, Class<? extends DimensionSelector> expectedDimensionSelectorClass) {
    RowSupplier rowSupplier = new RowSupplier();
    NonnullPair<Object2IntMap<String>, Int2ObjectMap<String>> dictionaries = createDictionaries(data);
    DimensionSelector selector = targetWithAllowList.decorate(new StringDimensionSelectorForTest(rowSupplier, dictionaries.lhs, dictionaries.rhs, unknownCardinality, validIdLookup, nameLookupPossibleInAdvance));
    Assert.assertSame(expectedDimensionSelectorClass, selector.getClass());
    assertAllowListFiltering(rowSupplier, selector);
}
Also used : DimensionSelector(org.apache.druid.segment.DimensionSelector) Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap)

Example 2 with Object2IntMap

use of it.unimi.dsi.fastutil.objects.Object2IntMap in project druid by druid-io.

the class ListFilteredDimensionSpecDimensionSelectorTest method testDenyList.

private void testDenyList(boolean unknownCardinality, boolean validIdLookup, boolean nameLookupPossibleInAdvance, Class<? extends DimensionSelector> expectedDimensionSelectorClass) {
    RowSupplier rowSupplier = new RowSupplier();
    NonnullPair<Object2IntMap<String>, Int2ObjectMap<String>> dictionaries = createDictionaries(data);
    DimensionSelector selector = targetWithDenyList.decorate(new StringDimensionSelectorForTest(rowSupplier, dictionaries.lhs, dictionaries.rhs, unknownCardinality, validIdLookup, nameLookupPossibleInAdvance));
    Assert.assertSame(expectedDimensionSelectorClass, selector.getClass());
    assertDenyListFiltering(rowSupplier, selector);
}
Also used : DimensionSelector(org.apache.druid.segment.DimensionSelector) Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap)

Example 3 with Object2IntMap

use of it.unimi.dsi.fastutil.objects.Object2IntMap 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

Object2IntMap (it.unimi.dsi.fastutil.objects.Object2IntMap)3 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)2 DimensionSelector (org.apache.druid.segment.DimensionSelector)2 LLCSegmentName (com.linkedin.pinot.common.utils.LLCSegmentName)1 Object2IntLinkedOpenHashMap (it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1