- Machine Learning with Spark(Second Edition)
- Rajdeep Dua Manpreet Singh Ghotra Nick Pentreath
- 76字
- 2021-07-09 21:07:40
SparkSession
SparkSession allows programming with the DataFrame and Dataset APIs. It is a single point of entry for these APIs.
First, we need to create an instance of the SparkConf class and use it to create the SparkSession instance. Consider the following example:
val spConfig = (new SparkConf).setMaster("local").setAppName("SparkApp")
val spark = SparkSession
.builder()
.appName("SparkUserData").config(spConfig)
.getOrCreate()
Next we can use spark object to create a DataFrame:
val user_df = spark.read.format("com.databricks.spark.csv")
.option("delimiter", "|").schema(customSchema)
.load("/home/ubuntu/work/ml-resources/spark-ml/data/ml-100k/u.user")
val first = user_df.first()
推薦閱讀
- Visualforce Development Cookbook(Second Edition)
- R Data Mining
- 傳感器技術實驗教程
- 走入IBM小型機世界
- 網上生活必備
- 工業機器人入門實用教程(KUKA機器人)
- WordPress Theme Development Beginner's Guide(Third Edition)
- RedHat Linux用戶基礎
- 在實戰中成長:C++開發之路
- Introduction to R for Business Intelligence
- 簡明學中文版Flash動畫制作
- ADuC系列ARM器件應用技術
- PyTorch深度學習
- 暗戰強人:黑客攻防入門全程圖解
- Office 2010輕松入門