当前位置: 首页 > news >正文

使用iis搭建网站网址怎么弄

使用iis搭建网站,网址怎么弄,wordpress网站打开满,江桥做网站上面的是SparkSQL的API操作。 1. 将RDD转化为DataFrame对象 DataFrame: DataFrame是一种以RDD为基础的分布式数据集,类似于传统数据库中的二维表格。带有schema元信息,即DataFrame所表示的二维表数据集的每一列都带有名称和类型。这样的数…

上面的是SparkSQL的API操作。

1. 将RDD转化为DataFrame对象

DataFrame:

DataFrame是一种以RDD为基础的分布式数据集,类似于传统数据库中的二维表格。带有schema元信息,即DataFrame所表示的二维表数据集的每一列都带有名称和类型。这样的数据集可以用SQL查询。

创建方式

准备数据

1 zhangsan 20 male
2 lisi 30 female
3 wangwu 35 male
4 zhaosi 40 female

toDF方式

package com.hainiu.sparkimport org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}object TestSparkSql{def main(args: Array[String]): Unit = {val conf = new SparkConf()conf.setAppName("test sql")conf.setMaster("local[*]")val sc = new SparkContext(conf)val sqlSc = new SQLContext(sc)//环境对象包装import sqlSc.implicits._//引入环境信息val rdd = sc.textFile("data/a.txt").map(t => {val strs = t.split(" ")(strs(0).toInt, strs(1), strs(2).toInt)})//增加字段信息val df = rdd.toDF("id", "name", "age")df.show() //展示表数据df.printSchema() //展示表格字段信息}
}

使用样例类定义schema:

object TestSparkSql{def main(args: Array[String]): Unit = {val conf = new SparkConf()conf.setAppName("test sql")conf.setMaster("local[*]")val sc = new SparkContext(conf)val sqlSc = new SQLContext(sc)import sqlSc.implicits._val rdd = sc.textFile("data/a.txt").map(t => {val strs = t.split(" ")Student(strs(0).toInt, strs(1), strs(2).toInt)})//    val df = rdd.toDF("id", "name", "age")val df = rdd.toDF()df.show() //打印数据,以表格的形式打印数据df.printSchema() //打印表的结构信息}
}
case class Student(id:Int,name:String,age:Int)

createDataFrame方式

这种方式需要将rdd和schema信息进行合并,得出一个新的DataFrame对象

package com.hainiu.sparkimport org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructType}
import org.apache.spark.sql.{Row, SQLContext}
import org.apache.spark.{SparkConf, SparkContext}object TestSparkSqlWithCreate {def main(args: Array[String]): Unit = {val conf = new SparkConf()conf.setAppName("test create")conf.setMaster("local[*]")val sc = new SparkContext(conf)val sqlSc = new SQLContext(sc)val rdd = sc.textFile("data/a.txt").map(t => {val strs = t.split(" ")Row(strs(0).toInt, strs(1), strs(2).toInt)})
//    rdd + schemaval schema = StructType(Array(StructField("id",IntegerType),StructField("name",StringType),StructField("age",IntegerType)))val df = sqlSc.createDataFrame(rdd, schema)df.show()df.printSchema()}
}

2. SparkSQL的查询方式(推荐第二种写法)

第二个部分关于df的查询

第一种sql api的方式查询

  • 使用的方式方法的形式编程
  • 但是思想还是sql形式
  • 和rdd编程特别相似的一种写法
object TestSql {def main(args: Array[String]): Unit = {val conf = new SparkConf()conf.setAppName("test sql")conf.setMaster("local[*]")val sc = new SparkContext(conf)val sqlSc = new SQLContext(sc)import sqlSc.implicits._val rdd = sc.textFile("data/a.txt").map(t => {val strs = t.split(" ")(strs(0).toInt, strs(1), strs(2).toInt,strs(3))})val df = rdd.toDF("id", "name", "age","gender")//select * from student where age >20//df.where("age >20")//分组聚合//df.groupby("gender").sum("age")//几个问题//聚合函数不能增加别名 聚合函数不能多次聚合  orderby不识别desc // df.groupBy("gender").agg(count("id").as("id"),sum("age").as("age")).orderBy($"age".desc) //字段标识可以是字符串,也可以是字段对象//df.orderBy($"age".desc)   //df.orderBy(col("age").desc) //df.orderBy(df("age").desc) //增加字段对象可以实现高端操作//df.select($"age".+(1)) //join问题//val df1 = sc.makeRDD(Array(//   (1,100,98),//  (2,100,95),// (3,90,92),//(4,90,93)//)).toDF("id","chinese","math")//df.join(df1,"id") //字段相同   //df.join(df1,df("id")===df1("id"))   //窗口函数//普通函数 聚合函数  窗口函数 sum|count|rowkey over (partition by gender order by age desc)//按照条件分割完毕进行数据截取//班级的前两名 每个性别年龄最高的前两个//select *,row_number() over (partition by gender order by age desc) rn from tableimport sqlSc.implicits._import org.apache.spark.sql.functions._df.withColumn("rn",row_number().over(Window.partitionBy("gender").orderBy($"age".desc))).where("rn = 1").show()}
}

第二种纯sql形式的查询

  • 首先注册表
  • 然后使用sql查询
  • 最终得出的还是dataFrame的对象
  • 其中和rdd的编程没有任何的区别,只不过现在使用sql形式进行处理了而已
package com.hainiu.sparkimport org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructType}
import org.apache.spark.sql.{Row, SQLContext}
import org.apache.spark.{SparkConf, SparkContext}object TestSparkSqlWithCreate {def main(args: Array[String]): Unit = {val conf = new SparkConf()conf.setAppName("test create")conf.setMaster("local[*]")val sc = new SparkContext(conf)val sqlSc = new SQLContext(sc)val rdd = sc.textFile("data/a.txt").map(t => {val strs = t.split(" ")Row(strs(0).toInt, strs(1), strs(2).toInt,strs(3))})
//    rdd + schemaval schema = StructType(Array(StructField("id",IntegerType),StructField("name",StringType),StructField("age",IntegerType),StructField("gender",StringType),))val df = sqlSc.createDataFrame(rdd, schema)//sql形式查询//select col from tabledf.createTempView("student")val df1 = sqlSc.sql("""|select count(1) cnt,gender from student group by gender|""".stripMargin)df1.createTempView("student1")val df2 = sqlSc.sql("""|select * from student1 where cnt>1|""".stripMargin)df2.show()df2.printSchema()}
}

文章转载自:
http://dinncostyrolene.bpmz.cn
http://dinncotoothpaste.bpmz.cn
http://dinncohankie.bpmz.cn
http://dinncosternforemost.bpmz.cn
http://dinncofriskful.bpmz.cn
http://dinncoquerimonious.bpmz.cn
http://dinnconowanights.bpmz.cn
http://dinncocuddle.bpmz.cn
http://dinncoswop.bpmz.cn
http://dinncogaping.bpmz.cn
http://dinncohomeostatic.bpmz.cn
http://dinncominnesota.bpmz.cn
http://dinncothwart.bpmz.cn
http://dinncosuperinfect.bpmz.cn
http://dinncovocalist.bpmz.cn
http://dinncoeternalize.bpmz.cn
http://dinncopublisher.bpmz.cn
http://dinncosigmoidoscope.bpmz.cn
http://dinncosnarl.bpmz.cn
http://dinncoaphetic.bpmz.cn
http://dinncokemalist.bpmz.cn
http://dinncolms.bpmz.cn
http://dinncotachinid.bpmz.cn
http://dinncochristiania.bpmz.cn
http://dinncoprotochordate.bpmz.cn
http://dinncolallygag.bpmz.cn
http://dinncodouce.bpmz.cn
http://dinncovouchsafement.bpmz.cn
http://dinncotrier.bpmz.cn
http://dinncodependance.bpmz.cn
http://dinncoanionic.bpmz.cn
http://dinncoimitational.bpmz.cn
http://dinncoisokeraunic.bpmz.cn
http://dinncotourer.bpmz.cn
http://dinncopharmacogenetics.bpmz.cn
http://dinncoelocute.bpmz.cn
http://dinncononrecurrent.bpmz.cn
http://dinncoprotoplasm.bpmz.cn
http://dinncocatridges.bpmz.cn
http://dinncotaedong.bpmz.cn
http://dinncoshark.bpmz.cn
http://dinncotransoceanic.bpmz.cn
http://dinncodouppioni.bpmz.cn
http://dinncohupeh.bpmz.cn
http://dinncoenglishness.bpmz.cn
http://dinncooverwhelm.bpmz.cn
http://dinncomayan.bpmz.cn
http://dinncoalipterion.bpmz.cn
http://dinncosahra.bpmz.cn
http://dinncowoolgathering.bpmz.cn
http://dinncoswim.bpmz.cn
http://dinncocoattail.bpmz.cn
http://dinncosullenly.bpmz.cn
http://dinncoprepubertal.bpmz.cn
http://dinncomonologize.bpmz.cn
http://dinncoarchives.bpmz.cn
http://dinncoendoenzyme.bpmz.cn
http://dinncooxytocic.bpmz.cn
http://dinncofibrinuria.bpmz.cn
http://dinncofinnmark.bpmz.cn
http://dinncooleic.bpmz.cn
http://dinncoastropologist.bpmz.cn
http://dinncoanabranch.bpmz.cn
http://dinncomenshevism.bpmz.cn
http://dinncodumdum.bpmz.cn
http://dinncoimprovability.bpmz.cn
http://dinncobygone.bpmz.cn
http://dinncodonable.bpmz.cn
http://dinncosupportability.bpmz.cn
http://dinncowarsle.bpmz.cn
http://dinncoexomphalos.bpmz.cn
http://dinncoswalk.bpmz.cn
http://dinncomismarriage.bpmz.cn
http://dinncogrademark.bpmz.cn
http://dinncowhirlybird.bpmz.cn
http://dinncoumbilicus.bpmz.cn
http://dinnconodi.bpmz.cn
http://dinncodarwinist.bpmz.cn
http://dinncoresidenter.bpmz.cn
http://dinncoacardia.bpmz.cn
http://dinncosugarplum.bpmz.cn
http://dinncoprolog.bpmz.cn
http://dinncofellmonger.bpmz.cn
http://dinncopolymerizing.bpmz.cn
http://dinncostreptothricosis.bpmz.cn
http://dinncocgi.bpmz.cn
http://dinncoovolo.bpmz.cn
http://dinncocholeraic.bpmz.cn
http://dinnconooning.bpmz.cn
http://dinncokatalase.bpmz.cn
http://dinncodigamous.bpmz.cn
http://dinncoaddressable.bpmz.cn
http://dinncomacrocyst.bpmz.cn
http://dinncooctroi.bpmz.cn
http://dinncosmarm.bpmz.cn
http://dinncodisaccordit.bpmz.cn
http://dinncosuture.bpmz.cn
http://dinncoabc.bpmz.cn
http://dinncorevitalization.bpmz.cn
http://dinncocrossable.bpmz.cn
http://www.dinnco.com/news/139059.html

相关文章:

  • 大同本地做网站的网站推广的内容
  • 深圳做网站网络公司关键词搜索排名查询
  • 网站标准宽度如何实现网站的快速排名
  • 富阳网站建设推广资源网
  • 专门做网站的公司与外包公司有哪些黑帽seo培训多少钱
  • 帮人做网站如何收费怎么seo关键词优化排名
  • 燕郊教育网站建设百度移动端关键词优化
  • wordpress 网页存在专业北京seo公司
  • 校园网站建设服务电子商务平台有哪些
  • 好看的免费网站模板下载小红书seo排名帝搜软件
  • 给个网站做填空题网络营销服务的特点有哪些
  • wordpress网站如何制作怎么推广网址
  • 租车公司网站 模板网站搜索引擎优化主要方法
  • 昆山建站公司网页seo
  • 青岛做网站公司哪家好青岛关键词优化平台
  • wordpress 最热文章宁波seo整体优化公司
  • 个人网站开发用到的技术世界大学排名
  • 代做网站在哪找活网站推广的技巧
  • 顺义石家庄网站建设外包seo公司
  • 介绍自己的做的网站吗最新营销模式有哪些
  • 沈阳建设工程信息网官方网站上海百度移动关键词排名优化
  • 黑龙江交通系统网站建设数据推广公司
  • 网站页面设计最宽可做多宽深圳谷歌seo公司
  • 怎么做草坪网站推广注册app赚钱平台
  • 网站建设公司果动c网络营销与直播电商好就业吗
  • 网站建设qq杭州网站seo公司
  • 类似于美团的网站开发seo刷排名工具
  • 郑州网站优化渠道百度认证考试
  • 论述网站建设的具体步骤有哪些小说风云榜
  • 华久做网站关键词数据