use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.
the class ValidationManagerTest method testPushTimePersistence.
@Test
public void testPushTimePersistence() throws Exception {
DummyMetadata metadata = new DummyMetadata(TEST_TABLE_NAME);
_pinotHelixResourceManager.addSegment(metadata, "http://dummy/");
Thread.sleep(1000);
OfflineSegmentZKMetadata offlineSegmentZKMetadata = ZKMetadataProvider.getOfflineSegmentZKMetadata(_pinotHelixResourceManager.getPropertyStore(), metadata.getTableName(), metadata.getName());
SegmentMetadata fetchedMetadata = new SegmentMetadataImpl(offlineSegmentZKMetadata);
long pushTime = fetchedMetadata.getPushTime();
// Check that the segment has been pushed in the last 30 seconds
Assert.assertTrue(System.currentTimeMillis() - pushTime < 30000);
// Check that there is no refresh time
Assert.assertEquals(fetchedMetadata.getRefreshTime(), Long.MIN_VALUE);
// Refresh the segment
metadata.setCrc("anotherfakecrc");
_pinotHelixResourceManager.addSegment(metadata, "http://dummy/");
Thread.sleep(1000);
offlineSegmentZKMetadata = ZKMetadataProvider.getOfflineSegmentZKMetadata(_pinotHelixResourceManager.getPropertyStore(), metadata.getTableName(), metadata.getName());
fetchedMetadata = new SegmentMetadataImpl(offlineSegmentZKMetadata);
// Check that the segment still has the same push time
Assert.assertEquals(fetchedMetadata.getPushTime(), pushTime);
// Check that the refresh time is in the last 30 seconds
Assert.assertTrue(System.currentTimeMillis() - fetchedMetadata.getRefreshTime() < 30000);
}
use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.
the class BaseSumStarTreeIndexTest method testHardCodedQueries.
protected void testHardCodedQueries(IndexSegment segment, Schema schema) {
// Test against all metric columns, instead of just the aggregation column in the query.
List<String> metricNames = schema.getMetricNames();
SegmentMetadata segmentMetadata = segment.getSegmentMetadata();
for (int i = 0; i < _hardCodedQueries.length; i++) {
Pql2Compiler compiler = new Pql2Compiler();
BrokerRequest brokerRequest = compiler.compileToBrokerRequest(_hardCodedQueries[i]);
FilterQueryTree filterQueryTree = RequestUtils.generateFilterQueryTree(brokerRequest);
Assert.assertTrue(RequestUtils.isFitForStarTreeIndex(segmentMetadata, filterQueryTree, brokerRequest));
Map<String, double[]> expectedResult = computeSumUsingRawDocs(segment, metricNames, brokerRequest);
Map<String, double[]> actualResult = computeSumUsingAggregatedDocs(segment, metricNames, brokerRequest);
Assert.assertEquals(expectedResult.size(), actualResult.size(), "Mis-match in number of groups");
for (Map.Entry<String, double[]> entry : expectedResult.entrySet()) {
String expectedKey = entry.getKey();
Assert.assertTrue(actualResult.containsKey(expectedKey));
double[] expectedSums = entry.getValue();
double[] actualSums = actualResult.get(expectedKey);
for (int j = 0; j < expectedSums.length; j++) {
Assert.assertEquals(actualSums[j], expectedSums[j], "Mis-match sum for key '" + expectedKey + "', Metric: " + metricNames.get(j) + ", Random Seed: " + _randomSeed);
}
}
}
}
use of com.linkedin.pinot.common.segment.SegmentMetadata in project pinot by linkedin.
the class OfflineTableDataManagerTest method makeIndexSegment.
private IndexSegment makeIndexSegment(String name, int totalDocs) {
IndexSegment indexSegment = mock(IndexSegment.class);
SegmentMetadata segmentMetadata = mock(SegmentMetadata.class);
when(indexSegment.getSegmentMetadata()).thenReturn(segmentMetadata);
when(indexSegment.getSegmentName()).thenReturn(name);
when(indexSegment.getSegmentMetadata().getTotalDocs()).thenReturn(totalDocs);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
_nDestroys++;
return null;
}
}).when(indexSegment).destroy();
_allSegments.add(indexSegment);
return indexSegment;
}
Aggregations