use of org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand in project lucene-solr by apache.
the class SearchGroupsResultTransformer method transform.
/**
* {@inheritDoc}
*/
@Override
public NamedList transform(List<Command> data) throws IOException {
final NamedList<NamedList> result = new NamedList<>(data.size());
for (Command command : data) {
final NamedList<Object> commandResult = new NamedList<>(2);
if (SearchGroupsFieldCommand.class.isInstance(command)) {
SearchGroupsFieldCommand fieldCommand = (SearchGroupsFieldCommand) command;
final SearchGroupsFieldCommandResult fieldCommandResult = fieldCommand.result();
final Collection<SearchGroup<BytesRef>> searchGroups = fieldCommandResult.getSearchGroups();
if (searchGroups != null) {
commandResult.add(TOP_GROUPS, serializeSearchGroup(searchGroups, fieldCommand));
}
final Integer groupedCount = fieldCommandResult.getGroupCount();
if (groupedCount != null) {
commandResult.add(GROUP_COUNT, groupedCount);
}
} else {
continue;
}
result.add(command.getKey(), commandResult);
}
return result;
}
Aggregations