public class SqlResultSetProcessor extends Object
| Constructor and Description |
|---|
SqlResultSetProcessor(DruidAggregationQuery<?> druidQuery,
ApiToFieldMapper apiToFieldMapper,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
SqlTimeConverter sqlTimeConverter)
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 |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
buildDruidResponse()
Processes the results from the sql
ResultSet and writes them out as
the json format returned for a GroupByQuery. |
protected static Map<String,Function<String,Number>> |
getAggregationTypeMapper(DruidAggregationQuery<?> druidQuery)
Creates a map from each aggregation name, i.e.
|
void |
process(ResultSet sqlResultSet)
Reads the result set and converts it into a result that druid
would produce.
|
protected void |
processRow(Map<String,Function<String,Number>> resultTypeMapper,
com.fasterxml.jackson.core.JsonGenerator jsonWriter,
String[] row)
Processes a single row of results from the result set.
|
protected static void |
writeNumberField(com.fasterxml.jackson.core.JsonGenerator jsonWriter,
String name,
Number number)
|
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()
ResultSet and writes them out as
the json format returned for a GroupByQuery.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.Double.parseDouble(java.lang.String) Long.parseLong(java.lang.String, int).Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.