Use the bitset here: org.apache.spark.util.collection.BitSet

It is way faster than Scala's.