rust - Rust parquet,按名称而不是按索引位置获取列值
问题描述
我想知道如何从镶木地板文件中按列名获取“item_id”和“idf_score”值。
我正在使用镶木地板 =“3.0”
这是一个玩具示例,我现在如何使用列索引获取值。
fn stackoverflow_example(dir: &str) -> HashMap<u64, f64> {
let mut item_to_idf = HashMap::new();
let dir_entry = fs::read_dir(dir).unwrap();
for path in dir_entry {
let full_path_to_file = path.unwrap().path().display().to_string();
if full_path_to_file.ends_with(".parquet") {
let file = File::open(&Path::new(&full_path_to_file)).unwrap();
let reader = SerializedFileReader::new(file).unwrap();
let mut row_iter = reader.get_row_iter(None).unwrap();
while let Some(row) = row_iter.next() {
let item_id = row.get_long(0).unwrap() as u64;
let idf_score = row.get_double(1).unwrap();
item_to_idf.insert(item_id, idf_score);
}
}
}
item_to_idf
}
解决方案
推荐阅读
- spring - 如何在 dto 类的注释中导入 application.yml 属性
- php - yii2中如何使用if语句正确查看表数据
- image - 如何在本机反应中将base64图像字符串加载到图像滑块中?
- bazel - 避免不同 Linux 版本的 bazel-remote-cache 冲突
- c# - 从字符串中提取多个整数
- javascript - jQuery - 未捕获的类型错误:无法读取未定义的属性“默认值”
- miragejs - 如何使用 MirageJS 中的工厂返回字符串 id 数组?
- scala - 将列动态传递到 Spark SQL 中的其他函数时
- arrays - 查找总和大于给定数字的月份
- ios - 有时 Date() 返回 1 月 1 日