How to correctly enum and partition a kdb table? -


i put few lines partition kdb table, contains string columns of course , must enumerated.

i wonder if code correct or if can simplified further. in particular, have doubt need create partitioned table schema given memory table , disk table have same layout. also, there might way avoid creating temporary 'tbl_mem' , 'tbl_mem_enum' tables:

... tbl_mem: select ts,sym,msg_type oms_mem lj sym_mem; tbl_mem_enum: .q.en[`$sym_path] tbl_mem; delete tbl_mem `.;  (`$db;``!((17;2;9);(17;2;9))) set ([]ts:`time$(); ticker:`symbol$(); msg_type:`symbol$()); (`$db) upsert (select ts,ticker:sym,msg_type tbl_mem_enum) delete tbl_mem_enum `.; 

ps: know, shouldn't use "_" name variables, use separate words in variable or function name? '.' kdb function.

i think mean table contains symbol columns - these columns need enumerate (strings don't need enumeration). can write , enumeration in single step. if using same compression algo/level on columns may easier use .z.zd:

.z.zd:17 2 9i; (`$db) set .q.en[`$sym_path] select ts, ticker:sym, msg_type oms_mem lj sym_mem; 

it's recommended use camelcase instead of '_'. useful info here: http://www.timestored.com/kdb-guides/q-coding-standards


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -