public class SqlResultSetProcessor extends Object
|Constructor and Description|
Builds something to process a set of sql results and return them as the same format as a GroupBy query to Druid.
|Modifier and Type||Method and Description|
Processes the results from the sql
Creates a map from each aggregation name, i.e.
Reads the result set and converts it into a result that druid would produce.
Processes a single row of results from the result set.
public SqlResultSetProcessor(DruidAggregationQuery<?> druidQuery, ApiToFieldMapper apiToFieldMapper, com.fasterxml.jackson.databind.ObjectMapper objectMapper, SqlTimeConverter sqlTimeConverter)
druidQuery- The original query that was converted to a sql query.
apiToFieldMapper- The mapping from api to physical name.
objectMapper- The mapper for all JSON processing.
sqlTimeConverter- The time converter used with making the query.
public com.fasterxml.jackson.databind.JsonNode buildDruidResponse()
ResultSetand writes them out as the json format returned for a
protected void processRow(Map<String,Function<String,Number>> resultTypeMapper, com.fasterxml.jackson.core.JsonGenerator jsonWriter, String row) throws IOException
resultTypeMapper- The mapping from an aggregation to a function which corrects it's type.
jsonWriter- The generator for writing the json results.
row- The result row.
IOException- if failed while writing json.
public void process(ResultSet sqlResultSet) throws SQLException
sqlResultSet- The result set of the druid query.
SQLException- if results can't be read.
protected static void writeNumberField(com.fasterxml.jackson.core.JsonGenerator jsonWriter, String name, Number number) throws IOException
jsonWriter- The writer used to build json.
name- The name of the field to write with json.
number- The Number value of the field to write with json.
IOException- if results can't be written.
protected static Map<String,Function<String,Number>> getAggregationTypeMapper(DruidAggregationQuery<?> druidQuery)
druidQuery- The query to make a mapper for.
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.