re: [personal kdb+] table values vs references

293 views
Skip to first unread message

k...@ryan-h.com

unread,
Oct 10, 2012, 4:24:11 AM10/10/12
to personal...@googlegroups.com
KDB uses reference counting, all vectors are passed by reference.
Tables are just collections of vectors and are also passed by reference.
 
For related info see:
 
-Ryan Hamilton



From: "Sam" <jain....@gmail.com>
Sent: 10 October 2012 06:43
To: personal...@googlegroups.com
Subject: [personal kdb+] table values vs references


Hi,
What is the best way to pass tables around in functions? I've large tables and I am writing functions to handle operations such as saving them. If I pass the table as it is by value, then it will create a copy of table at each assignment of a function call. This could be really expensive for large tables. However, if I pass the reference around (`tab), then certain operations such as .Q.en, .Q.par, select ,update, etc don't work as they expect table value not reference.

So what is the ideal approach to handle tables?

thanks for your input.

 

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/personal-kdbplus/-/lYkEKnM30a4J.
To post to this group, send email to personal...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

abcfoots

unread,
Oct 10, 2012, 8:25:39 AM10/10/12
to personal...@googlegroups.com
A variables reference count is returned using -16!. The code below shows passing by reference and illustrates Ryans point

q)t:([]a:1,2,3)
q)0N!-16!t;{0N!-16!x}[t];0N!-16!t;
1
2
1
Reply all
Reply to author
Forward
0 new messages