Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit69ee9eb

Browse files
author
James Lee
committed
update TypedDataset
1 parent91074f5 commit69ee9eb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎src/main/java/com/sparkTutorial/sparkSql/TypedDataset.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
importorg.apache.log4j.Level;
44
importorg.apache.log4j.Logger;
5+
importorg.apache.spark.api.java.function.FilterFunction;
56
importorg.apache.spark.sql.*;
67

78
importstaticorg.apache.spark.sql.functions.avg;
@@ -38,19 +39,21 @@ public static void main(String[] args) throws Exception {
3839
typedDataset.show(20);
3940

4041
System.out.println("=== Print the responses from Afghanistan ===");
41-
typedDataset.filter(response ->response.getCountry().equals("Afghanistan")).show();
42+
typedDataset.filter((FilterFunction<Response>)response ->response.getCountry().equals("Afghanistan")).show();
4243

4344
System.out.println("=== Print the count of occupations ===");
4445
typedDataset.groupBy(typedDataset.col("occupation")).count().show();
4546

4647
System.out.println("=== Print responses with average mid age less than 20 ===");
47-
typedDataset.filter(response ->response.getAgeMidPoint() !=null &&response.getAgeMidPoint() <20).show();
48+
typedDataset.filter((FilterFunction<Response>)response ->response.getAgeMidPoint() !=null &&
49+
response.getAgeMidPoint() <20)
50+
.show();
4851

4952
System.out.println("=== Print the result by salary middle point in descending order ===");
5053
typedDataset.orderBy(typedDataset.col(SALARY_MIDPOINT ).desc()).show();
5154

5255
System.out.println("=== Group by country and aggregate by average salary middle point and max age middle point ===");
53-
typedDataset.filter(response ->response.getSalaryMidPoint() !=null)
56+
typedDataset.filter((FilterFunction<Response>)response ->response.getSalaryMidPoint() !=null)
5457
.groupBy("country")
5558
.agg(avg(SALARY_MIDPOINT),max(AGE_MIDPOINT))
5659
.show();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp