static <T> Consumer<T> unchecked(IOConsumer<T> f) { return t -> { try { f.accept(t); } catch (IOException e) { throw new RuntimeIOException(e); } }; } }
/** * Prefer this method over {@link #get(Iterable)} to avoid gathering large results in a list. * @see DatastoreReaderWriter#get(Key...) * @throws IOException if the underlying client throws {@link DatastoreException} * or if {@code f} throws {@link IOException}. */ void get(Iterable<Key> keys, IOConsumer<Entity> f) throws IOException { run(() -> rw.get(toArray(keys, Key.class)).forEachRemaining(IOConsumer.unchecked(f))); }
/** * Prefer this method over {@link #query(Query)} to avoid gathering large results in a list. * @see DatastoreReaderWriter#run(Query) * @throws IOException if the underlying client throws {@link DatastoreException} * or if {@code f} throws {@link IOException}. */ <T> void query(Query<T> query, IOConsumer<T> f) throws IOException { run(() -> rw.run(query).forEachRemaining(IOConsumer.unchecked(f))); }