use of com.tuplejump.stargate.cassandra.RowFetcher in project stargate-core by tuplejump.
the class AggregateFunction method process.
@Override
public List<Row> process(ResultMapper resultMapper, ColumnFamilyStore table, RowIndex currentIndex) throws Exception {
Options options = resultMapper.searchSupport.getOptions();
if (aggregates.length == 1 && !aggregates[0].distinct && "count".equalsIgnoreCase(aggregates[0].getType()) && groupBy == null) {
//this means it is a count-star. we can simply return the size of the index results
Count count = new Count(aggregates[0], false);
count.count = resultMapper.collector.docs().size();
group.groups.put(new Tuple(options.nestedFields, Collections.EMPTY_MAP, simpleExpressions), count);
Row row = resultMapper.tableMapper.getRowWithMetaColumn(group.toByteBuffer());
return Collections.singletonList(row);
}
Tuple tuple = createTuple(options);
if (resultMapper.collector.canByPassRowFetch()) {
for (IndexEntryCollector.IndexEntry indexEntry : resultMapper.collector.docs()) {
load(tuple, indexEntry);
group.addTuple(tuple);
}
} else {
RowFetcher rowFetcher = new RowFetcher(resultMapper);
for (Row row : rowFetcher.fetchRows()) {
resultMapper.tableMapper.load(positions, tuple, row);
group.addTuple(tuple);
}
}
Utils.SimpleTimer timer3 = Utils.getStartedTimer(SearchSupport.logger);
ByteBuffer groupBuffer = group.toByteBuffer();
timer3.endLogTime("Aggregation serialization [" + group.groups.size() + "] results");
Row row = resultMapper.tableMapper.getRowWithMetaColumn(groupBuffer);
return Collections.singletonList(row);
}
Aggregations