apache-spark - Spark 数据集的 Avro Schema 与 Scala 案例类
问题描述
我很好奇使用 Scala 案例类中定义的模式与使用 Apache Avro 为 Spark 数据集定义模式之间是否存在显着的性能差异。目前我有一个看起来像这样的模式:
root
|-- uniqueID: string (nullable = true)
|-- fieldCount: integer (nullable = false)
|-- fieldImportance: integer (nullable = false)
|-- fieldPrimaryName: string (nullable = true)
|-- fieldSecondaryName: string (nullable = true)
|-- samples: map (nullable = true)
| |-- key: string
| |-- value: struct (valueContainsNull = true)
| | |-- value1: byte (nullable = false)
| | |-- value2: byte (nullable = false)
| | |-- value3: byte (nullable = false)
对应的案例类看起来像
case class FieldSample(uniqueID: String,
fieldCount: Int,
fieldImportance: Int,
fieldPrimaryName: Int,
fieldSecondaryName: Int,
samples: Map[String, ValueStruct])
case class ValueStruct(value1: Byte,
value2: Byte,
value3: Byte)
我已经使用 scala 案例类实现了这个,但我看到从磁盘读取的瓶颈非常大。数据以 parquet 格式保存在磁盘上。我想知道的是,在这种情况下,使用 Avro 模式而不是 scala 案例类是否有任何性能优势。我的猜测是嵌套模式导致 parquet 读取缓慢,所以我想知道 Avro 序列化是否以这种方式提供任何性能升级。谢谢!
解决方案
推荐阅读
- android - 使用 Sripe 的 Google Pay:在 Android 中出现意外的开发人员错误
- javascript - Javascript中带有空格的“未定义”变量的字符串连接
- nginx - Nginx 缓存问题与 Expires 标头
- javascript - 使用匹配将正则表达式解析为本地变量
- reactjs - 如何在 Reactjs 标签中使用 jquery
- java - 如何从 Firebase 存储设置图像视图?
- android - Android auto - Google play rejection for Dark mode - How to fix?
- r - 如何在 R 中保存使用 forestplot 包创建的图?
- java - 每 x 毫秒执行一次的代码,可更改
- reactjs - 如果路径不包含有关数据类型的线索,React/NextJS 如何处理路由和图像?