Nova postagem

Pesquisar

Pergunta
· Out. 28, 2024

Problem with local (private) IPM registry

I'm trying out the package manager (IPM). I'm trying to create a local (private) registry. To me it looks like the local registry installation succeeded but I can't figure out how to use it.

I'm using latest stable v0.7.3.

I have uploaded one module there (as told in one forum post):

$ curl http://localhost:52774/registry/
{"version":"1.3.2"}
$ curl http://localhost:52774/registry/packages/-/all
[{"name":"objectscript-math","description":"Math library for InterSystems ObjectScript","repository":"https://github.com/psteiwer/ObjectScript-Math/","origin":"","versions":["0.0.5"],"is_owner":0}]

Now trying to use that repository:

zpm:IPMTEST1>list-installed -tree
zpm-registry 1.3.2
└──yaml-utils 0.1.4

zpm:IPMTEST1>repo -list

registry
        Source:                 https://pm.community.intersystems.com
        Enabled?                Yes
        Available?              Yes
        Use for Snapshots?      Yes
        Use for Prereleases?    Yes
        Is Read-Only?           No
        Deployment Enabled?     No

zpm:IPMTEST1>repo -name registry -list-modules
[a long list of modules removed for readability]

zpm:IPMTEST1>repo -name local -remote -url http://localhost:52774/registry/

local
        Source:                 http://localhost:52774/registry/
        Enabled?                Yes
        Available?              No
        Use for Snapshots?      Yes
        Use for Prereleases?    Yes
        Is Read-Only?           No
        Deployment Enabled?     No
zpm:IPMTEST1>repo -list

local
        Source:                 http://localhost:52774/registry/
        Enabled?                Yes
        Available?              No
        Use for Snapshots?      Yes
        Use for Prereleases?    Yes
        Is Read-Only?           No
        Deployment Enabled?     No

registry
        Source:                 https://pm.community.intersystems.com
        Enabled?                Yes
        Available?              Yes
        Use for Snapshots?      Yes
        Use for Prereleases?    Yes
        Is Read-Only?           No
        Deployment Enabled?     No

zpm:IPMTEST1>repo -name local -list-modules

zpm:IPMTEST1>

Why my local repository is not available (Available? No) and why I don't see the objectscript-math module here?

There is also always a significant delay in operations with local repository, like some kind of timeout.

4 Comments
Discussão (4)2
Entre ou crie uma conta para continuar
Artigo
· Out. 28, 2024 2min de leitura

Writing a user-defined aggregate function in IRIS - example: Median

User-defined aggregate functions have been supported in IRIS since 2021.1.0. I'd wished upon a star for these years ago before finding a secret hacky way to override MAX and MIN in a custom datatype, but didn't get a chance to actually try one out until today. I thought it was an interesting experience/example - the question of how to get a Median in IRIS SQL came up once before - so I'm sharing it here without too much further comment.

One caveat: UDAFs don't have the nice object/SQL parity that other types of functions do, so you actually need to run SQL to define the aggregate function (helpfully wrapped in a classmethod in the below example). Compiling the class alone isn't enough.

/// Class implementing a Median aggregate function for IRIS SQL
Class DC.Demo.Median
{

/// Returns a new global ref in IRISTEMP to use to store intermediate results
ClassMethod Initialize() As %String [ PublicList = ref, SqlProc ]
{
	New ref
	Set ref = $Name(^IRIS.Temp.UDAF.Median($Increment(^IRIS.Temp.UDAF.Median)))
	Set @ref = 0
	Quit ref
}

/// Updates temp global for a single record
ClassMethod Iterate(ref As %String, value As %Numeric) As %String [ SqlProc ]
{
	If (value '= "") {
		Do $Increment(@ref)
		Do $Increment(@ref@(+value))
	}
	Quit ref
}

/// Finds the actual median (possibly an average of the two middle values)
ClassMethod Finalize(ref As %String) As %Numeric [ SqlProc ]
{
	Set median = ""
	Set total = @ref
	Set position1 = (total+1)\2
	Set position2 = (total+2)\2
	Set val1 = ""
	Set val2 = ""
	Set reached = 0
	Set key = ""
	For {
		Set key = $Order(@ref@(key),1,refCount)
		Quit:key=""
		set reached = reached + refCount
		if (reached >= position1) && (val1 = "") {
			Set val1 = key
		}
		if (reached >= position2) && (val2 = "") {
			Set val2 = key
		}
		If (val1 '= "") && (val2 '= "") {
			Set median = (val1+val2)/2
			Quit
		}
	}
	Kill @ref
	Quit median
}

/// To actually define the UDAF from an SQL perspective, call this classmethod.
ClassMethod Define()
{
	// Drop the function in case something has changed
	&sql(DROP AGGREGATE DC_Demo.Median)
	&sql(CREATE AGGREGATE DC_Demo.Median(arg NUMERIC) RETURNS NUMERIC
	   INITIALIZE WITH DC_Demo.Median_Initialize
	   ITERATE WITH DC_Demo.Median_Iterate
	   FINALIZE WITH DC_Demo.Median_Finalize)
	$$$ThrowSQLIfError(SQLCODE,%msg)
}

}

Hopefully this helps someone!

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Out. 28, 2024

Exporting Cache data along with the table schema

Hi! I am trying to export Cache data to my SQL database and am trying to export the schema as well.

The Data Export wizard on the Management Portal only allows me to export the data but not the schema. Is there anyway to get the schema exported as well?

4 Comments
Discussão (4)3
Entre ou crie uma conta para continuar
Pergunta
· Out. 28, 2024

IIS Routing Question

I have a question about the routing of IIS.

If I have a javascript application that has a single entry point app.html. Is it possible to configure the IIS server such that both the urls

addr:port/entry1

addr:port/entry2

to provide the same app.html and let the javascript code from application decide what component to load next, depending on the path of the URL ?

My IIS server is configured such that when I do a GET url1, ir tries to send entry1.html , respectively entry2.html when I do GET url2.

In Intersystems documentation I did not find how to configure IIS to route to the same application from multiple paths.

Could somebody help me, please ?

2 Comments
Discussão (2)2
Entre ou crie uma conta para continuar
Resumo
· Out. 28, 2024

Publicações Desenvolvedores InterSystems, Outubro 21 - 27, 2024, Resumo