Search in sources :

Example 31 with SegmentMetadata

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);
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) OfflineSegmentZKMetadata(com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata) SegmentMetadataImpl(com.linkedin.pinot.core.segment.index.SegmentMetadataImpl) Test(org.testng.annotations.Test)

Example 32 with SegmentMetadata

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);
            }
        }
    }
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) FilterQueryTree(com.linkedin.pinot.common.utils.request.FilterQueryTree) Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) HashMap(java.util.HashMap) Map(java.util.Map)

Example 33 with SegmentMetadata

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;
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) Answer(org.mockito.stubbing.Answer) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Aggregations

SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)33 Test (org.testng.annotations.Test)10 SegmentMetadataImpl (com.linkedin.pinot.core.segment.index.SegmentMetadataImpl)8 SimpleSegmentMetadata (com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata)7 File (java.io.File)6 AfterTest (org.testng.annotations.AfterTest)6 BeforeTest (org.testng.annotations.BeforeTest)6 RetentionManager (com.linkedin.pinot.controller.helix.core.retention.RetentionManager)5 ArrayList (java.util.ArrayList)5 OfflineSegmentZKMetadata (com.linkedin.pinot.common.metadata.segment.OfflineSegmentZKMetadata)4 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)4 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)3 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)3 HashMap (java.util.HashMap)3 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)2 HLCSegmentName (com.linkedin.pinot.common.utils.HLCSegmentName)2 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)2 TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)2 Interval (org.joda.time.Interval)2 Matchers.anyString (org.mockito.Matchers.anyString)2