help with sample query on code.kx.com

On this page (http://code.kx.com/wiki/Sample\_Queries), there is a sample q code

<font color='"#000000"'>/ Generate some random computer statistics (cpu usage only)

/ You can modify n (number of unique computers), timerange (how long the data is for)
/ freq (how often a computer publishes a statistic) and calls (the number of logged calls)
n:1000; timerange:5D; freq:0D00:01; calls:3000;
depts:financepackinglogisticsmanagementhoopjumpingtradingtelesales; startcpu:(til n)!25+n?20; fcn:n*fc:long$timerange%freq;

computer:(time:(-0D00:00:10 + fcn?0D00:00:20)+fcn#(.z.p - timerange)+freq*til fc; id:raze fc#'key startcpu)
computer:update g#id from time xasc update cpu:{100&3|startcpu[first x]+sums(count x)?-2 -1 -1 0 0 1 1 2}[id] by id from computer

/ And generate some random logged calls
calls:( time:(.z.p - timerange)+asc calls?timerange; id:calls?key startcpu; severity:calls?1 2 3)

/ create a lookup table of computer information
computerlookup:([id:key startcpu] dept:n?depts; os:n?win7win8osxvista)

The line in red above gives me an error

q)\l sample.q

k){$[$[99h=@t:v y;98h=@. t;0];[n:#+!y;n!x 0!y];x y]}

's-fail

@

@[;time;#[s]]

+timeid`cpu!(2016.08.25D06:45:04.189595562 2016.08.25D06:45:04.226940205 20..

q.Q))

The error seems to be sorting the computer table by time. I can’t seem to figure out why the sorting is failing or how to fix it.

which version/release of kdb+ are you using?

KDB version on which it is NOT working (This is the paid 64-bit version running on Linux):

KDB+ 3.1 2013.07.18 Copyright (C) 1993-2013 Kx Systems

l64/ 1(1)core

KDB version on which it is working (This is the free 32 bit version running on Windows):

KDB+ 3.1 2014.08.22 Copyright (C) 1993-2014 Kx Systems

w32/ 16()core

yes, that bug was fixed in v3.1 2013.10.06

Thanks Charles. Appreciate if you can share more details of the bug.

On Tuesday, August 30, 2016 at 3:01:13 PM UTC+8, Hungry Goat wrote:

On this page (http://code.kx.com/wiki/Sample_Queries), there is a sample q code

/ Generate some random computer statistics (cpu usage only)/ You can modify n (number of unique computers), timerange (how long the data is for)/ freq (how often a computer publishes a statistic) and calls (the number of logged calls)n:1000; timerange:5D; freq:0D00:01; calls:3000;depts:financepacking<wbr>logisticsmanagement<wbr>hoopjumpingtradingtelesales; startcpu:(til n)!25+n?20; fcn:n*fc:long$timerange%freq;computer:(time:(-0D00:00:10 + fcn?0D00:00:20)+fcn#(.z.p - timerange)+freq*til fc; id:raze fc#'key startcpu)computer:update g#id from time xasc update cpu:{100&3|startcpu[first x]+sums(count x)?-2 -1 -1 0 0 1 1 2}[id] by id from computer/ And generate some random logged callscalls:( time:(.z.p - timerange)+asc calls?timerange; id:calls?key startcpu; severity:calls?1 2 3)/ create a lookup table of computer informationcomputerlookup:([id:key startcpu] dept:n?depts; os:n?win7win8osxvista)

The line in red above gives me an error

q)\l sample.q

k){$[$[99h=@t:v y;98h=@. t;0];[n:#+!y;n!x 0!y];x y]}

's-fail

@

@[;time;#[s]]

+timeid`cpu!(2016.08.25D06:45:04.189595562 2016.08.25D06:45:04.226940205 20..

q.Q))

The error seems to be sorting the computer table by time. I can’t seem to figure out why the sorting is failing or how to fix it.

As a commercially licensed user, you have access to the detailed change list via your company’s representative (they can download new versions/releases AND the detailed change list).

In addition, as a commercially licensed user, you’re also welcome to join the k4 listbox by submitting your company email address ( not your personal gmail/hotmail etc) here https://www.listbox.com/subscribe/?listname=k4

However, the relevant change was
sorting of vectors of underlying type long was broken where range of values<9e15 with values>9e15.
 e.g. q)n:10;b:(100*a:n?n)+50*floor n#1e17;iasc[b]~iasc a

Thank you Charles. Appreciate your prompt response.