Spark-cassandra-connector Inserting data Functions Savetocassandra

Source: Internet
Author: User
Tags cassandra

Save data to Cassandra in Spark-shell:

vardata = Normalfill.map (line = Line.split ("\u0005")) Data.map ( line= = (Line (0), Line (1), Line (2)) . Savetocassandra ("Cui",  "Oper_ios", Somecolumns ("User_no","cust_id","Oper_code","Oper_time"))

Savetocassandra method when the field type is counter, the default behavior is count

CREATE TABLE CUI.INCR (
Name text,
Count counter,
PRIMARY KEY (name)
)

scala> var rdd = Sc.parallelize (Array (("Cui", 100))
rdd:org.apache.spark.rdd.rdd[(String, Int)] = parallelcollectionrdd[820] at parallelize at <console>:42

scala> Rdd.savetocassandra ("Cui", "incr", Somecolumns ("name", "Count"))
16/01/21 16:55:35 INFO Core. Cluster:new Cassandra host/172.25.1.158:9042 Added
......

Name Count

Cui 100

scala> var rdd = Sc.parallelize (Array (("Cui", 100))
rdd:org.apache.spark.rdd.rdd[(String, Int)] = parallelcollectionrdd[821] at parallelize at <console>:42

scala> Rdd.savetocassandra ("Cui", "incr", Somecolumns ("name", "Count"))

Name Count

Cui

Spark-cassandra-connector Inserting data Functions Savetocassandra

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.