Rechercher

Article
· Mars 24, 2024 5m de lecture

Quickstart guide to IRIS DB on Linux Systems

Introduction

This is a quickstart guide to IRIS for Linux systems administrators who need to be able to support the IRIS DB as well as other normal infrastructure tasks.

IRIS is a DB system from Intersystems. An IRIS DB can hold code (in the form of a Class) or data (in the form of Globals). IRIS DB are Linux files called IRIS.DAT.

IRIS was previously called Cache. There may be some references to Cache in the Intersystems documentation or forums or in some of your system documentation.

IRIS classes are coded in language call ObjectScript. IRIS classes have properties and methods.

IRIS classes can be run as interactive jobs or as scheduled tasks all within IRIS.

 

IRIS code can be in terms of a procedure.

 

IRIS DBs are typically journalled in case transactions need to be rolled back or DBs need to be recovered from a backup via a rolled forward process.

 

IRIS DBs can be mirrored to provide a level of redundancy across 2 servers. If DBs are mirrored then the transaction updates must be committed to both mirror members before the application is advised that the update is successful. Intersystems terms the mirror members as “failover members”. One of the failover members is termed the PRIMARY and the other member is termed BACKUP.

 

There is also an arbiter node(server) so that there is a quorum. Quorum members “vote” as to which failover member has failed.

 

There can be a asynchronous mirror node. The asynchronous mirror node is updated on a store and forward basis from journals.

 

IRIS DB has a product called Ensemble that supports productions. There can be only one production per name space. Ensemble can be used to develop applications using a concept of Services (input queues), Processes (how to process the input queue) and Operations (output queue).

 

IRIS DB has a product called JReports for developing reports. The development of reports is intended to be like Crystal reports.

 

Interacting with IRIS

You can connect to IRIS with:

iris session <instance name>

 

You can find out how many instances there are defined on your system:

iris list

 

You can also connect to IRIS via the Management Portal which is GUI/web based.

 

There is also a command like interface called WebTerminal which is often installed.

 

IRIS is configured via a configuration/parameter file typically called iris.cpf.

The iris.cpf file will show the location of the IRIS.DAT file for each defined database. The iris.cpf file will also show the mirror configuration.

 

Namespace vs DB

DB files by convention live in a directory that has the name of the DB itself.

 

Namespace are a logical concept that stores data or code.

 

A namespace provides access to data and to code, which is stored (typically) in multiple databases. Databases (IRIS.DAT) are the physical manifestation of the namespace.

 

All InterSystems IRIS systems will have a namespace of “%SYS” and “USER”. There are other default namespaces:

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GORIENT_enviro#GORIENT_enviro_namespace_system

 

Journalling

Journal records are written to journal files which are located on one of 2 directories/filesystems – a primary and secondary area. When the primary area is full then journals will be written to the  secondary area. When the secondary area is full then journals will be written to the  primary area.  When the primary area is full then journals will be written to the  secondary area….

Journal files are switched when backups start, backups finish, under operator control or when the configured journal size is exceeded.

When both journal areas are full then all transactions stop.

There is usually a scheduled task that deletes old journal based on the age (number of days prior to today) or the number of previous backups. The default is 2 days old or 2 backups completed. 

 

 

Objectscript

These are some basic commands:

DO <- run a class method or procedure that is stored in the namespace/database

SET <- assign a value to a variable. Variable can be set to a literal or output from a method or class property. Variables do not need to be declared.

KILL <- deletes a variable

WRITE <- write text or variable contents or combination

 

Variable names are case-sensitive.

 

If the variable name starts with a ^ then it is a global. Global are multi dimensional storage areas. Where the variable is a global (variable name starting with ^) this structure is written persistently to the namespace then to the database(s).

Intersystems documentation says:

In InterSystems IRIS, a database contains globals and nothing else; even code is stored in globals. At the lowest level, all access to data is done via direct global access — that is, by using commands and functions that work directly with globals.”

 

All other variables only exist in current user session.

 

If the name with DO  starts with a ^ then it is a procedure. For example

DO ^MIRROR

DO ^JOURNAL

 

ZN “%SYS” <- Change namespace

set status=##class(%SYS.Journal.System). GetState() <- Get the journal status

write $CASE(status,                                                          <- Print the journal status using a case statement

            0:"Enabled",1:"Disabled",2:"Suspended",

            3:"Frozen",4:"Paused")

 

List all namespaces

DO ##class(%SYS.Namespace).ListAll(.result)

zwrite result

1 Comment
Discussion (1)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Mars 24, 2024 3m de lecture

What more can be done with lists in SQL (%DLIST, %INLIST, FOR SOME)

What I find really useful about IRIS when teaching my subject of Postrelational databases is the fact that it is a multi model database. Which means that I can actually go into architecture and structure and all that only once but then show the usage of different models (like object, document, hierarchy) using the same language and approach. And it is not a huge leap to go from an object oriented programming language (like C#, Java etc) to an object oriented database.

However, along with advantages (which are many) come some drawbacks when we switch from object oriented model to relational. When I say that you can get access to the same data using different models I need to also explain how it is possible to work with lists and arrays from object model in relational table. With arrays it is very simple - by default they are represented as separate tables and that's the end of it. With lists - it's harder because by default it's a string. But one still wants to do something about it without damaging the structure and making this list unreadable in the object model.

So in this article I will showcase a couple of predicates and a function that are useful when working with lists, and not just as fields.

Let's say that we have a class Restaurant.Dish which will have all our dishes:

Class Restaurant.Dish Extends %Persistent
{
Property Name As %String;
Property Description As %String(MAXLEN = 1000);
Property Category As %String;
Property Price As %Float;
Property Currency As %String;
Property Calories As %Integer;
}

Which we somehow populated with data:

And there is a class Restaurant.Account which contains the favourite dishes of the patrons:

Class Restaurant.Account Extends %Persistent
{
Property Name As %Name;
Property FavouriteFood As list Of %String;
}

And it also contains data:

First, let's look at the aggregate function %DLIST. It returns an ObjectScript %List structure containing the values in the specified column as list elements. In general, the syntax is as follows:

%DLIST([ALL | DISTINCT [BY(col-list)]] 
  string-expr 
  [%FOREACH(col-list)] [%AFTERHAVING])

Now, let's say we need to group all the dishes by categories and get a list of all dishes in those categories:

select Category,
       %DLIST(Name) AS AllDishes,
       %DLIST(Distinct (Name)) AS AllDistinctDishes
  from Restaurant.Dish
GROUP BY Category
ORDER BY Category

Another one is a predicate condition %INLIST. It matches a value to the elements in a %List structured list. It resembles the predicate IN but expects to get a $LB as an argument, instead of a values, separated by comas. Its syntax is as follows:

scalar-expression %INLIST list [SIZE ((nn))]

For example, now we want to see what dishes out of favourites of our patrons we have on a menu:

select Name, Description, Price
  from Restaurant.Dish
WHERE name %INLIST (select FavouriteFood 
                      from Restaurant.Account 
                     where ID = 1)  SIZE ((10))

And the last predicate condition I want to highlight here is FOR SOME %ELEMENT. It matches the list elements in field with the specified predicate. The SOME keyword specifies that at least one of the elements in the field must satisfy the specified predicate clause. The predicate clause must contain either the %VALUE or the %KEY keyword, followed by a predicate condition. These keywords are not case-sensitive. The syntax is as follows:

FOR SOME %ELEMENT(field) [[AS] e-alias] (predicate)

As for the last example, let's say we got a deal for Sprite and Diet Coke and we wish to see if it will have traction with our patrons. 

select *
  from Restaurant.Account 
 where FOR SOME %ELEMENT(FavouriteFood) f
     (f.%VALUE IN ('Sprite','Diet Coke') and %KEY IS NOT NULL)

So this is just to attract your attention to these 3 possibilities of working with lists in SQL. For further details, please visit the documentation pages I referenced in the article. And of course, you can always use built-in functions when working with $lb in SQL.

2 Comments
Discussion (2)1
Connectez-vous ou inscrivez-vous pour continuer
Question
· Mars 23, 2024

FHIR Data not return content

Hi,

I found an issue while fetching records from FHIR DB, I am getting below error thou FHIR repository have the records with the corresponding id

{

    "resourceType": "OperationOutcome",

    "issue": [

        {

            "severity": "error",

            "code": "not-found",

            "diagnostics": "<HSFHIRErr>ResourceNotFound",

            "details": {

                "text": "No resource with type 'Appointment' and id '21'"

            }

        }

    ]

}

5 Comments
Discussion (5)2
Connectez-vous ou inscrivez-vous pour continuer
Article
· Mars 21, 2024 2m de lecture

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
Discussion (1)0
Connectez-vous ou inscrivez-vous pour continuer
Article
· Mars 18, 2024 6m de lecture

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

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

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

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

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

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

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

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

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

以下に記載の手順の内、1)および2)の手順まで実行します。

3)以降は実施する必要はありません。

(Cachéの場合は、右括弧なしの1,2,3)

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 ブロック比較
 

注1:

以下のようにシングルユーザーモードで開始されている旨のメッセージが含まれている場合は、この手順は必要ありません。

Cache is started in single user mode.
To log into Cache, type:
    ccontrol session CACHE -B
and D ^STURECOV for help recovering from this error.

以下のように直接シングルユーザーモードでログインし、b.から始めます。

(これらのコマンドのPATHが設定されているか、コマンドの実行イメージの存在する場所で実行する必要があります。)

Windows
 IRIS
 >irisdb -s ..\mgr -B
 Caché
 >cache -s..\mgr -B  
UNIX
 IRIS
 >iris session iris -B
 Caché
 >ccontrol session cache -B
Discussion (0)1
Connectez-vous ou inscrivez-vous pour continuer