Eduard Lebedyuk · May 24, 2020 go to post

So should this be reported as a bug ?

Yes, please do.

This probably means the pythonbind interface is not doing some conversions that the ODBC and JDBC drivers are doing ?

Probably. Python Native API and xDBC are the recommended approaches to use with InterSystems IRIS.

Eduard Lebedyuk · May 24, 2020 go to post

Does this query work?

SELECT
    DatabaseName,
    Directory,
    MaxSize,
    Size,
    ExpansionSize,
    Available,
    Free,
    DiskFreeSpace,
    Status,
    SizeInt,
    TO_NUMBER(TOCHAR(AvailableNum)) AvailableNum,
    DiskFreeSpaceNum,
    ReadOnly
FROM SYS.Database_FreeSpace('*')
Eduard Lebedyuk · May 23, 2020 go to post

.xlsx file, manipulates the file (in COS)

How are you manipulating xlsx in InterSystems ObjectScript?

Eduard Lebedyuk · May 22, 2020 go to post

For a better http performance

  • Install dedicated web server
  • Configure it for your workflow
  • Maybe move web gateway/web server to a separate server
Eduard Lebedyuk · May 19, 2020 go to post

What does

write $SYSTEM.Util.GetEnviron("JAVA_HOME")

return in the same process as JavaGateway?

If not /usr/java/jdk1.8.0_65 you might need to restart the InterSystems IRIS instance.

Your OS user can be determined by running:

write $system.Process.UserName()

again it's important to run this code in the same process as Java Gateway.

After you determined effective OS username you can check folder/executable permissions.

Finally, SELinux if enabled might require additional configuration.

Eduard Lebedyuk · May 17, 2020 go to post

You can use this macro to translate class name into table name.

set table = ##class(%CSP.UI.Portal.SQL.Home).Quoter2($$$ClassSQLTable(class))

It's faster (no object access) and quotes table name if required.

Eduard Lebedyuk · May 17, 2020 go to post

If records are never deleted and you're okay with a few misses, use ExtentSizeFast, if you need the fastest precise runtime implementation use ExtentSize, in you need better compile speed and don't care about runtime speed use GetExtentSize.

/// w ##class(Utils.Persistent).GetGlobal("Utils.Persistent")
ClassMethod GetDataGlobal(Class As %Dictionary.CacheClassname) As %String
{
    Quit:'$$$comClassDefined(Class) ""
    Set Strategy = $$$comClassKeyGet(Class, $$$cCLASSstoragestrategy)
    Quit $$$defMemberKeyGet(Class, $$$cCLASSstorage, Strategy, $$$cSDEFdatalocation)
}

/// w ##class(Utils.Persistent).ExtentSizeFast("Utils.Persistent")
ClassMethod ExtentSizeFast(Class As %Dictionary.CacheClassname) As %String [ CodeMode = expression ]
{
$Get(@..GetDataGlobal(Class), 0)
}


/// w ##class(Utils.Persistent).GetExtentSize("Utils.Persistent")
ClassMethod GetExtentSize(Class As %String) As %Integer
{
    Set Global = ..GetDataGlobal(Class)
    Quit:Global="" 0
   
    Set Id = $Order(@Global@(""))
    Set Count = 0
    While Id '= "" {
        Set Id = $Order(@Global@(Id))
        Set Count = Count + 1
    }
    Quit Count
}

ClassMethod ExtentSize() As %Integer [ CodeMode = objectgenerator ]
{
    set Strategy = $$$comClassKeyGet(%classname, $$$cCLASSstoragestrategy)
    set Global = $$$defMemberKeyGet(%classname, $$$cCLASSstorage, Strategy, $$$cSDEFdatalocation)
    Do %code.WriteLine(" Set Id = $Order(" _ Global _ "(""""))")
    Do %code.WriteLine(" Set Count = 0")
    Do %code.WriteLine(" While Id '= """" {")
    Do %code.WriteLine("     Set Id = $Order(" _ Global _ "(Id))")
    Do %code.WriteLine("     Set Count = Count + 1")
    Do %code.WriteLine(" }")
    Do %code.WriteLine(" Quit Count")
    Quit $$$OK
}
Eduard Lebedyuk · May 17, 2020 go to post
set user = $username
set role = "MyOperation"
set sc = ##class(EnsLib.Workflow.UserDefinition).CreateUser(user)
set sc = ##class(EnsLib.Workflow.RoleDefinition).CreateRole(role)
set sc = ##class(EnsLib.Workflow.RoleDefinition).AddUserToRole(role, user)

Export role/user globals as xml.

Eduard Lebedyuk · May 15, 2020 go to post

Great article.

Is it available for InterSystems IRIS?

Some projects make use of dynamic objects and it would be great to show them in Visual Trace.

Eduard Lebedyuk · May 14, 2020 go to post

You can use JDBC gateway via Interoperability productions (EnsLib.SQL package).

How are you using ODBC in InterSystems ObjectScript?

Eduard Lebedyuk · May 13, 2020 go to post

You need the c flag

write $SYSTEM.OBJ.Load("C:\InterSystems\HealthShare_2\opt\contenedor\zpm-0.2.2.xml", "c")

But as @Evgeny Shvarov said you'll need InterSystems IRIS for zpm to work.

Eduard Lebedyuk · May 12, 2020 go to post

$STORAGE is a special variable which contains the number of bytes available for a current process. After it hits zero you get STORE error. You can profile your code to see which part leaks memory. Small example:

write $STORAGE
>268326112
set i=1
write $STORAGE
>268326104
kill i
write $STORAGE
>268326112

Check that:

  • $storage before and after EvaluateClone call is the same
  • $storage on each loop cycle is the same

Another approach is throwing/catching and logging an exception and checking what's available in each frame.

do clone.Children.RemoveAt(key) // update clone

RemoveAt returns oref, maybe you need to kill it.

I'm wondering if IS has a java-like garbage collector (as in "the object is automatically destroyed"), and if so, is this keeping up with the clone construction and killing, over a 200k+ loop? Is it an immediate thing, or is there a garbage collector crawling around looking for un-referenced objects?

InterSystems products have automatic garbage collector. I'm not sure on the specifics. Calling @Daniel.Pasco.

Eduard Lebedyuk · May 12, 2020 go to post

You can use Java Gateway and this project.

On a first overview this looks like a container specification with standard crypto algorithms. So you can definitely implement it in InterSystems IRIS. I have done Xades implementation for InterSystems IRIS and it's doable (500 sloc total).

Eduard Lebedyuk · May 9, 2020 go to post

Idea for contestants.

Julyter Notebooks kernel for InterSystems ObjectScript.

Recently I developed bidirectional integration for Jupyter Notebooks. It allows you to create intelligent Business Processes with Python activities. Here's the code (it uses Native API for Python and there's less than a 1000 sloc in the whole integration). Here's some screenshots:

However, as you see currently only BPLs with Python are supported.

The idea for the app is simple - to do the reverse - add the ability for Julyter Notebooks to execute InterSystems ObjectScript code.

Why? It's a great tool for quick prototyping and demos!

How? Using Native API develop a wrapper kernel for InterSystems ObjectScript. Essentially all you need to do is to execute arbitrary string of code and return result. Check WebTerminal source code (by @Nikita.Savchenko7047) to see how a similar application works.

Docs:

Eduard Lebedyuk · May 4, 2020 go to post

As second argument defaults to 1 and third can be skipped you can write just:

if $e(chunk)=""""{
}
Eduard Lebedyuk · Apr 30, 2020 go to post

There's a workaround for import:

  Set dynObj = {}.%FromJSON(jsonStream)
  Set hexStream = dynObj.%Get("hex_stream",,"stream")
  Set base64Stream = dynObj.%Get("base64_stream",,"stream")
 
  Set dynObj."hex_stream" = ""
  Set dynObj."base64_stream" = ""
  Do dynObj.%Remove("hex_stream")
  Do dynObj.%Remove("base64_stream")
 
  Set newObject = ..%New()
  Set newObject.HexStream = hexStream
  Set newObject.Base64Stream = base64Stream
 
  Set tSC = newObject.%JSONImport(dynObj)
Eduard Lebedyuk · Apr 30, 2020 go to post

Try

$$$TRACE("LastChecked value is: '" _ LastChecked _ "', compare: " _ (LastChecked="undefined"))
Eduard Lebedyuk · Apr 30, 2020 go to post

You can add this to your code

$$$TRACE("LastChecked value is: '" _ LastChecked _ "'")

to get LastChecked value.

Eduard Lebedyuk · Apr 30, 2020 go to post

Does not work for me:

d ##class(dc.test).Test()
^dc.testD=5
^dc.testD=5
 
PYTHON>w $zv
IRIS for Windows (x86-64) 2020.1 (Build 215U) Mon Mar 30 2020 20:14:33 EDT