Skip to content

Commit

Permalink
change: 1.更新连接地址
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyofin committed Sep 25, 2019
1 parent 92e3a5e commit 53de0fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* @create: 2019-09-09 15:31
**/
public class RedCrossEsSpark {

public static final String JDBC_URL_PHOENIX = "jdbc:phoenix:cdh01:2181";

public static void main(String[] args) throws AnalysisException {
SparkSession sparkSession = SparkSession
.builder()
Expand Down Expand Up @@ -69,7 +72,7 @@ public static void main(String[] args) throws AnalysisException {

// 写入es
sparkSession.sparkContext().conf().set("es.index.auto.create", "true")
.set("es.nodes", "192.168.1.25")
.set("es.nodes", "172.19.4.171")
.set("es.port", "9200")
.set("es.nodes.wan.only", "true");

Expand All @@ -84,7 +87,7 @@ private static void readInPatientRecordFromHbase(SparkSession sparkSession) thro
.format("jdbc")
.option("driver", "org.apache.phoenix.jdbc.PhoenixDriver")
.option("phoenix.schema.isNamespaceMappingEnabled", "true")
.option("url", "jdbc:phoenix:cdh01:2181")
.option("url", JDBC_URL_PHOENIX)
.option("dbtable", "\"gzhonghui\".\"sanitation_negligence_record\"")
.load();
sanitationNegligenceRecord.createOrReplaceTempView("sanitation_negligence_record");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ scala> nestedNumbers.map((x: List[Int]) => x.map(_ * 2)).flatten
res1: List[Int] = List(2, 4, 6, 8)
```

## 常用操作
###对列的数据进行操作
强转类型
```java
// Casts colA to integer.
df.select(df("colA").cast("int"))
```

这个例子先调用map,然后调用flatten,这就是“组合子”的特征,也是这些函数的本质。

**参考** Effective Scala 对[flatMap](https://twitter.github.com/effectivescala/#Functional programming-`flatMap`)的意见。
Expand Down

0 comments on commit 53de0fb

Please sign in to comment.