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);
}
Aggregations