You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by "Devi P.V" <de...@gmail.com> on 2016/09/07 06:42:11 UTC

How to write data into CouchBase using Spark & Scala?

I am newbie in CouchBase.I am trying to write data into CouchBase.My sample
code is following,

val cfg = new SparkConf()
  .setAppName("couchbaseQuickstart")
  .setMaster("local[*]")
  .set("com.couchbase.bucket.MyBucket","pwd")

val sc = new SparkContext(cfg)
val doc1 = JsonDocument.create("doc1", JsonObject.create().put("some",
"content"))
val doc2 = JsonArrayDocument.create("doc2", JsonArray.from("more",
"content", "in", "here"))

val data = sc
  .parallelize(Seq(doc1, doc2))

But I can't access data.saveToCouchbase().

I am using Spark 1.6.1 & Scala 2.11.8

I gave following dependencies in built.sbt

libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.1"
libraryDependencies += "com.couchbase.client" % "spark-connector_2.11" % "1.2.1"


How can I write data into CouchBase using Spark & Scala?

Re: How to write data into CouchBase using Spark & Scala?

Posted by "Devi P.V" <de...@gmail.com>.
Thanks.Now it is working.

On Thu, Sep 8, 2016 at 12:57 AM, aka.fe2s <ak...@gmail.com> wrote:

> Most likely you are missing an import statement that enables some Scala
> implicits. I haven't used this connector, but looks like you need "import
> com.couchbase.spark._"
>
> --
> Oleksiy Dyagilev
>
> On Wed, Sep 7, 2016 at 9:42 AM, Devi P.V <de...@gmail.com> wrote:
>
>> I am newbie in CouchBase.I am trying to write data into CouchBase.My
>> sample code is following,
>>
>> val cfg = new SparkConf()
>>   .setAppName("couchbaseQuickstart")
>>   .setMaster("local[*]")
>>   .set("com.couchbase.bucket.MyBucket","pwd")
>>
>> val sc = new SparkContext(cfg)
>> val doc1 = JsonDocument.create("doc1", JsonObject.create().put("some", "content"))
>> val doc2 = JsonArrayDocument.create("doc2", JsonArray.from("more", "content", "in", "here"))
>>
>> val data = sc
>>   .parallelize(Seq(doc1, doc2))
>>
>> But I can't access data.saveToCouchbase().
>>
>> I am using Spark 1.6.1 & Scala 2.11.8
>>
>> I gave following dependencies in built.sbt
>>
>> libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.1"
>> libraryDependencies += "com.couchbase.client" % "spark-connector_2.11" % "1.2.1"
>>
>>
>> How can I write data into CouchBase using Spark & Scala?
>>
>>
>>
>>
>>
>

Re: How to write data into CouchBase using Spark & Scala?

Posted by "aka.fe2s" <ak...@gmail.com>.
Most likely you are missing an import statement that enables some Scala
implicits. I haven't used this connector, but looks like you need "import
com.couchbase.spark._"

--
Oleksiy Dyagilev

On Wed, Sep 7, 2016 at 9:42 AM, Devi P.V <de...@gmail.com> wrote:

> I am newbie in CouchBase.I am trying to write data into CouchBase.My
> sample code is following,
>
> val cfg = new SparkConf()
>   .setAppName("couchbaseQuickstart")
>   .setMaster("local[*]")
>   .set("com.couchbase.bucket.MyBucket","pwd")
>
> val sc = new SparkContext(cfg)
> val doc1 = JsonDocument.create("doc1", JsonObject.create().put("some", "content"))
> val doc2 = JsonArrayDocument.create("doc2", JsonArray.from("more", "content", "in", "here"))
>
> val data = sc
>   .parallelize(Seq(doc1, doc2))
>
> But I can't access data.saveToCouchbase().
>
> I am using Spark 1.6.1 & Scala 2.11.8
>
> I gave following dependencies in built.sbt
>
> libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "1.6.1"
> libraryDependencies += "com.couchbase.client" % "spark-connector_2.11" % "1.2.1"
>
>
> How can I write data into CouchBase using Spark & Scala?
>
>
>
>
>