Search in sources :

Example 1 with MonotonicNonNull

use of org.checkerframework.checker.nullness.qual.MonotonicNonNull in project druid by druid-io.

the class SqlSegmentsMetadataManager method replaceWithExistingSegmentIfPresent.

/**
 * For the garbage collector in Java, it's better to keep new objects short-living, but once they are old enough
 * (i. e. promoted to old generation), try to keep them alive. In {@link #poll()}, we fetch and deserialize all
 * existing segments each time, and then replace them in {@link #dataSourcesSnapshot}. This method allows to use
 * already existing (old) segments when possible, effectively interning them a-la {@link String#intern} or {@link
 * com.google.common.collect.Interner}, aiming to make the majority of {@link DataSegment} objects garbage soon after
 * they are deserialized and to die in young generation. It allows to avoid fragmentation of the old generation and
 * full GCs.
 */
private DataSegment replaceWithExistingSegmentIfPresent(DataSegment segment) {
    @MonotonicNonNull DataSourcesSnapshot dataSourcesSnapshot = this.dataSourcesSnapshot;
    if (dataSourcesSnapshot == null) {
        return segment;
    }
    @Nullable ImmutableDruidDataSource dataSource = dataSourcesSnapshot.getDataSource(segment.getDataSource());
    if (dataSource == null) {
        return segment;
    }
    DataSegment alreadyExistingSegment = dataSource.getSegment(segment.getId());
    return alreadyExistingSegment != null ? alreadyExistingSegment : segment;
}
Also used : ImmutableDruidDataSource(org.apache.druid.client.ImmutableDruidDataSource) MonotonicNonNull(org.checkerframework.checker.nullness.qual.MonotonicNonNull) DataSourcesSnapshot(org.apache.druid.client.DataSourcesSnapshot) DataSegment(org.apache.druid.timeline.DataSegment) Nullable(javax.annotation.Nullable)

Example 2 with MonotonicNonNull

use of org.checkerframework.checker.nullness.qual.MonotonicNonNull in project ExoPlayer by google.

the class FakeVideoRenderer method shouldProcessBuffer.

@Override
protected boolean shouldProcessBuffer(long bufferTimeUs, long playbackPositionUs) {
    boolean shouldProcess = super.shouldProcessBuffer(bufferTimeUs, playbackPositionUs);
    boolean shouldRenderFirstFrame = output != null && (!renderedFirstFrameAfterEnable ? (getState() == Renderer.STATE_STARTED || mayRenderFirstFrameAfterEnableIfNotStarted) : !renderedFirstFrameAfterReset);
    shouldProcess |= shouldRenderFirstFrame && playbackPositionUs >= streamOffsetUs;
    @Nullable Object output = this.output;
    if (shouldProcess && !renderedFirstFrameAfterReset && output != null) {
        @MonotonicNonNull Format format = Assertions.checkNotNull(this.format);
        eventDispatcher.videoSizeChanged(new VideoSize(format.width, format.height, format.rotationDegrees, format.pixelWidthHeightRatio));
        eventDispatcher.renderedFirstFrame(output);
        renderedFirstFrameAfterReset = true;
        renderedFirstFrameAfterEnable = true;
    }
    return shouldProcess;
}
Also used : Format(com.google.android.exoplayer2.Format) MonotonicNonNull(org.checkerframework.checker.nullness.qual.MonotonicNonNull) VideoSize(com.google.android.exoplayer2.video.VideoSize) Nullable(androidx.annotation.Nullable)

Aggregations

MonotonicNonNull (org.checkerframework.checker.nullness.qual.MonotonicNonNull)2 Nullable (androidx.annotation.Nullable)1 Format (com.google.android.exoplayer2.Format)1 VideoSize (com.google.android.exoplayer2.video.VideoSize)1 Nullable (javax.annotation.Nullable)1 DataSourcesSnapshot (org.apache.druid.client.DataSourcesSnapshot)1 ImmutableDruidDataSource (org.apache.druid.client.ImmutableDruidDataSource)1 DataSegment (org.apache.druid.timeline.DataSegment)1