What about "InterSystems ObjectScript" ?
>>> short ISOS ?? 😉
- Log in to post comments
What about "InterSystems ObjectScript" ?
>>> short ISOS ?? 😉
An excellent experience !
thanks for sharing.
Fully agree with your suggestion of an Abstract Class.
It's in fact the modern equivalent of the old .INC approach
much more simple with 2 identic .INT routines a1 and a2
ROUTINE a1 [Type=INC]
load ;
read !,"loops=",loop,!
do t1 hang 0.5 do t2 quit
next
set t1=$zh quit
t1
set t0=$zh
for i=1:1:loop do next
write t1-t0,!
quit
t2
set t0=$zh
for i=1:1:loop do next^a2
write t1-t0,!
quit
SAMPLES>d ^a1
loops=1000000
.081626
.136785
SAMPLES>I just mean you can't do less:
the difference is even worse 40.3%
My approach was rather simple.
SUMMARY: There is a difference.
But I wouldn't bend a little finger to attack it. (not even on PDP-11)
This is nothing where performance comes from.
OK - in UDL
IRIS for Windows (x86-64) 2024.3 (Build 217U) Thu Nov 14 2024 17:59:58 EST
ROUTINE anna [Type=INC]anna(name) quit ""
A.HUGE.cls
Include anna Class A.HUGE Extends (%Persistent, %Populate) { Property calc As %Integer [ Calculated, SqlComputeCode = { set {*}={%%ID}}, SqlComputed ]; ClassMethod fill(size) As %String [ SqlProc ] { for i=1:1:size set ^A.HUGED(i)="" set ^A.HUGED=i quit $ZR_"="_@$ZR } ClassMethod test1(val) As %String [ SqlProc ] { quit ##class(A.PERSON).Anna(val) } ClassMethod test2(val) As %String [ SqlProc ] { quit $$anna(val) } Storage Default { <Data name="HUGEDefaultData"> <Value name="1"> <Value>%%CLASSNAME</Value> </Value> </Data> <DataLocation>^A.HUGED</DataLocation> <DefaultData>HUGEDefaultData</DefaultData> <IdLocation>^A.HUGED</IdLocation> <IndexLocation>^A.HUGEI</IndexLocation> <StreamLocation>^A.HUGES</StreamLocation> <Type>%Storage.Persistent</Type> } }
A.PERSON.cls
Include anna
Class A.PERSON Extends %Persistent
{
Property calc As %Integer [ Calculated, SqlComputeCode = { set {*}={%%ID}}, SqlComputed ];
ClassMethod fill(size) As %String [ SqlProc ]
{
for i=1:1:size set ^A.PERSOND(i)=""
set ^A.PERSOND=i
quit $ZR_"="_@$ZR
}
ClassMethod test1(val) As %String [ SqlProc ]
{
quit ##class(A.PERSON).Anna(val)
}
ClassMethod Anna(name As %String) As %String
{
quit $$anna(name)
}
Storage Default
{
<Data name="PERSONDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
</Data>
<DataLocation>^A.PERSOND</DataLocation>
<DefaultData>PERSONDefaultData</DefaultData>
<IdLocation>^A.PERSOND</IdLocation>
<IndexLocation>^A.PERSONI</IndexLocation>
<StreamLocation>^A.PERSONS</StreamLocation>
<Type>%Storage.Persistent</Type>
} }I did this to verify my approach looping over a simulated table of 100 mio rows
The difference is evident:
[SQL]SAMPLES>>select A.HUGE_fill(100000000) 18. select A.HUGE_fill(100000000) | Expression_1 | | -- | | ^A.HUGED=100000000 | 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0008s/5/828/0ms execute time(s)/globals/cmds/disk: 18.8332s/100,000,002/200,000,445/0ms query class: %sqlcq.SAMPLES.cls3 --------------------------------------------------------------------------- [SQL]SAMPLES>>select list(A.HUGE_TEST1(ID)) from A.HUGE 19. select list(A.HUGE_TEST1(ID)) from A.HUGE | Aggregate_1 | | -- | | | 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0005s/4/141/0ms execute time(s)/globals/cmds/disk: 101.5573s/100,000,001/700,000,424/0ms query class: %sqlcq.SAMPLES.cls2 --------------------------------------------------------------------------- [SQL]SAMPLES>>select list(A.HUGE_TEST2(ID)) from A.HUGE 20. select list(A.HUGE_TEST2(ID)) from A.HUGE | Aggregate_1 | | -- | | | 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0005s/4/141/0ms execute time(s)/globals/cmds/disk: 72.1640s/100,000,001/700,000,424/0ms query class: %sqlcq.SAMPLES.cls1 --------------------------------------------------------------------------- [SQL]SAMPLES>>
Rough calculation: including the code in the class saves ~30% of execution time
my class code
Include anna
Class A.HUGE Extends (%Persistent, %Populate)
{
Property calc As %Integer [ Calculated, SqlComputeCode = { set {*}={%%ID}}, SqlComputed ];
ClassMethod fill(size) As %String [ SqlProc ]
{
for i=1:1:size set ^A.HUGED(i)=""
set ^A.HUGED=i
quit $ZR_"="_@$ZR
}
ClassMethod test1(val) As %String [ SqlProc ]
{
quit ##class(A.PERSON).Anna(val)
}
ClassMethod test2(val) As %String [ SqlProc ]
{
quit $$anna(val)
}The simplified anna,INC just returns NullString to concentrate on code switching
anna(name)
quit ""Loading compiled obj code from cache to partition should not have any remarkable impact.
But you are right by principle ! It's some kind of overhead and not for free.
If you place the affected code into a .INC routine you may share that piece
rather easy over multiple instances.
Though mostly not used in that way any Include may also contain executable code.
For a :MAC routine it's nothing impressive.
For Class code it's a bit tricky but works as well
example ANNA.INC
anna(name) ;
write !,"Hello ",name,!
quit ">>>"_name_"<<<"example Anna.CLS
/// demo for Anna
Include ANNA
Class A.Anna {
ClassMethod demo(name As %String) As %String
{
quit $$anna(name)
}
}It works:
SAMPLES>write "===",##class(A.Anna).demo("robert")
===
Hello robert
>>>robert<<<
SAMPLES>So multiple loading is reduced.
You have of course also the option to compose a Custom Command in %ZLANG***.MAC
I just have no experience of how this impacts partition loading.
The generated .INT proves it.png)
Studio shows the Error already during typing..png)
But this works fine as you expected:.png)
BINGO !
.png)
composed by nI
Exactly.!
..#PARAMETER inserts a STRING
But >>> $NAME() looks for a variable also by indirection
USER>w $name("^rcc(1)")
W $NAME("^rcc(1)")
^
<SYNTAX>
USER>w $name(^rcc(1))
^rcc(1)
USER>s x="^rcc(1)"
USER>w $name(x)
x
USER>w $name(@x)
^rcc(1)
USER>OOOOOPS 😮
Hi Jean,
at first glance I'd expect the query plan for #18. and #19. should be quite similar
:SQL offers 3 levels to see the query plan
This might offer a chance to identify the difference.
There's still an - unlikely - chance that #19 runs on some broken cached query,
that never was updated. so clear cached queries might be a possible solution. Not an explanation
Best regards, Robert
Interoperability is not available in all namespaces.
Typically not in %SYS, but in USER
Check in Management Portal. where it is included.
I'm once more impressed by your contribution.
As often in past you leave the (mostly boring) mainstream,
look over the mental fence and bring tools and solutions
beyond the usual compositions that I see repeatedly in my reviews.
this is just great! . 👏 👍
Hello community;
update added
confirm. It works and is independent of IRIS version
Write to a DataBase with no Read is not possible by principle.
Think if indices and other information for structural maintenance.
BUT:
You may create your own WRITE in a method, function, background job, ...
that elevates to RW access and drops it at completion.
details: Privileged Routine Applications
I prepared a pull request for standard Docker support
https://github.com/r-cemper/PR_First-Vector-Search-on-IRIS
#1) in %SYS find the sessions by this Stored Procedure:.png)
#2 Next based on the SessionId I can open the Object
%SYS>set sess=##class(%CSP.Session).%OpenId("kTkyVXwgxw")
%SYS>set pid=sess.ProcessId
%SYS>if $l(pid) set tSC=$$DeleteSession^%SYS.cspServer(pid)The last row was found in
Attention. Not every CSP Session has also a pid !
That's a typical case,
where I write my personal ZZanyname function into %ZLANGF00.mac
to hide the details
which version ?
I tried and failed.
CLASS DOES NOT EXIST>%FromOref+8^%Library.DynamicObject.1 *%Library.EntityProjectionUtil
SAMPLES>w $zv
IRIS for Windows (x86-64) 2024.3 (Build 217U) Thu Nov 14 2024 17:59:58 EST
Just to confirm naming in COS
GlobalName is everything between Caret ^ and left Parenthesis (
GlobalSubscript is everything within left and right Parenthesis ( )
just E2C8.D9IS.*
to cover all .1 .2 .3 .S
and no subscripts
Did you mean to map this Global ?
^DepartmentMasterData("^E2C8.D9IS.*") ?????
or just ^E2C8.D9IS.* ? with all subscripts
OK
To Stream needs 1 line 2 statements
ClassMethod personsidGET(messageRequest As dc.Sample.v3rest.requests.personsidGET) As %Stream.Object
{
set stream=##class(%Stream.TmpCharacter).%New(),sc=##class(dc.Sample.Person).%OpenId(messageRequest.pathid).%JSONExportToStream(.stream)
return stream
}To String is shorter (just 1 statement) as you don't need to initialize %String)
ClassMethod personsidGET(messageRequest As dc.Sample.v3rest.requests.personsidGET) As %String
do ##class(dc.Sample.Person).%OpenId(messageRequest.pathid).%JSONExportToString(.string)
return string
{not just Sample.Person but also Sample.Address,
or whatever serial class you refer to require %JSON Adaptor.
then
set person=##class(Sample.Person).%OpenId(3)
>set sc=person.%JSONExportToString(.Jperson)
set zjson={}.%FromJSON(Jperson)
ZWRITE
Jperson="{"LIMIT":103,"Name":"O'Rielly,Xavier E.","SSN":"331-77-5308","DOB":"1957-05-26","Home":{"Street":"8757 Elm Place","City":"Miami","State":"FL","Zip":"92027"},"Office":{"Street":"413 First Drive","City":"Miami","State":"NH","Zip":"83830"},"Age":67,"RowVer":0}"
person=<OBJECT REFERENCE>[2@Sample.Person]
sc=1
zjson=<OBJECT REFERENCE>[13@%Library.DynamicObject]and there is your dynamic object
there is no description of how to communicate with Butler
at the moment it hangs around like a lazy chap
updated today