use of com.fasterxml.jackson.databind.MappingIterator in project druid by druid-io.
the class SpillingGrouper method iterator.
@Override
public Iterator<Entry<KeyType>> iterator(final boolean sorted) {
final List<Iterator<Entry<KeyType>>> iterators = new ArrayList<>(1 + files.size());
iterators.add(grouper.iterator(sorted));
for (final File file : files) {
final MappingIterator<Entry<KeyType>> fileIterator = read(file, keySerde.keyClazz());
iterators.add(Iterators.transform(fileIterator, new Function<Entry<KeyType>, Entry<KeyType>>() {
@Override
public Entry<KeyType> apply(Entry<KeyType> entry) {
final Object[] deserializedValues = new Object[entry.getValues().length];
for (int i = 0; i < deserializedValues.length; i++) {
deserializedValues[i] = aggregatorFactories[i].deserialize(entry.getValues()[i]);
if (deserializedValues[i] instanceof Integer) {
// Hack to satisfy the groupBy unit tests; perhaps we could do better by adjusting Jackson config.
deserializedValues[i] = ((Integer) deserializedValues[i]).longValue();
}
}
return new Entry<>(entry.getKey(), deserializedValues);
}
}));
closeables.add(fileIterator);
}
return Groupers.mergeIterators(iterators, sorted ? keyObjComparator : null);
}
Aggregations