Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An IR which returns a wrong answer. #518

Open
KueenLau opened this issue Jan 21, 2021 · 0 comments
Open

An IR which returns a wrong answer. #518

KueenLau opened this issue Jan 21, 2021 · 0 comments

Comments

@KueenLau
Copy link

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 {
v: WeldVec,
}
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);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant