Small addition: I now realize that my echo ts 'A =: 1234 (123456789) } A'
executes the sentence twice. It is the first execution, creating a new key, that takes a long time. Updating the value at an existing key is instantaneous. On Fri, 9 Apr 2021 at 11:50, Ben Gorte <[email protected]> wrote: > Actually I have also been trying to use a sparse array as a key-value data > store. I had quite large keys (15 digit integers) and smaller (positive) > integer values. I needed to query by key or by value, as well as to > sometimes traverse the whole dataset in key order. Very often I query for > non-existing keys, which should not be considered an exception, but just > return a special (negative) value. > > All this works perfectly after almost no development effort. > > However: > > * be very slow for updates, as the entire table must be copied > > You can say that again :-) > > In the example below, filling the table with a million values takes 0.2s, > which is great. Adding another key-value seems to take only 0.02 s > according to 6!:2, but in reality I'm waiting 1 minute and 42 seconds. This > is in j-9.03h, in 9.02 it's even four minutes. Whether jconsole or jqt > makes no difference. During that time, top (in linux) is showing 100% CPU > usage for the J task and 100M memory usage (no swapping). > > Isn't that strange? > > Greetings, > Ben > > ~/temp$ cat spar > #!/home/ben/j903/bin/jconsole > > ts =: 6!:2 ; 7!:2@] > SIZE=:1000000000000000 > > A =: 1 $. SIZE;0;_1 > k =: ?1000000$SIZE > v =: ?1000000$1000 > echo ts 'A =: v k } A' > echo ts 'A =: 1234 (123456789) } A' > exit '' > > ~/temp$ time spar > ┌────────┬─────────┐ > │0.195064│100668384│ > └────────┴─────────┘ > ┌────────┬────────┐ > │0.019474│52432576│ > └────────┴────────┘ > > real 1m42.805s > user 1m42.709s > sys 0m0.075s > > > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
