use of org.apache.parquet.format.event.TypedConsumer.ListConsumer in project parquet-format by apache.
the class TBaseStructConsumer method listOf.
/**
* To consume a list of elements
* @param c the type of the list content
* @param consumer the consumer that will receive the list
* @return a ListConsumer that can be passed to the DelegatingFieldConsumer
*/
public static <T extends TBase<T, ? extends TFieldIdEnum>> ListConsumer listOf(Class<T> c, final Consumer<List<T>> consumer) {
class ListConsumer implements Consumer<T> {
List<T> list;
@Override
public void consume(T t) {
list.add(t);
}
}
final ListConsumer co = new ListConsumer();
return new DelegatingListElementsConsumer(struct(c, co)) {
@Override
public void consumeList(TProtocol protocol, EventBasedThriftReader reader, TList tList) throws TException {
co.list = new ArrayList<T>();
super.consumeList(protocol, reader, tList);
consumer.consume(co.list);
}
};
}
Aggregations