
scala
weixing_2006
好记性不如烂笔头
展开
-
spark实时读取kafka,提交参数
object BigScreenStream { def main(args: Array[String]): Unit = { val port=5555 val hdfs_file_path = "/spark/streaming/stop/bigScreen" //判断消 息文件是否存在,如果存在就 // val time=args(0).toLong // val fla...原创 2020-01-16 19:51:40 · 667 阅读 · 0 评论 -
scala 对mongodb增删改查
获取数据库的连接 private String uri ="mongodb://interface_manager:2wsxCDE#@IP:PORT/?authSource=admin"; private Map<String,MongoTemplate> templateMap = new HashMap<String,MongoTemplate>(); public ...原创 2019-11-18 19:14:14 · 367 阅读 · 0 评论 -
为什么我连接上了mongodb 操作数据库的时候没反应求解
import org.mongodb.scala.MongoClient import org.mongodb.scala.bson.collection.immutable.Document /* @author: ljx @date: @description: scala连接mongodb,有权限认证 */ object pojo4 { def main(args: A...原创 2019-11-14 10:36:08 · 1505 阅读 · 0 评论 -
fastjson对json解析
json数据:{ "devices": { "cameras": { "device_id": "awJo6rH", "last_event": { "has_sound": true, "has_motion": true, "has_person": true, "start_time": "2016-12-29...原创 2019-10-26 08:58:30 · 160 阅读 · 0 评论 -
通过经纬度获取地区
读取文件后 val jsonStr = Source.fromFile("data/nyc-borough-boundaries-polygon.geojson").mkString val featureCollection = FeatureExtraction.parseJson(jsonStr) //排序(区域最大的放最前面) import scala.collection.JavaC...原创 2019-10-13 21:04:03 · 963 阅读 · 0 评论 -
利用spark读取文件新增列
如图下的数据:如果title中包含某一个类别的关键字,那么取出主类与子类补充到元数据 如果title中出现了男士、男生、男关键字,那么为男士专用 下面是需要补充的类 ,前2列分别是主类和子类,后面都属于关键字 代码: import org.apache.spark.broadcast.Broadcast import org.apache.spark.rdd.RDD import org.a...原创 2019-10-07 20:09:54 · 466 阅读 · 0 评论 -
scala列表常用操作
判断列表是否为空(isEmpty) 拼接两个列表(++) 获取列表的首个元素(head)和剩余部分(tail) 反转列表(reverse) 获取前缀(take)、获取后缀(drop) 扁平化(flaten) 拉链(zip)和拉开(unzip) 转换字符串(toString) 生成字符串(mkString) 并集(union) 交集(intersect) 差集(diff) 1、判断列表是否为空 ...原创 2019-09-22 16:28:35 · 350 阅读 · 0 评论 -
scala基础之继承,类型判断、特质、对象混入、调用链、模式匹配
1、override和super,关于继承,我们在子类中使用override需要来重写父类的成员,可以使用super来引用父类 class Person { val name = "super" def getName = name } class Student extends Person { // 重写val字段(这里val是重点) override val name: String...原创 2019-09-22 14:25:08 · 212 阅读 · 0 评论 -
scala语言基础
scala语言基础: 1、break和continue 实现break: for( i <- 1 to 100){ | breakable{ | if(i %10 ==0){break() | }else{println(i)} | } | } 实现continue breakable{ | for(i <- 1 to 100){ | if(i>50){break...原创 2019-09-17 21:00:11 · 218 阅读 · 0 评论