Search in sources :

Example 6 with HLCSegmentName

use of com.linkedin.pinot.common.utils.HLCSegmentName in project pinot by linkedin.

the class ValidationManagerTest method testTotalDocumentCountRealTime.

@Test
public void testTotalDocumentCountRealTime() throws Exception {
    // Create a bunch of dummy segments
    String testTableName = "TestTableTotalDocCountTest";
    final String group1 = testTableName + "_REALTIME_1466446700000_34";
    final String group2 = testTableName + "_REALTIME_1466446700000_17";
    String segmentName1 = new HLCSegmentName(group1, "0", "1").getSegmentName();
    String segmentName2 = new HLCSegmentName(group1, "0", "2").getSegmentName();
    String segmentName3 = new HLCSegmentName(group1, "0", "3").getSegmentName();
    String segmentName4 = new HLCSegmentName(group2, "0", "3").getSegmentName();
    DummyMetadata metadata1 = new DummyMetadata(testTableName, segmentName1, 10);
    DummyMetadata metadata2 = new DummyMetadata(testTableName, segmentName2, 20);
    DummyMetadata metadata3 = new DummyMetadata(testTableName, segmentName3, 30);
    // This should get ignored in the count as it belongs to a different group id
    DummyMetadata metadata4 = new DummyMetadata(testTableName, segmentName4, 20);
    // Add them to a list
    List<SegmentMetadata> segmentMetadataList = new ArrayList<SegmentMetadata>();
    segmentMetadataList.add(metadata1);
    segmentMetadataList.add(metadata2);
    segmentMetadataList.add(metadata3);
    segmentMetadataList.add(metadata4);
    Assert.assertEquals(ValidationManager.computeRealtimeTotalDocumentInSegments(segmentMetadataList, true), 60);
    // Now add some low level segment names
    String segmentName5 = new LLCSegmentName(testTableName, 1, 0, 1000).getSegmentName();
    String segmentName6 = new LLCSegmentName(testTableName, 2, 27, 10000).getSegmentName();
    DummyMetadata metadata5 = new DummyMetadata(testTableName, segmentName5, 10);
    DummyMetadata metadata6 = new DummyMetadata(testTableName, segmentName6, 5);
    segmentMetadataList.add(metadata5);
    segmentMetadataList.add(metadata6);
    // Only the LLC segments should get counted.
    Assert.assertEquals(ValidationManager.computeRealtimeTotalDocumentInSegments(segmentMetadataList, false), 15);
}
Also used : HLCSegmentName(com.linkedin.pinot.common.utils.HLCSegmentName) SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) LLCSegmentName(com.linkedin.pinot.common.utils.LLCSegmentName) Test(org.testng.annotations.Test)

Aggregations

HLCSegmentName (com.linkedin.pinot.common.utils.HLCSegmentName)6 ArrayList (java.util.ArrayList)4 LLCSegmentName (com.linkedin.pinot.common.utils.LLCSegmentName)3 Test (org.testng.annotations.Test)3 SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)2 Field (java.lang.reflect.Field)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)2 ExternalView (org.apache.helix.model.ExternalView)2 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)1 InstanceZKMetadata (com.linkedin.pinot.common.metadata.instance.InstanceZKMetadata)1 RealtimeSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.RealtimeSegmentZKMetadata)1 KafkaStreamMetadata (com.linkedin.pinot.common.metadata.stream.KafkaStreamMetadata)1 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)1 Pair (com.linkedin.pinot.core.query.utils.Pair)1 ServerToSegmentSetMap (com.linkedin.pinot.routing.ServerToSegmentSetMap)1 KafkaHighLevelConsumerBasedRoutingTableBuilder (com.linkedin.pinot.routing.builder.KafkaHighLevelConsumerBasedRoutingTableBuilder)1 RandomRoutingTableBuilder (com.linkedin.pinot.routing.builder.RandomRoutingTableBuilder)1 RoutingTableBuilder (com.linkedin.pinot.routing.builder.RoutingTableBuilder)1