/** * Generates ResultSet object from the JsonNode which contains the serialized ResultSet. * * @param serializedResultSet JsonNode which contains the serialized ResultSet * * @return ResultSet object generated from JsonNode */ private ResultSet getResultSet(JsonNode serializedResultSet) { ResultSetSchema resultSetSchema = getResultSetSchema(serializedResultSet.get(SCHEMA_KEY)); List<Result> results = Streams.stream(serializedResultSet.get(RESULTS_KEY)) .map(serializedResult -> getResult(serializedResult, resultSetSchema)) .collect(Collectors.toList()); return new ResultSet(resultSetSchema, results); }
@Override public ResultSet map(ResultSet resultSet) { // TODO: Use only native stream operations in RxJava: GroupByTime -> Sort -> Take N -> Concat streams by time TopNAccumulator acc = new TopNAccumulator(); resultSet.stream().forEachOrdered(acc); return new ResultSet(resultSet.getSchema(), acc.data); }
@Override public ResultSet map(ResultSet resultSet) { ResultSetSchema schema = map(resultSet.getSchema()); MetricColumn column = schema.getColumn(ROW_NUM_COLUMN_NAME, MetricColumn.class).get(); int resultSetSize = resultSet.size(); List<Result> newResults = new ArrayList<>(resultSetSize); for (int i = 0; i < resultSetSize; i++) { newResults.add(rowNumMap(resultSet.get(i), column, i)); } ResultSet newResultSet = new ResultSet(schema, newResults); LOG.trace("Mapped resultSet: {} to new resultSet {}", resultSet, newResultSet); return newResultSet; }
/** * Sorting the resultSet based on dateTime column sort direction. * * @param resultSet The result set need to be sorted in ascending or descending order * * @return sorted ResultSet */ @Override public ResultSet map(ResultSet resultSet) { Map<DateTime, List<Result>> bucketizedResultsMap = new LinkedHashMap<>(); RequestLog.startTiming("sortResultSet"); try { for (Result result : resultSet) { bucketizedResultsMap.computeIfAbsent(result.getTimeStamp(), ignored -> new ArrayList<>()).add(result); } List<DateTime> dateTimeList = new ArrayList<>(bucketizedResultsMap.keySet()); Collections.sort(dateTimeList, direction == SortDirection.ASC ? Comparator.naturalOrder() : Comparator.reverseOrder()); return new ResultSet( resultSet.getSchema(), dateTimeList.stream() .map(bucketizedResultsMap::get) .flatMap(List::stream) .collect(Collectors.toList()) ); } finally { RequestLog.stopTiming("sortResultSet"); } }
/** * Take a complete result set and replace it with one altered according to the rules of the concrete mapper. * * @param resultSet The unmapped result set * * @return The mapped result set */ public ResultSet map(ResultSet resultSet) { List<Result> newResults = new ArrayList<>(); Result newResult; for (Result r: resultSet) { newResult = map(r, resultSet.getSchema()); if (newResult != null) { newResults.add(newResult); } } ResultSetSchema newSchema = map(resultSet.getSchema()); ResultSet newResultSet = new ResultSet(newSchema, newResults); LOG.trace("Mapped resultSet: {} to new resultSet {}", resultSet, newResultSet); return newResultSet; }
/** * Cuts the result set down to just the page requested. * * @param resultSet The result set to be cut down. * * @return The page of results desired. */ @Override public ResultSet map(ResultSet resultSet) { Pagination<Result> pages = new AllPagesPagination<>(resultSet, paginationParameters); AbstractResponse.addLinks(pages, uriBuilder, responseProcessor); //uses map for additional flexibility and robustness, even though it is currently a no-op. return new ResultSet(map(resultSet.getSchema()), pages.getPageOfData()); }
new ResultSet( new ResultSetSchema(AllGranularity.INSTANCE, Collections.emptySet()), Collections.emptyList() ),
.map(pageParams -> new AllPagesPagination<>(preResponse.getResultSet(), pageParams)) .map(page -> new PreResponse( new ResultSet(preResponse.getResultSet().getSchema(), page.getPageOfData()), addPaginationInfoToResponseContext(responseContext, uriInfo, page) ))
return new ResultSet(schema, results);
List<Result> results = new ArrayList<>(); results.add(result); ResultSet resultSet = new ResultSet(schema, results); results1.add(result2); results1.add(result3); ResultSet resultSet1 = new ResultSet(schema, results1); PreResponse preResponse1 = new PreResponse(resultSet1, responseContext); preResponseStore.save("ticket3p", preResponse1);
List<Result> results = new ArrayList<>(); results.add(result); ResultSet resultSet = new ResultSet(schema, results); results1.add(result2); results1.add(result3); ResultSet resultSet1 = new ResultSet(schema, results1); PreResponse preResponse1 = new PreResponse(resultSet1, responseContext); preResponseStore.save("ticket3p", preResponse1);