use of org.infinispan.query.remote.client.impl.QueryResponse in project infinispan by infinispan.
the class DefaultQuerySerializer method createQueryResponse.
@Override
public QueryResponse createQueryResponse(RemoteQueryResult remoteQueryResult) {
List<?> list = remoteQueryResult.getResults();
int numResults = list.size();
String[] projection = remoteQueryResult.getProjections();
int projSize = projection != null ? projection.length : 0;
List<WrappedMessage> results = new ArrayList<>(projSize == 0 ? numResults : numResults * projSize);
for (Object o : list) {
if (projSize == 0) {
results.add(new WrappedMessage(o));
} else {
Object[] row = (Object[]) o;
for (int i = 0; i < projSize; i++) {
results.add(new WrappedMessage(row[i]));
}
}
}
QueryResponse response = new QueryResponse();
response.setTotalResults(remoteQueryResult.getTotalResults());
response.setNumResults(numResults);
response.setProjectionSize(projSize);
response.setResults(results);
return response;
}
Aggregations