Image Downloading with Parallel Streams and RxJava

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I am and I have been a great fan of your video's they are very precise and informative, What I had always appreciated about your video's that you had a plethora of knowledge within detail understanding. Wish you a great health, Keep sharing for the community.

kumarabhishek
Автор

Douglas, small suggestion :- I think you should start using twitter and post your session updates. 
On the other note your session's are really good ...

jagapathiraju
Автор

Dr. Schmidt, inside RunTimer.getTimingResults() method, why did you choose to use StringBuffer instead of StringBuilder? Is it because you needed to use the synchronized feature of StringBuffer?

unnsse
Автор

Why exactly did the RXJava code have to use a forkjoin common pool and not a Schedulers.io() which is a pool optimized for I/O if I remember from when I used it with RXJava 1.x?

NishitVishwanath
Автор

I checked the latest version in ex2 folder and saw that RxJava was removed and were added.
Can you please explain why plain RxJava approach is so slow, even though it uses adaptive mechanism for creating threads when other are blocked? (It is even slower than naive testDefaultDownloadBehavior that does not create threads when other are blocked). What are the benefits of flatMapping observable in observable and subscribing to it internally?

Please, see the timings below.

My output:
Entering the download tests program with 6 cores available
ex2: testDefaultDownloadBehavior() downloaded and stored 42 images using 6 threads in the pool
ex2: downloaded and stored 42 images using 27 threads in the pool
ex2: downloaded and stored 42 images using 27 threads in the pool
ex2: downloaded and stored 42 images using 27 threads in the pool
ex2: downloaded and stored 42 images using 44 threads in the pool
ex2: downloaded and stored 42 images using 44 threads in the pool

Printing 6 results from fastest to slowest
executed in 8120 msecs
executed in 9618 msecs
executed in 12750 msecs
executed in 23404 msecs
testDefaultDownloadBehavior() executed in 31139 msecs
executed in 131744 msecs

Code for testDownloadBehaviorRxJava

private void testDownloadBehaviorRxJava(Function<URL, File> downloadAndStoreImage,
String testName) {
// Get and print a list of files to the downloaded images.
Observable



.collectInto(new ArrayList<>(), List::add)
.blockingSubscribe(imageFiles
-> printStats(testName, imageFiles.size()));
}

vs

private void testDownloadBehaviorRxflatMap(Function<URL, File> downloadAndStoreImage,
String testName) {
Observable

.flatMap(url -> Observable
.just(url)


.collectInto(new ArrayList<>(), List::add)
.blockingSubscribe(imageFiles ->
printStats(testName, imageFiles.size()));
}

ievgengavrysh
Автор

thanks, is this lesson for who want learn java and if you have playlist to start learn jave i appreciate it
thanks once again

abusafiaayman
Автор

Whats the "m" and "s" prefix on the field names? So ugly :(

timwalters
visit shbcf.ru