title: is rdd.contains function in spark-scala expensive
body: <p>I am getting millions of message from Kafka stream in spark-streaming. There are 15 different types of message. Messages come from a single topic. I can only differentiate message by its content. so I am using rdd.contains method to get the different type of rdd.</p>
  
  <p>sample message</p>
  
  <p>{"a":"foo", "b":"bar","type":"first" .......}<br>
  {"a":"foo1", "b":"bar1","type":"second" .......}<br>
  {"a":"foo2", "b":"bar2","type":"third" .......}<br>
  {"a":"foo", "b":"bar","type":"first" .......}<br>
  ..............<br>
  ...............<br>
  .........<br>
  so on <br></p>
  
  <p>code</p>
  
  <pre><code>DStream.foreachRDD { rdd =&gt;
    if (!rdd.isEmpty()) {
      val rdd_first = rdd.filter {
        ele =&gt; ele.contains("First")
      }
      if (!rdd_first.isEmpty()) {
        insertIntoTableFirst(hivecontext.read.json(rdd_first)) 
      }
      val rdd_second = rdd.filter {
        ele =&gt; ele.contains("Second")
      }
      if (!rdd_second.isEmpty()) {
       insertIntoTableSecond(hivecontext.read.json(rdd_second))
      }
           .............
           ......
      same way for 15 different rdd
  </code></pre>
  
  <p>is there any way to get different rdd from kafka topic message?</p>