use of org.apache.druid.segment.ReferenceCountingSegment 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());
}
use of org.apache.druid.segment.ReferenceCountingSegment in project druid by druid-io.
the class FireHydrantTest method testGetIncrementedSegmentSwapped.
@Test
public void testGetIncrementedSegmentSwapped() {
ReferenceCountingSegment incrementalSegmentReference = hydrant.getHydrantSegment();
Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
hydrant.swapSegment(queryableIndexSegment);
ReferenceCountingSegment segment = hydrant.getIncrementedSegment();
Assert.assertNotNull(segment);
Assert.assertTrue(segment.getBaseSegment() == queryableIndexSegment);
Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
Assert.assertEquals(1, segment.getNumReferences());
}
use of org.apache.druid.segment.ReferenceCountingSegment in project druid by druid-io.
the class FireHydrantTest method testGetSegmentForQueryButNotAbleToAcquireReferencesSegmentClosed.
@Test
public void testGetSegmentForQueryButNotAbleToAcquireReferencesSegmentClosed() {
expectedException.expect(ISE.class);
expectedException.expectMessage("segment.close() is called somewhere outside FireHydrant.swapSegment()");
ReferenceCountingSegment incrementalSegmentReference = hydrant.getHydrantSegment();
Assert.assertEquals(0, incrementalSegmentReference.getNumReferences());
incrementalSegmentReference.close();
Optional<Pair<SegmentReference, Closeable>> maybeSegmentAndCloseable = hydrant.getSegmentForQuery(Function.identity());
}
use of org.apache.druid.segment.ReferenceCountingSegment in project druid by druid-io.
the class FireHydrantTest method testGetIncrementedSegmentNotSwapped.
@Test
public void testGetIncrementedSegmentNotSwapped() {
Assert.assertEquals(0, hydrant.getHydrantSegment().getNumReferences());
ReferenceCountingSegment segment = hydrant.getIncrementedSegment();
Assert.assertNotNull(segment);
Assert.assertTrue(segment.getBaseSegment() == incrementalIndexSegment);
Assert.assertEquals(1, segment.getNumReferences());
}
use of org.apache.druid.segment.ReferenceCountingSegment in project druid by druid-io.
the class TestClusterQuerySegmentWalker method getSegmentsForTable.
private List<WindowedSegment> getSegmentsForTable(final String dataSource, final Iterable<SegmentDescriptor> specs) {
final VersionedIntervalTimeline<String, ReferenceCountingSegment> timeline = timelines.get(dataSource);
if (timeline == null) {
return Collections.emptyList();
} else {
final List<WindowedSegment> retVal = new ArrayList<>();
for (SegmentDescriptor spec : specs) {
final PartitionChunk<ReferenceCountingSegment> entry = timeline.findChunk(spec.getInterval(), spec.getVersion(), spec.getPartitionNumber());
retVal.add(new WindowedSegment(entry.getObject(), spec.getInterval()));
}
return retVal;
}
}
Aggregations