/** * Transforms dependent table names to metrics. * * @param tableNames The names of the tables to be mapped * @param physicalTableDictionary The physical table dictionary to resolve the names * * @return set of PhysicalTables from the ResourceDictionaries */ private static Set<ConfigPhysicalTable> mapNamestoTables( Collection<String> tableNames, PhysicalTableDictionary physicalTableDictionary ) { Set<String> missingTableNames = tableNames.stream() .filter(it -> ! physicalTableDictionary.containsKey(it)) .collect(Collectors.toSet()); if (!missingTableNames.isEmpty()) { String message = String.format(MISSING_DEPENDANT_TABLE_FORMAT, missingTableNames); throw new IllegalArgumentException(message); } return tableNames.stream() .map(it -> physicalTableDictionary.get(it)) .collect(Collectors.toSet()); }
@Override public ConfigPhysicalTable build(ResourceDictionaries dictionaries, DataSourceMetadataService metadataService) { Map<ConfigPhysicalTable, DataSourceFilter> availabilityFilters = tablePartDefinitions.entrySet().stream() .collect(Collectors.toMap( entry -> dictionaries.getPhysicalDictionary().get(entry.getKey().asName()), entry -> new DimensionIdFilter(toDimensionValuesMap( entry.getValue(), dictionaries.getDimensionDictionary() )) )); return new BaseCompositePhysicalTable( getName(), getTimeGrain(), buildColumns(dictionaries.getDimensionDictionary()), availabilityFilters.keySet(), getLogicalToPhysicalNames(), PartitionAvailability.build(availabilityFilters) ); }
PhysicalTable table = tableDictionary.get(sliceName);
return physicalTableDictionary.get(currentTableName);
@Override protected VolatileIntervalsService getVolatileIntervalsService() { PhysicalTableDictionary physicalTableDictionary = getConfigurationLoader().getPhysicalTableDictionary(); Map<PhysicalTable, VolatileIntervalsFunction> hourlyMonthlyVolatileIntervals = new LinkedHashMap<>(); if (physicalTableDictionary.containsKey(HOURLY.asName())) { hourlyMonthlyVolatileIntervals.put( getConfigurationLoader().getPhysicalTableDictionary().get(HOURLY.asName()), () -> new SimplifiedIntervalList( Collections.singleton( new Interval(new DateTime(2016, 8, 15, 0, 0), new DateTime(2016, 8, 16, 0, 0)) ) ) ); } if (physicalTableDictionary.containsKey(MONTHLY.asName())) { hourlyMonthlyVolatileIntervals.put( getConfigurationLoader().getPhysicalTableDictionary().get(MONTHLY.asName()), () -> new SimplifiedIntervalList( Collections.singleton( new Interval(new DateTime(2016, 8, 1, 0, 0), new DateTime(2016, 9, 1, 0, 0)) ) ) ); } return new DefaultingVolatileIntervalsService( NoVolatileIntervalsFunction.INSTANCE, hourlyMonthlyVolatileIntervals ); }
@Override protected VolatileIntervalsService getVolatileIntervalsService() { PhysicalTableDictionary physicalTableDictionary = getConfigurationLoader().getPhysicalTableDictionary(); Map<PhysicalTable, VolatileIntervalsFunction> hourlyMonthlyVolatileIntervals = new LinkedHashMap<>(); if (physicalTableDictionary.containsKey(HOURLY.asName())) { hourlyMonthlyVolatileIntervals.put( getConfigurationLoader().getPhysicalTableDictionary().get(HOURLY.asName()), () -> new SimplifiedIntervalList( Collections.singleton( new Interval(new DateTime(2016, 8, 15, 0, 0), new DateTime(2016, 8, 16, 0, 0)) ) ) ); } if (physicalTableDictionary.containsKey(MONTHLY.asName())) { hourlyMonthlyVolatileIntervals.put( getConfigurationLoader().getPhysicalTableDictionary().get(MONTHLY.asName()), () -> new SimplifiedIntervalList( Collections.singleton( new Interval(new DateTime(2016, 8, 1, 0, 0), new DateTime(2016, 9, 1, 0, 0)) ) ) ); } return new DefaultingVolatileIntervalsService( NoVolatileIntervalsFunction.INSTANCE, hourlyMonthlyVolatileIntervals ); }
@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); }