Source:
public Page getNextPage() { if (finished) { return null; } long start = System.nanoTime(); try { List<DruidColumnHandle> handles = columnHandles.stream() .map(column -> (DruidColumnHandle) column) .collect(Collectors.toList()); List<Type> columnTypes = handles.stream() .map(DruidColumnHandle::getColumnType) .collect(Collectors.toList()); PageBuilder pageBuilder = new PageBuilder(columnTypes); String data = druidClient.getData(brokerDql.getDql()); JsonNode rootNode; try { rootNode = objectMapper.readTree(data); checkArgument(rootNode.isArray(), "broker Druid query should return Json Array"); ArrayNode arrayNode = (ArrayNode) rootNode; Iterator<JsonNode> iterator = arrayNode.elements(); while (iterator.hasNext()) { JsonNode node = iterator.next(); for (int i = 0; i < columnHandles.size(); i++) { Type type = columnTypes.get(i); BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i); JsonNode value = node.get(handles.get(i).getColumnName()); if (type instanceof BigintType) { type.writeLong(blockBuilder, value.longValue()); } if (type instanceof DoubleType) { type.writeDouble(blockBuilder, value.doubleValue()); } if (type instanceof RealType) { type.writeDouble(blockBuilder, value.doubleValue()); } else if (type instanceof TimestampType) { DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser() .withChronology(ISOChronology.getInstanceUTC()) .withOffsetParsed(); DateTime dateTime = formatter.parseDateTime(value.textValue()); type.writeLong(blockBuilder, dateTime.getMillis()); } else { Slice slice = Slices.utf8Slice(value.textValue()); blockBuilder.writeBytes(slice, 0, slice.length()).closeEntry(); completedBytes += slice.length(); } } } } catch (IOException e) { throw new PrestoException(DRUID_BROKER_RESULT_ERROR, e); } pageBuilder.declarePositions(rootNode.size()); Page page = pageBuilder.build(); completedPositions += page.getPositionCount(); finished = true; return page; } finally { readTimeNanos += System.nanoTime() - start; } }

Target:
public Page getNextPage() { if (finished) { return null; } long start = System.nanoTime(); try { List<DruidColumnHandle> handles = columnHandles.stream() .map(column -> (DruidColumnHandle) column) .collect(toImmutableList()); List<Type> columnTypes = handles.stream() .map(DruidColumnHandle::getColumnType) .collect(toImmutableList()); PageBuilder pageBuilder = new PageBuilder(columnTypes); String data = druidClient.getData(brokerDql.getDql()); JsonNode rootNode; try { rootNode = OBJECT_MAPPER.readTree(data); checkArgument(rootNode.isArray(), "broker Druid query should return Json Array"); ArrayNode arrayNode = (ArrayNode) rootNode; Iterator<JsonNode> iterator = arrayNode.elements(); while (iterator.hasNext()) { JsonNode node = iterator.next(); for (int i = 0; i < columnHandles.size(); i++) { Type type = columnTypes.get(i); BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i); JsonNode value = node.get(handles.get(i).getColumnName()); if (type instanceof BigintType) { type.writeLong(blockBuilder, value.longValue()); } else if (type instanceof DoubleType) { type.writeDouble(blockBuilder, value.doubleValue()); } else if (type instanceof RealType) { type.writeDouble(blockBuilder, value.doubleValue()); } else if (type instanceof TimestampType) { DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser() .withChronology(ISOChronology.getInstanceUTC()) .withOffsetParsed(); DateTime dateTime = formatter.parseDateTime(value.textValue()); type.writeLong(blockBuilder, dateTime.getMillis()); } else { Slice slice = Slices.utf8Slice(value.textValue()); blockBuilder.writeBytes(slice, 0, slice.length()).closeEntry(); completedBytes += slice.length(); } } } } catch (IOException e) { throw new PrestoException(DRUID_BROKER_RESULT_ERROR, e); } pageBuilder.declarePositions(rootNode.size()); Page page = pageBuilder.build(); completedPositions += page.getPositionCount(); finished = true; return page; } finally { readTimeNanos += System.nanoTime() - start; } }