Scala is a statically-typed language where the arguments you provide to a method must have specific types in order for the method call to compile. Sometimes methods are overloaded, in which case different combinations of arguments can be provided, and in Scala sometimes some arguments may have default values, in which case they don't need to be provided at all.
There are several ways to determine what arguments are possible for a given method. Your IDE might show a tool-tip when you type MQTTUtils.createPairedStream(
. Sometimes library developers publish API documentation that shows method signatures (which include the argument types and return value) in an easy-to-read format. If neither of these are options for you and the project is open source, you can just look up the source code. In this case you'll find something the following (note that you may need to change the tag in the GitHub interface if you're using a different version):
/**
* Create an input stream that receives messages pushed by a MQTT publisher.
* @param ssc StreamingContext object
* @param brokerUrl Url of remote MQTT publisher
* @param topics Array of topic names to subscribe to
* @param storageLevel RDD storage level. Defaults to StorageLevel.MEMORY_AND_DISK_SER_2.
*/
def createPairedStream(
ssc: StreamingContext,
brokerUrl: String,
topics: Array[String],
storageLevel: StorageLevel = StorageLevel.MEMORY_AND_DISK_SER_2
): ReceiverInputDStream[(String, String)] = {
new MQTTPairedInputDStream(ssc, brokerUrl, topics, storageLevel)
}
This is the simplest of eight createPairedStream
method overloads (all the rest take additional arguments). This shows that you'll need to provide (in order) a StreamingContext
, a broker URL, and an array of topics.