Source:
private void doPoll() { log.debug("Starting polling of segment table"); final List<DataSegment> segments = connector.inReadOnlyTransaction( new TransactionCallback<List<DataSegment>>() { @Override public List<DataSegment> inTransaction(Handle handle, TransactionStatus status) { return handle .createQuery(StringUtils.format("SELECT payload FROM %s WHERE used=true", getSegmentsTable())) .setFetchSize(connector.getStreamingFetchSize()) .map( new ResultSetMapper<DataSegment>() { @Override public DataSegment map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { DataSegment segment = jsonMapper.readValue(r.getBytes("payload"), DataSegment.class); return replaceWithExistingSegmentIfPresent(segment); } catch (IOException e) { log.makeAlert(e, "Failed to read segment from db.").emit(); return null; } } } ) .list(); } } ); if (segments == null || segments.isEmpty()) { log.warn("No segments found in the database!"); return; } log.info("Polled and found %,d segments in the database", segments.size()); ConcurrentHashMap<String, DruidDataSource> newDataSources = new ConcurrentHashMap<>(); ImmutableMap<String, String> dataSourceProperties = ImmutableMap.of("created", DateTimes.nowUtc().toString()); segments .stream() .filter(Objects::nonNull) .forEach(segment -> { newDataSources .computeIfAbsent(segment.getDataSource(), dsName -> new DruidDataSource(dsName, dataSourceProperties)) .addSegmentIfAbsent(segment); }); dataSourcesSnapshot = new DataSourcesSnapshot(newDataSources.entrySet() .stream() .collect(Collectors.toMap( e -> e.getKey(), e -> e.getValue().toImmutableDruidDataSource() ))); }

Target:
private void doPoll() { log.debug("Starting polling of segment table"); final List<DataSegment> segments = connector.inReadOnlyTransaction( new TransactionCallback<List<DataSegment>>() { @Override public List<DataSegment> inTransaction(Handle handle, TransactionStatus status) { return handle .createQuery(StringUtils.format("SELECT payload FROM %s WHERE used=true", getSegmentsTable())) .setFetchSize(connector.getStreamingFetchSize()) .map( new ResultSetMapper<DataSegment>() { @Override public DataSegment map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { DataSegment segment = jsonMapper.readValue(r.getBytes("payload"), DataSegment.class); return replaceWithExistingSegmentIfPresent(segment); } catch (IOException e) { log.makeAlert(e, "Failed to read segment from db.").emit(); return null; } } } ) .list(); } } ); if (segments == null || segments.isEmpty()) { log.warn("No segments found in the database!"); return; } log.info("Polled and found %,d segments in the database", segments.size()); ConcurrentHashMap<String, DruidDataSource> newDataSources = new ConcurrentHashMap<>(); ImmutableMap<String, String> dataSourceProperties = ImmutableMap.of("created", DateTimes.nowUtc().toString()); segments .stream() .filter(Objects::nonNull) .forEach(segment -> { newDataSources .computeIfAbsent(segment.getDataSource(), dsName -> new DruidDataSource(dsName, dataSourceProperties)) .addSegmentIfAbsent(segment); }); final Map<String, ImmutableDruidDataSource> updatedDataSources = CollectionUtils.mapValues( newDataSources, v -> v.toImmutableDruidDataSource() ); dataSourcesSnapshot = new DataSourcesSnapshot(updatedDataSources); }