Hi All,

Could someone shed a light to why when adding element into MutableList can 
result in type mistmatch, even if I'm sure that the class type is right?

Below is the sample code I run in spark 1.0.2 console, at the end of line, 
there is an error type mismatch:



Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 1.0.2
      /_/

Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45)
Type in expressions to have them evaluated.
Type :help for more information.
14/10/15 14:36:39 INFO spark.SecurityManager: Changing view acls to: hadoop
14/10/15 14:36:39 INFO spark.SecurityManager: SecurityManager: authentication 
disabled; ui acls disabled; users with view permissions: Set(hadoop)
14/10/15 14:36:39 INFO slf4j.Slf4jLogger: Slf4jLogger started
14/10/15 14:36:39 INFO Remoting: Starting remoting
14/10/15 14:36:39 INFO Remoting: Remoting started; listening on addresses 
:[akka.tcp://sp...@fphd4.ctpilot1.com:35293]
14/10/15 14:36:39 INFO Remoting: Remoting now listens on addresses: 
[akka.tcp://sp...@fphd4.ctpilot1.com:35293]
14/10/15 14:36:39 INFO spark.SparkEnv: Registering MapOutputTracker
14/10/15 14:36:39 INFO spark.SparkEnv: Registering BlockManagerMaster
14/10/15 14:36:39 INFO storage.DiskBlockManager: Created local directory at 
/tmp/spark-local-20141015143639-c62e
14/10/15 14:36:39 INFO storage.MemoryStore: MemoryStore started with capacity 
294.4 MB.
14/10/15 14:36:39 INFO network.ConnectionManager: Bound socket to port 43236 
with id = ConnectionManagerId(fphd4.ctpilot1.com,43236)
14/10/15 14:36:39 INFO storage.BlockManagerMaster: Trying to register 
BlockManager
14/10/15 14:36:39 INFO storage.BlockManagerInfo: Registering block manager 
fphd4.ctpilot1.com:43236 with 294.4 MB RAM
14/10/15 14:36:39 INFO storage.BlockManagerMaster: Registered BlockManager
14/10/15 14:36:39 INFO spark.HttpServer: Starting HTTP Server
14/10/15 14:36:39 INFO server.Server: jetty-8.y.z-SNAPSHOT
14/10/15 14:36:40 INFO server.AbstractConnector: Started 
SocketConnector@0.0.0.0:37164
14/10/15 14:36:40 INFO broadcast.HttpBroadcast: Broadcast server started at 
http://10.18.30.154:37164
14/10/15 14:36:40 INFO spark.HttpFileServer: HTTP File server directory is 
/tmp/spark-34fc70ab-7c5d-4e79-9ae7-929fd47d4f36
14/10/15 14:36:40 INFO spark.HttpServer: Starting HTTP Server
14/10/15 14:36:40 INFO server.Server: jetty-8.y.z-SNAPSHOT
14/10/15 14:36:40 INFO server.AbstractConnector: Started 
SocketConnector@0.0.0.0:47025
14/10/15 14:36:40 INFO server.Server: jetty-8.y.z-SNAPSHOT
14/10/15 14:36:40 INFO server.AbstractConnector: Started 
SelectChannelConnector@0.0.0.0:4040
14/10/15 14:36:40 INFO ui.SparkUI: Started SparkUI at 
http://fphd4.ctpilot1.com:4040
14/10/15 14:36:40 WARN util.NativeCodeLoader: Unable to load native-hadoop 
library for your platform... using builtin-java classes where applicable
14/10/15 14:36:40 INFO executor.Executor: Using REPL class URI: 
http://10.18.30.154:49669
14/10/15 14:36:40 INFO repl.SparkILoop: Created spark context..
Spark context available as sc.

scala> case class Dummy(x: String) {
     |     val data:String = x
     | }
defined class Dummy

scala> import scala.collection.mutable.MutableList
import scala.collection.mutable.MutableList

scala> val v = MutableList[Dummy]()
v: scala.collection.mutable.MutableList[Dummy] = MutableList()

scala> v += (new Dummy("a"))
<console>:16: error: type mismatch;
found   : Dummy
required: Dummy
              v += (new Dummy("a"))

________________________________
The privileged confidential information contained in this email is intended for 
use only by the addressees as indicated by the original sender of this email. 
If you are not the addressee indicated in this email or are not responsible for 
delivery of the email to such a person, please kindly reply to the sender 
indicating this fact and delete all copies of it from your computer and network 
server immediately. Your cooperation is highly appreciated. It is advised that 
any unauthorized use of confidential information of Winbond is strictly 
prohibited; and any information in this email irrelevant to the official 
business of Winbond shall be deemed as neither given nor endorsed by Winbond.

Reply via email to