Search in sources :

Example 66 with QueryableIndex

use of org.apache.druid.segment.QueryableIndex in project druid by druid-io.

the class DruidSchemaConcurrencyTest method addSegmentsToCluster.

private void addSegmentsToCluster(int partitionIdStart, int numServers, int numSegments) {
    for (int i = 0; i < numSegments; i++) {
        DataSegment segment = newSegment(i + partitionIdStart);
        QueryableIndex index = newQueryableIndex(i + partitionIdStart);
        walker.add(segment, index);
        int serverIndex = i % numServers;
        inventoryView.addServerSegment(newServer("server_" + serverIndex), segment);
    }
}
Also used : QueryableIndex(org.apache.druid.segment.QueryableIndex) DataSegment(org.apache.druid.timeline.DataSegment)

Example 67 with QueryableIndex

use of org.apache.druid.segment.QueryableIndex in project druid by druid-io.

the class FireHydrantTest method testGetSegmentForQueryButNotAbleToAcquireReferences.

@Test
public void testGetSegmentForQueryButNotAbleToAcquireReferences() {
    ReferenceCountingSegment incrementalSegmentReference = hydrant.getHydrantSegment();
    Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
    Optional<Pair<SegmentReference, Closeable>> maybeSegmentAndCloseable = hydrant.getSegmentForQuery(segmentReference -> new SegmentReference() {

        @Override
        public Optional<Closeable> acquireReferences() {
            return Optional.empty();
        }

        @Override
        public SegmentId getId() {
            return incrementalIndexSegment.getId();
        }

        @Override
        public Interval getDataInterval() {
            return incrementalIndexSegment.getDataInterval();
        }

        @Nullable
        @Override
        public QueryableIndex asQueryableIndex() {
            return incrementalIndexSegment.asQueryableIndex();
        }

        @Override
        public StorageAdapter asStorageAdapter() {
            return incrementalIndexSegment.asStorageAdapter();
        }

        @Override
        public void close() {
            incrementalIndexSegment.close();
        }
    });
    Assert.assertFalse(maybeSegmentAndCloseable.isPresent());
    Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
}
Also used : ReferenceCountingSegment(org.apache.druid.segment.ReferenceCountingSegment) Optional(java.util.Optional) SegmentId(org.apache.druid.timeline.SegmentId) QueryableIndex(org.apache.druid.segment.QueryableIndex) SegmentReference(org.apache.druid.segment.SegmentReference) StorageAdapter(org.apache.druid.segment.StorageAdapter) Nullable(javax.annotation.Nullable) Pair(org.apache.druid.java.util.common.Pair) Interval(org.joda.time.Interval) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

QueryableIndex (org.apache.druid.segment.QueryableIndex)67 File (java.io.File)29 ArrayList (java.util.ArrayList)29 IncrementalIndex (org.apache.druid.segment.incremental.IncrementalIndex)18 DataSegment (org.apache.druid.timeline.DataSegment)18 QueryableIndexSegment (org.apache.druid.segment.QueryableIndexSegment)17 IOException (java.io.IOException)15 LinearShardSpec (org.apache.druid.timeline.partition.LinearShardSpec)15 IndexSpec (org.apache.druid.segment.IndexSpec)14 InputRow (org.apache.druid.data.input.InputRow)13 OnheapIncrementalIndex (org.apache.druid.segment.incremental.OnheapIncrementalIndex)13 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)12 SpecificSegmentsQuerySegmentWalker (org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker)12 List (java.util.List)10 Before (org.junit.Before)10 QueryRunner (org.apache.druid.query.QueryRunner)9 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)9 IndexBuilder (org.apache.druid.segment.IndexBuilder)9 Nullable (javax.annotation.Nullable)8 ISE (org.apache.druid.java.util.common.ISE)8