Function kdb_c_api::flip [−][src]
pub fn flip(dictionary: K) -> K
Expand description
Constructor of q table object from a q dictionary object.
Note
Basically this is a flip
command of q. Hence the value of the dictionary must have
lists as its elements.
use kdb_c_api::*; #[no_mangle] pub extern "C" fn create_table2(_: K) -> K{ // Build keys let keys=new_simple_list(qtype::SYMBOL, 2); let keys_slice=keys.as_mut_slice::<S>(); keys_slice[0]=internalize(str_to_S!("time")); keys_slice[1]=internalize_n(str_to_S!("temperature_and_humidity"), 11); // Build values let values=new_simple_list(qtype::COMPOUND, 2); let time=new_simple_list(qtype::TIMESTAMP, 3); // 2003.10.10D02:24:19.167018272 2006.05.24D06:16:49.419710368 2008.08.12D23:12:24.018691392 time.as_mut_slice::<J>().copy_from_slice(&[119067859167018272_i64, 201766609419710368, 271897944018691392]); let temperature=new_simple_list(qtype::FLOAT, 3); temperature.as_mut_slice::<F>().copy_from_slice(&[22.1_f64, 24.7, 30.5]); values.as_mut_slice::<K>().copy_from_slice(&[time, temperature]); flip(new_dictionary(keys, values)) }
q)climate_change: libc_api_examples 2: (`create_table2; 1);
q)climate_change[]
time temperature
-----------------------------------------
2003.10.10D02:24:19.167018272 22.1
2006.05.24D06:16:49.419710368 24.7
2008.08.12D23:12:24.018691392 30.5