Nova postagem

Pesquisar

Artigo
· Mar. 21, 2024 2min de leitura

Left Side Functions in ObjectScript

In ObjectScript you have a wide collection of functions that return some value
typically:

set variable = $somefunction(param1,param2, ...)

There is nothing special about that.
But there is a set of functions that I classify as LEFT SIDED 
The specialty of them is that you can use them also on the left of the equal operator 
as a target in the SET command:

set $somefunction(param1,param2, ...) = value

The reason to raise that subject is that with IRIS 2024.1 there is after may years  a "new kid on this block"

$VECTOR()

Assigns, returns, and deletes vector data at specified positions
especially
set $VECTOR(MyVector , position , type) = value

I do not want to elaborate on the details. The documentation is really complete.
There are also 3 other new vector-related right sided functions 
$VECTORDEFINED (),  $VECTOROP(), $ISVECTOR()  
You find the description following the links.

If you follow the examples in the documentation, you see that the new related
SQL Function TO_VECTOR () does pretty much the same in SQL notation
(actually it's not visible in InterSystems SQL Reference )

As a reminder / overview a list of the traditional left side functions:

  • $BIT – Returns and or sets the bit value of a specified position in a bitstring.
  • $EXTRACT – Extracts a substring from a character string by position, or replaces a substring by position.
  • $LIST – Returns or replaces elements in a list.
  • $PIECE – Returns or replaces a substring, using a delimiter.
  • $WEXTRACT – Extracts a substring from a character string by position, or replaces a substring by position, recognizing surrogate pairs.

It's a short list but can be highly efficient in some cases to avoid duplicated content and confusing manipulations.

3 Comments
Discussão (3)3
Entre ou crie uma conta para continuar
Artigo
· Mar. 21, 2024 2min de leitura

IRIS 向量搜索

这是在 IRIS 中完全运行向量搜索演示的尝试。
没有外部工具,您需要的只是终端/控制台和管理门户。
特别感谢Alvin Ryanputra作为他的软件包iris-vector-search的基础
灵感和测试数据的来源。
我的软件包基于 IRIS 2024.1 版本,需要注意您的处理器功能。

我尝试用纯 ObjectScript 编写演示。
仅描述向量的计算是在嵌入式Python中完成的

计算 2247 个记录的 384 维向量需要时间。
在我的 Docker 容器中,它正在运行 01:53:14 来完全生成它们。

然后被警告了!
所以我将这一步调整为可重入,以允许暂停向量计算。
每 50 条记录,您就会收到一次停止的提议。

该演示如下所示:

用户>做^A.DemoV

 测试向量搜索
=============================
1 - 初始化表
2 - 生成数据
3 - VECTOR_余弦
4 - VECTOR_DOT_产品
5 - 制作苏格兰威士忌
6 - 加载 Scotch.csv
7 - 生成向量
8 - 向量搜索
选择功能或 * 退出:8

 默认搜索:
让我们来看看前三名价格低于 100 美元的苏格兰威士忌,具有泥土和奶油的香气,
更改价格限制[100]:50
更改短语[泥土和奶油味]:泥土味 

计算搜索向量
  
总计低于 50 美元:222 

ID 价格 名称
1990 年 40 瓶 Wemyss 复古麦芽威士忌“泥炭烟囱”,8 年陈酿,40%
1785 39 著名的禧年,40%
1868 40 托马汀,15 岁,43%
2038 45 格伦·格兰特,10 岁,43%
1733 29 斯凯岛,8 岁,43% 5 行受影响


- 您可以在步骤 1..4 中看到 Vectors 的基本功能
- 步骤 5..8 与我从 Alvin 借用的搜索示例相关
- 步骤 6(导入测试数据)是直接的 ObjectScript
SQL LOAD DATA 对于输入 CSV 中的不规则性过于敏感

我建议也遵循管理门户中的示例来观察向量如何运行。

GitHub

1 Comment
Discussão (1)0
Entre ou crie uma conta para continuar
Artigo
· Mar. 21, 2024 2min de leitura

VECTOR inside IRIS

This is an attempt to run a vector search demo completely in IRIS
There are no external tools and all you need is a Terminal / Console and the management portal.
Special thanks to Alvin Ryanputra as his package iris-vector-search that was the base
of inspiration and the source for test data.
My package is based on IRIS 2024.1 release and requires attention to your processor capabilities.

I attempted to write the demo in pure ObjectScript.
Only the calculation of the description_vectoris done in embedded Python

Calculation of a vector with 384 dimensions over 2247 records takes time.
In my Docker container, it was running 01:53:14 to generate them completely.

You have been warned!
So I adjusted this step to be reentrant to allow pausing vector calculation.
Every 50 records you get an offer to have a stop. 

The demo looks like this:

USER>do ^A.DemoV

      Test Vector Search
=============================
     1 - Initialize Tables
     2 - Generate Data
     3 - VECTOR_COSINE
     4 - VECTOR_DOT_PRODUCT
     5 - Create Scotch
     6 - Load Scotch.csv
     7 - generate VECTORs
     8 - VECTOR search
Select Function or * to exit : 8

      Default search:
Let's look for TOP 3 scotch that costs less than $100,
 and has an earthy and creamy taste
     change price limit [100]: 50
     change phrase [earthy and creamy taste]: earthy 

 calculating search vector
  
     Total below $50: 222 

ID      price   name
1990    40      Wemyss Vintage Malts 'The Peat Chimney,' 8 year old, 40%
1785    39      The Famous Jubilee, 40%
1868    40      Tomatin, 15 year old, 43%
2038    45      Glen Grant, 10 year old, 43%
1733    29      Isle of Skye, 8 year old, 43% 5 Rows(s) Affected


- You see the basic functionalities of Vectors in steps 1..4
- Steps 5..8 are related to the search example I borrowed from Alvin
- Step 6 (import of test data) is straight ObjectScript
  SQL LOAD DATA was far too sensible for irregularities in the input CSV

I suggest following the examples also in MGMT portal to watch how Vectors operate.

GitHub
 

11 Comments
Discussão (11)5
Entre ou crie uma conta para continuar
Artigo
· Mar. 18, 2024 5min de leitura

コンソールログに"There exists a MISMATCH.WIJ file" が記録され、インスタンスの開始ができない時の対処法

これは InterSystems FAQ サイトの記事です。
 

インスタンスの開始が失敗し、コンソールログに"There exists a MISMATCH.WIJ file"が記録されている場合、何らかのシステム障害の影響でデータベースの整合性に関して問題が生じていることを示しています。

このような状況が発生した際にインスタンスの開始ができるようにするためには、以下の手順を実施します。

(1) a. インスタンスをNOSTUモードで起動
(2) b. データベースの整合性チェック

◆(2)の整合性チェックでエラーを検出しなかった場合、
 (3) d. MISMATCH.WIJ ファイルのリネーム
 (4) e. インスタンスの再起動
を実施します。

◆(2)の整合性チェックでエラーが検出された場合は、
 (3) c. MISMATCH.WIJファイルの適用
 (4) b. データベースの整合性チェック
 (5) d. MISMATCH.WIJファイルのリネーム
 (6) e. インスタンスの再起動
を実施します。 

以下に各手順の詳細を説明します。 

a. インスタンスをNOSTUモードで起動します。

NOSTUで開始する(Caché)

NOSTUで開始する(IRIS)

b. データベースの整合性チェック

STURECOV ルーチンを実行してデータベースの整合性チェックを行います。

%SYS>do ^STURECOV
Logins are not disabled.
This routine is designed to run when Cache' is in single user mode due to a problem running the STU startup routine.
Do you want to continue ? No => yes
Warning: Misuse of this utility can harm your system
There is no record of any errors during the prior startup
This could be because there was a problem writing the data to disk or because the system failed to start for some otherreason.
Do you want to continue ? No => yes
Enter error type (? for list) [^] => MISMATCHWIJ

1) List Affected Databases and View Blocks
2) Apply mismatched blocks from WIJ to databases 
3) Rename MISMATCH.WIJ         
4) Dismount a database
5) Mount a database
6) Database Repair Utility
7) Check Database Integrity
8) Bring down the system prior to a normal startup
--------------------------------------------------------------
H) Display Help
E) Exit this utility
--------------------------------------------------------------
Enter choice (1-8) or [Q]uit/[H]elp? 7
This utility is used to check the integrity of a database and the pointer structure of one or more globals.
Output results on
Device: Integrity_STURECOV.log        整合性チェックの結果をログファイルに出力します
Parameters? "WNS" =>
Stop after any error?  No=>
Do you want to check all databases?  No=> Yes
Checking c:\intersystems\irishealth\mgr\ at 23:09:20
Checking c:\intersystems\irishealth\mgr\enslib\ at 23:09:21
Checking c:\intersystems\irishealth\mgr\hscustom\ at 23:09:22
Checking c:\intersystems\irishealth\mgr\hslib\ at 23:09:23
Checking c:\intersystems\irishealth\mgr\hssys\ at 23:09:31
Checking c:\intersystems\irishealth\mgr\irisaudit\ at 23:09:31
Checking c:\intersystems\irishealth\mgr\irislib\ at 23:09:31
Checking c:\intersystems\irishealth\mgr\irislocaldata\ at 23:09:33
Checking c:\intersystems\irishealth\mgr\iristemp\ at 23:09:33
Checking c:\intersystems\irishealth\mgr\test\ at 23:09:33
Checking c:\intersystems\irishealth\mgr\user\ at 23:09:34
--------------------------------------------------------------
1) List Affected Databases and View Blocks
2) Apply mismatched blocks from WIJ to databases
3) Rename MISMATCH.WIJ
4) Dismount a database
5) Mount a database
6) Database Repair Utility
7) Check Database Integrity
8) Bring down the system prior to a normal startup
--------------------------------------------------------------
H) Display Help
E) Exit this utility
--------------------------------------------------------------
Enter choice (1-8) or [Q]uit/[H]elp?

 

出力されたログファイルの末尾に "No Errors were found." と記録されていれば整合性チェックでエラーは検出していません。

 

c. MISMATCH.WIJファイルの適用

STURECOV ルーチンよりMISMATCH.WIJファイルを適用します。

--------------------------------------------------------------
1) List Affected Databases and View Blocks
2) Apply mismatched blocks from WIJ to databases 
3) Rename MISMATCH.WIJ         
4) Dismount a database
5) Mount a database
6) Database Repair Utility
7) Check Database Integrity
8) Bring down the system prior to a normal startup
--------------------------------------------------------------
H) Display Help
E) Exit this utility
--------------------------------------------------------------
Enter choice (1-8) or [Q]uit/[H]elp? 2

d. MISMATCH.WIJ ファイルのリネーム
 

STURECOV ルーチンよりMISMATCH.WIJファイルをリネームします。

 

--------------------------------------------------------------
1) List Affected Databases and View Blocks
2) Apply mismatched blocks from WIJ to databases 
3) Rename MISMATCH.WIJ         
4) Dismount a database
5) Mount a database
6) Database Repair Utility
7) Check Database Integrity
8) Bring down the system prior to a normal startup
--------------------------------------------------------------
H) Display Help
E) Exit this utility
--------------------------------------------------------------
Enter choice (1-8) or [Q]uit/[H]elp? 3

e. インスタンスの再起動

STURECOV ルーチンよりインスタンスを停止後、インスタンスをランチャー等より通常起動します。

--------------------------------------------------------------
1) List Affected Databases and View Blocks
2) Apply mismatched blocks from WIJ to databases
3) Rename MISMATCH.WIJ
4) Dismount a database
5) Mount a database
6) Database Repair Utility
7) Check Database Integrity
8) Bring down the system prior to a normal startup
--------------------------------------------------------------
H) Display Help
E) Exit this utility
--------------------------------------------------------------
Enter choice (1-8) or [Q]uit/[H]elp? 8

MISMATCH.WIJの適用処理が正常終了しない、またはインスタンスの再開始後の整合性チェックでエラーがある場合は、カスタマーサポートセンターまでお問い合わせください 

WIJ ブロック比較
 

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· Mar. 18, 2024 2min de leitura

Getting data from InterSystems IRIS CloudSQL using xDBC

Recently, the question came up while discussing the access to the data stored in IRIS from different languages with my students if it was possible to initiate the connection and get data from Cloud solution (InterSystems IRIS CloudSQL) from Microsoft Excel, not the other way around. Considering the many varied ways one can get data in Excel (import data from external sources, connecting to databases using ODBC drivers, using power queries and web queries etc.) the obvious choice was to try ODBC driver. The only task left was to try to connect to the database in the cloud using the ODBC driver.

Quite unsurprisingly, it worked!

If you're new to CloudSQL, I would highly suggest you read the documentation. From it you will be able to get access to the InterSystems Cloud Services Portal (or you can go directly to AWS and subscribe with your AWS account) and download necessary drivers. BTW, if you encounter problems with CloudSQL, you may try to look for answers in this document first.

Now that these preliminaries are out of the way, let's try the simplest approach - setting up the ODBC data source with just a password and getting data from it in MS Excel.

Step 0. Set up your InterSystems IRIS CloudSQL. You will see the necessary settings on the Overview page of your Deployment:

Step 00. Download and install ODBC driver for your OS.

Step 1. Open your ODBC Data Sources and switch to System DSN tab. In it, click on Add...

and fill in the settings from your Overview page (first screenshot of the article).

Step 2. Connect Excel to IRIS. Open Excel, navigate to the Data tab, and select "Get Data" or "From Other Sources," depending on your Excel version. Choose "From ODBC" as the data source

select the ODBC data source you configured earlier

enter authentication credentials if asked

and choose the table you wish to load into Excel

Step 3. You're good to go and do whatever with your data

PS. Some other interesting articles/videos that I would suggest you read/watch regarding ODBC and CloudSQL:

  • a whole series of videos that show how to connect to CloudSQL from solutions written in different languages
  • an interesting article on how to set up roles and give permissions to xDBC connections
  • another article on how to use SSL/TLS to establish secure connections over JDBC and other driver technologies
  • and the last one about switching between ODBC drivers in an environment with multiple versions installed
4 Comments
Discussão (4)2
Entre ou crie uma conta para continuar