override def sumOption()

in algebird-core/src/main/scala/com/twitter/algebird/DecayingCMS.scala [597:619]


        override def sumOption(xs: TraversableOnce[CMS]): Option[CMS] = {

          val it: Iterator[CMS] = xs.iterator
          val ChunkSize = 1000

          // the idea here is that we read up to 1000 CMS values into
          // a fixed array, crunch them down to a single CMS, store it
          // in the first array index, read up to 999 more CMS values
          // in, crunch them down, and so on.
          var i = 0
          val arr = new Array[CMS](ChunkSize)
          while (it.hasNext) {
            while (it.hasNext && i < ChunkSize) {
              arr(i) = it.next()
              i += 1
            }
            if (i > 1) {
              arr(0) = innerSum(arr, i)
            }
            i = 1
          }
          if (i == 0) None else Some(arr(0))
        }