当我在Ubuntu中执行以下命令时
sudo apt-get update & sudo apt-get install Google-cloud-SDK
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。
E: Malformed entry 1 in list file /etc/apt/sources.list.d/google-cloud-sdk.list (Component)
E: The list of sources could not be read.
Run Code Online (Sandbox Code Playgroud) 我正在使用spark 2.11版本,我在我的应用程序中只做了3个基本操作:
但是对于这3个操作,它需要将近20分钟.如果我在SQL中执行相同的操作,则需要不到1分钟.
我已经开始使用spark因为它会产生非常快的结果,但是花费了太多时间.如何提高性能?
第1步:从数据库中获取记录.
Properties connectionProperties = new Properties();
connectionProperties.put("user", "test");
connectionProperties.put("password", "test##");
String query="(SELECT * from items)
dataFileContent= spark.read().jdbc("jdbc:oracle:thin:@//172.20.0.11/devad", query,connectionProperties);
Run Code Online (Sandbox Code Playgroud)
步骤2:使用contains检查文件B(2M)中存在的文件A(5k)的记录
Dataset<Row> NewSet=source.join(target,target.col("ItemIDTarget").contains(source.col("ItemIDSource")),"inner");
Run Code Online (Sandbox Code Playgroud)
步骤3:将匹配的记录写入CSV格式的文件
NewSet.repartition(1).select("*")
.write().format("com.databricks.spark.csv")
.option("delimiter", ",")
.option("header", "true")
.option("treatEmptyValuesAsNulls", "true")
.option("nullValue", "")
.save(fileAbsolutePath);
Run Code Online (Sandbox Code Playgroud)
为了提高性能,我尝试了一些设置Cache,数据序列化等功能
set("spark.serializer","org.apache.spark.serializer.KryoSerializer")),
Run Code Online (Sandbox Code Playgroud)
随机播放时间
sqlContext.setConf("spark.sql.shuffle.partitions", "10"),
Run Code Online (Sandbox Code Playgroud)
数据结构调整
-XX:+UseCompressedOops ,
Run Code Online (Sandbox Code Playgroud)
没有一种方法不会产生更好的性能.