Vitaliy Serdtsev · Mar 10, 2025 go to post

IRIS for Windows (x86-64) 2024.3 (Build 217U) Thu Nov 14 2024 17:59:58 EST

Or "Include EnsUtil"

Now you can do it like this:

##class(%BigData.ShardedSQL).ClassNameToTableName(pClassName)
Vitaliy Serdtsev · Mar 10, 2025 go to post

USER>w $zv
IRIS for Windows (x86-64) 2024.3 (Build 217U) Thu Nov 14 2024 17:59:58 EST

USER>w $$GetEnvironment^%apiOBJ("collation","%Library.String",.collval),! zw collval 1

USER>w $$GetEnvironment^%apiOBJ("collation","dc.Username",.collval),! zw collval 1

USER>zn "%SYS"

%SYS>w $$GetEnvironment^%apiOBJ("collation","%Library.String",.collval),! zw collval 1

%SYS>w $$GetEnvironment^%apiOBJ("collation","%Library.Username",.collval),! zw collval 1

Vitaliy Serdtsev · Mar 10, 2025 go to post

Strangely, I had no issues with the %Library.Username type. I didn't explicitly specify the collation anywhere: neither in the data type class nor for the Namespace-wide.

Namespace '%SYS':

Class %Library.Username Extends %String
{

Parameter MAXLEN As INTEGER = 160;

}

Namespace 'USER':

Class dc.Username Extends %String
{

Parameter MAXLEN As INTEGER = 160;

}

Class dc.a Extends %Persistent
{

Index is1 On s1;

Index is2 On s2;

Index is3 On s3;

Property s1 As %String;

Property s2 As %Username;

Property s3 As dc.Username;

ClassMethod Test()
{
  ..%KillExtent()
  
  s="joefu","JoeFu" {
    t=..%New()
    t.s1=s
    t.s2=s
    t.s3=s
    t.%Save()
  }

  zw ^dc.aD,^dc.aI
}

}
select FIELD_NAME,DATATYPE,COLLATION_FUNCTION,MAXLEN from %Library.SQLCatalog_SQLFields('dc.a')

FIELD_NAME DATATYPE COLLATION_FUNCTION MAXLEN
ID %Library.BigInt (null) (null)
s1 %Library.String SQLUPPER 50
s2 %Library.Username SQLUPPER 160
s3 dc.Username SQLUPPER 160
x__classname %Library.RawString (null) (null)

select INDEX_NAME,FIELDS from %Library.SQLCatalog_SQLIndices('dc.a')

INDEX_NAME FIELDS
is1 $$SQLUPPER({dc.a.s1})
is2 $$SQLUPPER({dc.a.s2})
is3 $$SQLUPPER({dc.a.s3})

USER>##class(dc.a).Test()
^dc.aD=2
^dc.aD(1)=$lb("","joefu","joefu","joefu")
^dc.aD(2)=$lb("","JoeFu","JoeFu","JoeFu")
^dc.aI("is1"," JOEFU",1)=""
^dc.aI("is1"," JOEFU",2)=""
^dc.aI("is2"," JOEFU",1)=""
^dc.aI("is2"," JOEFU",2)=""
^dc.aI("is3"," JOEFU",1)=""
^dc.aI("is3"," JOEFU",2)=""

Vitaliy Serdtsev · Feb 28, 2025 go to post

See Class Reference: Class %Stream.FileBinaryGzip Extends FileBinary Class %Stream.FileBinary Extends %Stream.Object

Hence %Stream.FileBinaryGzip is already the heir of %Stream.Object.

Vitaliy Serdtsev · Feb 14, 2025 go to post

It seems to me that there is a typo in the TestStartBottomLeft method:

should be  Do $$$AssertEquals(##class(codeGolf.ClockwiseWord).Solution(.matrix, 3, 1), "781234569")

Vitaliy Serdtsev · Feb 4, 2025 go to post

I was interested and I decided to check:

USER>w $zv
IRIS for Windows (x86-64) 2024.3 (Build 217U) Thu Nov 14 2024 17:59:58 EST
USER>d $System.Python.Shell()
 
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>>
Vitaliy Serdtsev · Feb 4, 2025 go to post

Only InterSystems developers can fix the generated code. To do this, contact the WRC. You and I can only work around the bug by rewriting the query.

Vitaliy Serdtsev · Feb 4, 2025 go to post

I installed Python 3.12.8 (x64) and configured it according to the documentation (link is given above)

Everything is working fine:

USER>do $System.Python.Shell()
 
Python 3.12.8 (tags/v3.12.8:2dc476b, Dec  3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>>

By the way, I didn't touch PythonPath.

Vitaliy Serdtsev · Feb 4, 2025 go to post

Please note the following warning:

Important:

There are known incompatibilities between InterSystems IRIS and Python 3.13, so you are advised to avoid Python 3.13 at this time. This issue will be addressed in an upcoming version of InterSystems IRIS.

Vitaliy Serdtsev · Jan 28, 2025 go to post

Yes, these are fields that will either be inserted or updated.

PS:
In fact, the following query should work correctly:

INSERT OR UPDATE myTable SET name='Omer',  counter NVL(counter,0) + 1 

But unfortunately, the SQL engine generates code where an undefined variable is accessed, so the <UNDEFINED> error occurs.
Try contacting WRC for a fix.

Vitaliy Serdtsev · Jan 27, 2025 go to post

The query can be yet simplified:

insert or update myTable(name,counter)
  select
    'Omer',
    nvl((select counter from dc.myTable where name='Omer') + 1, 1)
Vitaliy Serdtsev · Jan 23, 2025 go to post

And if so?

insert or update myTable(name,counter)
  select
    'Omer',
    case
      when exists(select * from myTable where name='Omer')
        then (select counter from myTable where name='Omer') + 1
      else 1
    end

The "name" field is assumed to be unique.

Vitaliy Serdtsev · Dec 23, 2024 go to post
 

Simple test

Class dc.test Abstract ]
{

ClassMethod Stream2BytesArray1(stream As %Stream.ObjectAs %SYS.Python Language python ]
{
  stream.Rewind()
  s = ""
  while not stream.AtEnd:
    r = stream.Read(1000000)
    s += r
  b = bytearray()
  b.extend(map(ord, s))
  return b
}

ClassMethod Stream2BytesArray2(stream As %Stream.ObjectAs %SYS.Python Language python ]
{
  import iris

  maxlen = iris.system.SYS.MaxLocalLength()
  b = bytearray()

  stream.Rewind()
  while not stream.AtEnd:
    b.extend(iris._SYS.Python.Bytes(stream.Read(maxlen)))
  return b
}

ClassMethod Stream2BytesArray3(stream As %Stream.ObjectAs %SYS.Python
{
  set maxlen $$$MaxLocalLength,
      $SYSTEM.Python.Builtins().bytearray()

  do stream.Rewind()
  while 'stream.AtEnd {do b.extend($system.Python.Bytes(stream.Read(maxlen)))}
  return b
}

/// d ##class(dc.test).Test()
ClassMethod Test()
{
  builtin=$system.Python.Builtins(),
    maxstr=$tr($j("",$$$MaxStringLength)," ","0"),
    stream=##class(%GlobalBinaryStream).%New()
  i=1:1:7 stream.Write(maxstr)
  "Stream.Size=",stream.Size,!
  
  n=1:1:3 {
    fn="Stream2BytesArray"_n,t=$zh,r=$CLASSMETHOD($this,fn,stream),t=($zh-t)_" s."
    w $$$FormatText("%1 len(r)=%2 time=%3",fn,builtin.len(r),t),!
  }
}

}
USER>##class(dc.test).Test()
Stream.Size=25488008
Stream2BytesArray1 len(r)=25488008 time=.752708 s.
Stream2BytesArray2 len(r)=25488008 time=.14895 s.
Stream2BytesArray3 len(r)=25488008 time=.080003 s.

The numbers speak for themselves.

Vitaliy Serdtsev · Dec 18, 2024 go to post

ClassMethod Stream2BytesArray(stream As %Stream.ObjectAs %SYS.Python
{
  
set builtin $SYSTEM.Python.Builtins()

  set builtin.bytearray()

  do stream.Rewind()
  
while 'stream.AtEnd {
    
set $system.Python.Bytes(stream.Read($$$MaxLocalLength))
    
do b.extend(r)
  
}
  
quit b
}

Vitaliy Serdtsev · Aug 14, 2024 go to post
 

size = 59 (does not depend on the "k" flag)

ClassMethod ascii()
{
 i=32:1:126 w:^oddDEF($this,"m","ascii",30,1)'[$c(i) *i
}
 

size = 76 (+without the "for" loop)

ClassMethod ascii()
{
 w $tr(##class(%Net.SMTP).#PrintableAscii,^oddDEF($this,"m","ascii",30,1))
}
Vitaliy Serdtsev · Aug 9, 2024 go to post

Judging by this code, I probably did not fully understand the conditions of the task. So:

  1. the source code of the method = " i=0,27,0:1:94 %code.Write($c(i+32)) ", size = 42
  2. the following characters are not found in the source code of the method:
    !"#&'*-/568;<>?@ABCDEFGHIJKLMNOPQRSTUVXYZ[]^_`abghjklmnpqsuvwxyz{|}~
  3. the method should print the characters from point 2
  4. I did not find it in the task conditions [CodeMode = objectgenerator]
Where did I go wrong?

Vitaliy Serdtsev · Aug 9, 2024 go to post

I would like to draw your attention to a number of points:

  • this code will work correctly only when the compilation flag "k" is enabled, otherwise $TEXT will not return anything.
    k - Keep source. When this flag is set, source code of generated routines will be kept.
  • this code will not work correctly in Caché, because there the label name will be "zascii", non "ascii"
  • if you look at the generated INT code, you can see the "}" character at the end, which will return $t(ascii+1), which will lead to an incorrect result
    ascii() methodimpl {
     i=32:1:126 w:$t(ascii+1)'[$c(i) *}