如何通过 Rust 中的给定列订购 arrow2 块?

问题描述 投票:0回答:1

我已经加载了一个带有大量列/数组的大 arrow2 块,在将其写入镶木地板文件之前,我想按给定列对其进行排序。看这段代码:

fn main(){
    use arrow2::{array::*, compute::sort};
    use arrow2::chunk::Chunk;

    let mut col1: Int64Vec = Int64Vec::new();
    col1.push(Some(0));
    col1.push(Some(5));
    col1.push(Some(3));
    col1.push(Some(2));

    let mut col2: Int64Vec = Int64Vec::new();
    col2.push(Some(1));
    col2.push(Some(2));
    col2.push(Some(3));
    col2.push(Some(4));

    let mut chu = Chunk::new(vec![col1.into_arc(), col2.into_arc()]);

    chu.sort_by_key();

}

显然这会失败,因为它不知道按哪一列排序,但我无法使用任何 .sort_* 函数。我想按第一列对“chu”进行排序。

我尝试为“.sort_by_key”函数编写索引提取函数,但没有成功。还谷歌和双子座关于它......

sorting rust apache-arrow rust-arrow2
1个回答
0
投票

TLDR:使用“lexsort”函数。它是简单化“排序”功能的完整版本。

起初,人们会认为这个函数与文本排序(大写与非大写、特殊字符等)有关,但事实并非如此。

另一方面,如果您只想将列保存到 parquet 文件中,就像我一样,请考虑在“WriterProperties”内使用 parquet 自己的列排序选项。

© www.soinside.com 2019 - 2024. All rights reserved.