pub unsafe extern "C" fn k(socket: I, query: const_S, ...) -> KExpand description
Send a text query or evaluate the text query in a process which are loading the shared library.
As this library is purposed to build shared object, the only choice of socket is 0. This
executes against the kdb+ process in which it is loaded.
#[macro_use]
extern crate kdbplus;
use kdbplus::qtype;
use kdbplus::api::*;
use kdbplus::api::native::*;
#[no_mangle]
pub extern "C" fn dictionary_list_to_table() -> K{
let dicts=unsafe{knk(3)};
let dicts_slice=dicts.as_mut_slice::<K>();
for i in 0..3{
let keys=unsafe{ktn(qtype::SYMBOL_LIST as I, 2)};
let keys_slice=keys.as_mut_slice::<S>();
keys_slice[0]=unsafe{ss(str_to_S!("a"))};
keys_slice[1]=unsafe{ss(str_to_S!("b"))};
let values=unsafe{ktn(qtype::INT_LIST as I, 4)};
values.as_mut_slice::<I>()[0..2].copy_from_slice(&[i*10, i*100]);
dicts_slice[i as usize]=unsafe{xD(keys, values)};
}
// Format list of dictionary as a table.
// ([] a: 0 10 20i; b: 0 100 200i)
unsafe{k(0, str_to_S!("{[dicts] -1 _ dicts, (::)}"), dicts, KNULL)}
}q)unfortunate_fact: `libc_api_examples 2: (`dictionary_list_to_table; 1);
q)unfortunate_fact[]
a b
------
0 0
10 100
20 200