denis-chudov commented on code in PR #5092: URL: https://github.com/apache/ignite-3/pull/5092#discussion_r1961535228
########## modules/core/src/main/java/org/apache/ignite/internal/util/io/IgniteDataInput.java: ########## @@ -418,4 +421,61 @@ interface Materializer<T> { */ T materialize(byte[] buffer, int offset, int length); } + + /** + * Reads a collection. + * + * @param collectionSupplier Supplier to create a collection. + * @param elementReader Function to read an element. + * @return Collection. + */ + default <T, C extends Collection<T>> C readCollection( + Supplier<C> collectionSupplier, + ObjectReader<T> elementReader + ) throws IOException { + int size = readVarIntAsInt(); + + C collection = collectionSupplier.get(); + + for (int i = 0; i < size; i++) { + collection.add(elementReader.read(this)); + } + + return collection; + } + + /** + * Reads a map. + * + * @param mapSupplier Supplier to create a map. + * @param keyReader Function to read a key. + * @param valueReader Function to read a value. + * @return Map. + */ + default <K, C, V extends C, M extends Map<K, V>> M readMap( + Supplier<M> mapSupplier, Review Comment: replaced with map -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org