gpt4 book ai didi

eclipse - 如何在 Eclipse 环境中的 spark 中设置堆大小?

转载 作者:行者123 更新时间:2023-12-04 09:10:23 26 4
gpt4 key购买 nike

我正在尝试在 Eclipse 中使用 spark 运行以下简单的代码:

import org.apache.spark.sql.SQLContext
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
object jsonreader {
def main(args: Array[String]): Unit = {
println("Hello, world!")
val conf = new SparkConf()
.setAppName("TestJsonReader")
.setMaster("local")
.set("spark.driver.memory", "3g")
val sc = new SparkContext(conf)

val sqlContext = new SQLContext(sc)
val df = sqlContext.read.format("json").load("text.json")

df.printSchema()
df.show
}
}

但是,我收到以下错误:
16/08/18 18:05:28 ERROR SparkContext: Error initializing SparkContext.
java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859200. Please increase heap size using the --driver-memory option or spark.driver.memory in Spark configuration.

我遵循了这样的不同教程: How to set Apache Spark Executor memory .大多数时候我要么使用 --driver-memory选项(Eclipse 不可能)或通过修改 spark 配置但没有相应的文件。

有没有人知道如何在 Eclipse 环境中解决这个问题?

最佳答案

在 Eclipse 中转到 运行 > 运行配置... > 参数 > VM 参数 并设置最大堆大小,如 -Xmx512m .

关于eclipse - 如何在 Eclipse 环境中的 spark 中设置堆大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39023022/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com