Сообщения

Сообщения за август, 2019

Comparison sequential execution and parallel with Futures in Scala

In this short article, I will show a comparison of sequential and parallel executions with scala Futures. First of all, I have a sequence of tickers (Ticker) with a structure like this: case class Ticker(tickerId :Int, tickerCode :String, tickerFirst :String, tickerSeconds :String) I read it from Cassandra DB and it has size 28. val sess = Global.sessInstance val tickersFrx: Seq[Ticker] = sess.tickersDict println("tickersFrx.size = "+tickersFrx.size) Next, I need for each Ticker in this sequence execute 2 additional DB query. First to determine the maximum data date. And with knowledge of this date, I need to get maximum UNIX timestamp of last data tick. Producing Seq[TickerWithDdateTs] p.s. I use limit 1 because we have clustering keys ordered descending. select ddate from mts_src.ticks_count_days where ticker_id = :tickerId limit 1 select db_tsunx from mts_src.ticks where ticker_id = :tickerId and ddate= :pDdate limit 1 case class TickerWithDd