weld-project / weld

High-performance runtime for data analytics applications
https://www.weld.rs
BSD 3-Clause "New" or "Revised" License
2.99k stars 256 forks source link

An IR which returns a wrong answer. #518

Open KueenLau opened 3 years ago

KueenLau commented 3 years ago

I construct a test which uses a vector containing struct. But the length of result is 0. When I change the input data to i32 vector, the length of result is correct. Blow is the code.

//Multi Column Test let code = "|v: vec[{i32,i32,i32}] | let sorted_vec = sort( result( for( v, appender[{i32,i32,i32}], |b:appender[{i32,i32,i32}],i:i64,n:{i32,i32,i32}| if(n.$1 == 1,merge(b,n),b) ) ), |x:{i32,i32,i32},y:{i32,i32,i32}| compare(x.$2,y.$2)); len(slice(sorted_vec,0L,3L)) "; let neid = OmniCodeGen::compile(code); let id = vec![1,2,3,4,5,6]; let course = vec![7,8,9,10,11,12]; let score= vec![80,81,82,83,84,85]; let data = vec![id,course,score]; let result = OmniCodeGen::execute(neid,data).expect("OmniCache Native execute failed!"); println!("result {:?}", result); let data = result.data() as const i64; let result = unsafe { (data).clone() }; println!("result----- {:?}",result)

impl OmniCodeGen { pub fn compile(code: &str) -> u64 { let conf = WeldConf::new(); let module = WeldModule::compile(code,&conf).expect("OmniCache code gen failed!"); let mut s = DefaultHasher::new(); code.hash(&mut s); let key= s.finish(); CACHE.insert(key,module); return key; } pub unsafe fn execute(nativeExecId: u64, data: Vec) -> WeldResult { let module = CACHE.get(&nativeExecId).expect("Not find execution native code,please code compile first!");

[allow(dead_code)]

    struct Args<T> {
        v: WeldVec<T>,
    }
    let ref input_data = Args{
        v: WeldVec::from(&data),
    };
    let ref input_value = WeldValue::new_from_data(input_data as * const _ as Data);
    let ref conf = WeldConf::new();
    let ref mut context = WeldContext::new(&conf).unwrap();
    return module.run(context,input_value);
}

}