if (granularity instanceof AllGranularity && !missingIntervals.isEmpty()) { missingIntervals = requestedIntervals;
/** * A request is cacheable if it does not refer to partial data. * * @return whether request can be cached */ private boolean isCacheable() { SimplifiedIntervalList missingIntervals = getPartialIntervalsWithDefault(getResponseContext()); SimplifiedIntervalList volatileIntervals = getVolatileIntervalsWithDefault(getResponseContext()); return missingIntervals.isEmpty() && volatileIntervals.isEmpty(); } }
/** * A request is cacheable if it does not refer to partial data. * * @return whether request can be cached */ protected boolean isCacheable() { SimplifiedIntervalList missingIntervals = getPartialIntervalsWithDefault(getResponseContext()); SimplifiedIntervalList volatileIntervals = getVolatileIntervalsWithDefault(getResponseContext()); return missingIntervals.isEmpty() && volatileIntervals.isEmpty(); } }
@Override public SimplifiedIntervalList getVolatileIntervals( Granularity granularity, List<Interval> intervals, PhysicalTable factSource ) { SimplifiedIntervalList simplifiedIntervals = new SimplifiedIntervalList(intervals); SimplifiedIntervalList volatileIntervals = IntervalUtils.collectBucketedIntervalsIntersectingIntervalList( intervalsFunctions.getOrDefault(factSource.getName(), defaultIntervals).getVolatileIntervals(), simplifiedIntervals, granularity ); if (granularity instanceof AllGranularity && !volatileIntervals.isEmpty()) { volatileIntervals = simplifiedIntervals; } LOG.trace("Volatile intervals: {} for grain {}", volatileIntervals, granularity); return volatileIntervals; } }
/** * Remove result records which are missing and not marked as volatile. * Any bucket which is partially volatile is not removed. In the case of the All granularity, all data is * considered to be in a single bucket. * * @param result The result row being transformed * @param schema The schema for that result * @return Null if the bucket this result falls in is missing but not volatile */ @Override public Result map(Result result, ResultSetSchema schema) { Granularity grain = schema.getGranularity(); if (grain.equals(AllGranularity.INSTANCE)) { return ! volatileIntervalSupply.get().isEmpty() || missingIntervals.isEmpty() ? result : null; } // Currently any Granularity which isn't 'ALL' must currently be a TimeGrain Interval resultInterval = new Interval(result.getTimeStamp(), ((TimeGrain) grain).getPeriod()); return getMissingNotVolatile().stream().anyMatch((it) -> it.overlaps(resultInterval)) ? null : result; }
boolean paginating = pagination != null; boolean haveMissingIntervals = BardFeatureFlag.PARTIAL_DATA.isOn() && !missingIntervals.isEmpty(); boolean haveVolatileIntervals = volatileIntervals != null && ! volatileIntervals.isEmpty();
if (!overlap.isEmpty()) { logAndGetErrorCallback(ErrorMessageFormat.DATA_AVAILABILITY_MISMATCH.format(overlap), query);
/** * Bind the query interval string to a list of intervals. * * @param intervalsName The query string describing the intervals * @param granularity The granularity for this request * @param timeZone The time zone to evaluate interval timestamps in * * @return A bound list of intervals for the query */ protected List<Interval> bindIntervals(String intervalsName, Granularity granularity, DateTimeZone timeZone) { DateTimeFormatter dateTimeFormatter = generateDateTimeFormatter(timeZone); List<Interval> result; if (BardFeatureFlag.CURRENT_MACRO_USES_LATEST.isOn()) { SimplifiedIntervalList availability = TableUtils.logicalTableAvailability(getTable()); DateTime adjustedNow = new DateTime(); if (! availability.isEmpty()) { DateTime firstUnavailable = availability.getLast().getEnd(); if (firstUnavailable.isBeforeNow()) { adjustedNow = firstUnavailable; } } result = generateIntervals(adjustedNow, intervalsName, granularity, dateTimeFormatter); } else { result = generateIntervals(intervalsName, granularity, dateTimeFormatter); } return result; }
if (isEmpty()) { addLast(interval); return;
); if (! missingIntervals.isEmpty()) { ResponseContext responseContext = response.getResponseContext();
@Override public boolean handleRequest( RequestContext context, DataApiRequest request, DruidAggregationQuery<?> druidQuery, ResponseProcessor response ) { if (!(response instanceof MappingResponseProcessor)) { throw new IllegalStateException("Volatile data request handler requires a mapping response."); } MappingResponseProcessor mappingResponse = (MappingResponseProcessor) response; // Gather the volatile intervals. A volatile interval in one data source make that interval volatile overall. SimplifiedIntervalList volatileIntervals = volatileIntervalsService.getVolatileIntervals( druidQuery.getGranularity(), druidQuery.getIntervals(), physicalTableDictionary.get( druidQuery .getInnermostQuery() .getDataSource() .getPhysicalTable() .getName() ) ); if (!volatileIntervals.isEmpty()) { ResponseContext responseContext = response.getResponseContext(); responseContext.put(VOLATILE_INTERVALS_CONTEXT_KEY.getName(), volatileIntervals); } return next.handleRequest(context, request, druidQuery, mappingResponse); }