Remove @aimglobal@(11) node maintenance from $$XREFDATA^%YDBAIM as it seems to serve no purpose
Final Release Note
Description
This is something I noticed while investigating a TRANS2BIG
error in Octo (YottaDB/DBMS/YDBOcto#1083 (closed)).
As line 525 states below, the xref global node @aimglobal@(11)
contains the TOTAL number of nodes being tracked. This is maintained in lines 1147-1162 below as well as in various other places in _YDBAIM.m
.
_YDBAIM.m
525 ; - (11) if stat is 2, this contains the total number of nodes being tracked
But I don't understand what purpose it serves. Let me take the below example M program where ^names
global has a id
subscript and firstname|lastname
as its value.
$ cat aimstat2.m
do UNXREFDATA^%YDBAIM
kill ^names
set ^names(1)="First1|Last1"
set base="^names",subs(1)=":"
set aimglobal=$$XREFDATA^%YDBAIM(base,.subs,"|",1,0,0,1,2,0,1)
set aimglobal=$$XREFDATA^%YDBAIM(base,.subs,"|",2,0,0,1,2,0,1)
write "# xref of firstname=First1 and lastname=Last1",!
do show
write "# xref of firstname=First2 and lastname=Last2",!
set ^names(2)="First2|Last2" do show
write "# xref of firstname=First3 and lastname=Last2",!
set ^names(3)="First3|Last2" do show
write "# xref of firstname=First4 and lastname=Last2",!
set ^names(4)="First4|Last1" do show
quit
show
zwrite ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)
zwrite ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)
zwrite ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)
write !
Running the M program gives the below output.
$ mumps -run aimstat2
# xref of firstname=First1 and lastname=Last1
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)=1
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)=1
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)=2
# xref of firstname=First2 and lastname=Last2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)=2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)=2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)=4
# xref of firstname=First3 and lastname=Last2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)=2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)=3
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)=6
# xref of firstname=First4 and lastname=Last2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)=2
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)=4
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)=8
^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-2)
clearly gives us the number of unique last names at each stage. And this is useful information to have.
Similarly, ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(-1)
gives us the number of unique first names at each stage. And this is also useful information to have.
But ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)
seems like useless information. It seems to be the total sum of ALL cross referenced pieces. So if there are N nodes in the ^names
global, and we are cross referencing both firstname and lastname pieces, ^%ydbAIMDERzGTIrQTVBoOhdanoKcC7(11)
seems to be always 2*N
. This is totally derived information. And to actually compute it, we create a tstart/tcommit fence which is what caused a TRANS2BIG
error in YottaDB/DBMS/YDBOcto#1083 (closed).
Octo will be temporarily fixed in this case to use stat=1
to avoid the TRANS2BIG error (instead of stat=2
). But stat=2
provides more information for optimizations in Octo (e.g. YottaDB/DBMS/YDBOcto#317 and YottaDB/DBMS/YDBOcto#275). So it would be nice to remove this unnecessary code in YDBAIM thereby we can revert to Octo using stat=2
afterwards.