kOS is K5; it's as different from K4 as K4 was to K3.
Views are available in K4/Q/KDB+, so the version on kx.com does work with views. If you want to play with the views idea, try to solve a problem and see where a view helps you.
Here's one I did earlier this week; I've got this tool that takes a whole bunch of logfiles of userids and counts; they look like this:
These are wrong. I originally tried to figure out them by finding the longest string that was also at the beginning of the sessionid, but after talking it out with Oleg and Pierre I decided to try to simply match them against the lengths of d:
?:#:'d
said I only have two lengths (19 and 20), so this is a much smaller search than what I was trying before!
To do this, I used views:
K::?:#:'d
k::"S"$"S",/:$:'K
f::k!+(K#\:/:g.s)
Now f is an index on g; instead of a `s column it has an `Sn column where n is length of the key; i.e. I have a `S19 and an `S20 column with the first 19 characters of `s and the first 20 characters of `s accordingly.
s::g.s[&|/f[k]in\:d]
c::g.c[&|/f[k]in\:d]
Now I can look at the `s and `c vars and do what I want to do; get my unique userids and my counts.
More importantly, I can apply this to all my files (I have a lot of them):
Views are available in K4/Q/KDB+, so the version on kx.com does work with views. If you want to play with the views idea, try to solve a problem and see where a view helps you.
Here's one I did earlier this week; I've got this tool that takes a whole bunch of logfiles of userids and counts; they look like this:
I call these columns `s(sessionid) and `c(count); I can load them with this: Now I say something like: G"trk/tnl5/20141207/TRK_ITM" to get one of these structures into the g variable.I actually have a bunch of filenames:
So I can load the first one with: G t 0This is convenient, since these files are big (1Gb each or so) I'll want to work with a subset:
This isn't part of my program, it's just something I do while developing. If I run "G" again it'll get the entire file again.Now, I want to match these against another list of users. I'll do a similar trick:
and now I can do: D"users.txt" to put this into the d variable.My program needs to find the rows of g that d match.
Some of the sessionids in the logfiles are corrupt. They look like this instead:
These are wrong. I originally tried to figure out them by finding the longest string that was also at the beginning of the sessionid, but after talking it out with Oleg and Pierre I decided to try to simply match them against the lengths of d: said I only have two lengths (19 and 20), so this is a much smaller search than what I was trying before!To do this, I used views:
Now f is an index on g; instead of a `s column it has an `Sn column where n is length of the key; i.e. I have a `S19 and an `S20 column with the first 19 characters of `s and the first 20 characters of `s accordingly. Now I can look at the `s and `c vars and do what I want to do; get my unique userids and my counts.More importantly, I can apply this to all my files (I have a lot of them):