Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 如何用Spark改进Kudu阅读?_Scala_Apache Spark_Apache Spark Sql_Kudu_Apache Kudu - Fatal编程技术网

Scala 如何用Spark改进Kudu阅读?

Scala 如何用Spark改进Kudu阅读?,scala,apache-spark,apache-spark-sql,kudu,apache-kudu,Scala,Apache Spark,Apache Spark Sql,Kudu,Apache Kudu,我有一个过程,给定一个新的输入,从Kudu数据库检索相关信息,然后进行一些计算 问题在于数据检索,我们有1.201.524.092行,对于任何计算,开始处理所需的数据都需要花费很长时间,因为读者需要将所有数据都交给spark 要阅读kudu表格,我们需要: def read(tableName: String): Try[DataFrame] = { val kuduOptions: Map[String, String] = Map( "

我有一个过程,给定一个新的输入,从Kudu数据库检索相关信息,然后进行一些计算

问题在于数据检索,我们有1.201.524.092行,对于任何计算,开始处理所需的数据都需要花费很长时间,因为读者需要将所有数据都交给spark

要阅读kudu表格,我们需要:

def read(tableName: String): Try[DataFrame] = {
        val kuduOptions: Map[String, String] = Map(
                "kudu.table" -> tableName,
                "kudu.master" -> kuduContext.kuduMaster)
        
        SQLContext.read.options(kuduOptions).format("kudu").load
        
}
然后:

val newInputs = ??? // Dataframe with the new inputs
val currentInputs = read("inputsTable") // This takes too much time!!!!

val relatedCurrent = currentInputs.join(newInputs.select("commonId", Seq("commonId"), "inner")

doThings(newInputs, relatedCurrent)
例如,我们只想引入一个新的输入。嗯,它必须扫描整个表以找到当前输入,这将导致81.6GB/1201524092行的无序写入

我该如何改进这一点


谢谢,

您可以收集新的输入,然后可以在where子句中使用它。 使用这种方法,您可以很容易地找到OOM,但它可以使您的查询非常快,因为它将受益于谓词下推

val collectedIds = newInputs.select("commonId").collect
val filtredCurrentInputs = currentInputs.where($"commonId".isin(collectedIds))

您可以收集新输入,然后在where子句中使用它。 使用这种方法,您可以很容易地找到OOM,但它可以使您的查询非常快,因为它将受益于谓词下推

val collectedIds = newInputs.select("commonId").collect
val filtredCurrentInputs = currentInputs.where($"commonId".isin(collectedIds))