cancel
Showing results for 
Search instead for 
Did you mean: 

Undocumented ways to load/map files and folders stuctures?

dotsch
New Contributor
Hi Kx,

I might be wrong about this but I can't recall any documentation mentioning these features:

//(1)
//a file handle sym of a folder can be used as a map of the q data files (without file ext)
q) `:d/a set 1 2 3
`:d/a
q) D:`:d
q) D`a    //same as get .Q.dd[D]`a
1 2 3

//(2)
//get maps/loads a whole folder structure 
q) `:d/b set 4 5 6
`:d/b
q) get D
a| 1 2 3
b| 4 5 6
//recursively
q)`:d/c/a`:d/c/b`:d/c/c set' 3 cut "abcdefghi"
`:d/c/a`:d/c/b`:d/c/c
q) get D
a| 1 2 3
b| 4 5 6
c| `s#`a`b`c!("abc";"def";"ghi")
//loads/maps splayed tables too
q) `:d/c/.d set `a`b
q) get D
a| 1 2 3
b| 4 5 6
c| +`a`b!("abc";"def")

//(+1)
//splayed tables don't have to be enumerated, but sym cols are not mapped in that case.
q) `:d/c/a set `a`b`c
q) meta get `:d/c
c| t f a
-| -----
a| s
b| c

(1)&(2) are very useful features actually, can I rely in them on the long term?

Regards,
András
2 REPLIES 2

cbiggs
New Contributor
In general, I would not rely on long term support of undocumented properties. The features that intended to be supported into the future are those that are documented.
For (1) the resolution of hsym path by indexing with a sym is not something I've ever seen documented. How do you believe it's use will be beneficial over the more explicit get .Q.dd[D;`a] call? Is it a matter of the reduction of additional character?

For (2), the fact that get will map in a kdb database structure is documented, the following is an example on the documentation for get 
q)get `:mydata
s  p  qty
---------
s1 p1
300
s1 p2
200
s1 p3
400



I'm curious as to the usefulness of these features when compared to more explicit and readable code, at the cost of a few more characters
Enter code here...


dotsch
New Contributor
Hi,

I know that undocumented features are generally not stable. I was hoping that I missed it in the docs or someone will say that the documentation will be updated and this is a permanent feature. 🙂
1) Indexing syntax works with monadic functions, dictionaries, even with connection handles, I don't really see why file handles should be an exception (as it is logical). I don't see any benefits in using .Q.dd for that particular case (other than long term support), but I will do that of couse as this feature is not meant for developers.
What is the reason for that?
2) I think this is very subjective. I find "get `:db/2019.12.02" more readable and elegant for mapping all tables form a given partition than, let's say
  {k!get each .Q.dd[x] each k:key x}`:db/2019.12.02
Too bad this feature is not stable, but again, this is just my taste.

Regards,
András