Pesquisar

Article
· Avr 26, 2024 3m de lecture

Geo Vector Search #2

Technical surprises using VECTORs
>>> UPDATED

Building my tech. example provided me with a bunch of findings htt I want to share.
The first vectors I touched appeared with text analysis and more than 200  dimensions.
I have to confess that I feel well with Einstein's 4 dimensional world.
7 to 15 dimensions populating the String Theory are somewhat across the border.
But 200 and more is definitely far beyond my mathematical horizon.

So I looked to our Globe and found a vector of (latitude,longitude) with 2 dimension is enough for testing.
A handy table of capitals was found and provided sample test data (shortened).

CAPITAL COUNTRY LATITUDE LONGITUDE
Kabul Afghanistan 34.28N 69.11E
Tirana Albania 41.18N 19.49E
Algiers Algeria 36.42N 03.08E
Pago Pago American Samoa 14.16S 170.43W
Andorra la Vella Andorra 42.31N 01.32E
Luanda Angola 08.50S 13.15E
Saint John's Antigua and Barbuda 17.127N 61.846W
Buenos Aires Argentina 36.30S 60.00W
Yerevan Armenia 40.10N 44.31E
Oranjestad Aruba 12.32N 70.02W
Canberra Australia 35.15S 149.08E
Vienna Austria 48.12N 16.22E
Baku Azerbaijan 40.29N 49.56E
Nassau Bahamas 25.05N 77.20W
Manama Bahrain 26.10N 50.30E
Dhaka Bangladesh 23.43N 90.26E
Bridgetown Barbados 13.05N 59.30W
Minsk Belarus 53.52N 27.30E
Brussels Belgium 50.51N 04.21E

#1
 Loading that TAB separated text file with LOAD DATA (SQL) worked perfect

#2
Transforming the geo coordinates int INT was a minor coding exercises
It resulted in a ClassMethod projected as SQL Procedure used inana UPDATE over the table.

#3
As geo coordinates refer to (0°N,0°W) somewhere in the Atlantic this is just a theoretical base for my vectors.
IRIS supports some VECTOR functions but I found no AddVector() or SubtractVector() function.
so this was done "manually" from the input coordinates.
The need arises from transforming coordinates to a useful base point for later comparing vectors
So you see static BASE coordinates and active WORK coordinates.

Getting the Vector's values is easy with SQL using %EXTERNAL() function
while in ObjectScript I ended up with
        set vectorvalues=##class(%Vector).LogicalToOdbc(vectorvariable) 
this was less impressive for working with Vectors.

#4
Similarity is calculated with VECTOR_COSINE() function.
You calculate the angle between 2 Vectors and COSINE norm it between +1 and -1
The input needs 2 Vectors of the same type and same dimension.
Examples as in documentation work fine if you compose your SQL String as suggested
and TO_VETOR(?,type,size) is OK  with  %SQLStatement  for execution.
BUT:
I tried it with embedded SQL.
Code checking signalled some disagreement but compiled without problem
At runtime it turned out that host variables in TO_VECTOR(:myvec,INT,2) failed
whatever combination of quotes, braces, .... I tried.
So be warned. I returned to  %SQLStatement to get my VCOS done.

UPDATE:  TO_VECTOR(:myvec,INT,2)
     set myvec="1314,-7979" 

Nothing special: Just a plain String with comma-separated values
It seems I couldn't believe that simple approach.
My apologizes to ISC Engineering.

#5
It was a surprise to learn how wide VECTOR_COSINE is spreading.
checking the vector Paris >> Bucuresti  traced half of Middle and East Asia.
So limiting the results to > 0.999 is a good practice in this scenario.

Video

GitHub
 

4 Comments
Discussion (4)1
Connectez-vous ou inscrivez-vous pour continuer
Article
· Avr 26, 2024 2m de lecture

Geo Vector Search #1

Geographic use of vector search

The basic idea is to use Vectors in the mathematical sense.
I used geographic coordinates. These are of course only 2-dimensional
but much easier to follow as vectors in text analysis with >200 dimensions.

The example loads a list of worldwide capitals with their coordinates
The coordinates are interpreted as vectors from geographic point 0°N/0 W
(some very wet spot in the Gulf of Guinea, >400 km from the African Coast)
Finding common directions from that spot is a quite theoretical case.
So adjustment to your preferred starting point is implemented.
Now finding similar directions for some target city makes sense.
It's a methematical use of VECTOR_COSINE() function other than text search.

And as this is just 2 dimensional COSINE is just what we (hopefully) learned at school.
So the results are far better to understand: 

  • 1  =  total match, same direction 0° deviation from original
  • 0  = no match at all,  direction points 90° away from original
  • -1 = total opposite direction pointing backward by 180° from original
  •  ~0.999  = quite close to original 

You just get information on the direction, not on the size.
So your vector from Paris to Budapest  points also to Minsk or someplace In Asia

The demo is controlled by a rathrer simple menu:

  Use Geographc Vectors
=========================
     1 - Initialize Tables
     2 - Import Data
     3 - Set Base Location
     4 - Generate Vectors
     5 - Select Target Location
     6 - Show Best Matches
Select Function or * to exit :

for multiple retries, you always restart at

  • #3 set your starting location
  • #4 adjust coordinates to your selected base
  • #5 set your target location  defining your base vector
  • #6 see what's in between or in front of your vector
    • adjust tolerance from -1...+1

GitHub

Video

DemoServer Mgmt Portal
DemoServer WebTerminal
 

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

Lire le code source de la librarie standard ObjectScript.

Bonjour,

 

J'essaie de trouver le code source de la routine WRITE et je n'y arrive pas.

Pourriez vous m'aider ?

 

Cordialement,

 

Alin C Soare.

2 Comments
Discussion (2)2
Connectez-vous ou inscrivez-vous pour continuer
Annonce
· Avr 22, 2024

Beta testers needed for our upcoming InterSystems IRIS SQL Specialist certification exam

Hello IRIS Community,

InterSystems Certification is developing a certification exam for InterSystems IRIS SQL specialists, and if you match the exam candidate description given below, we would like you to beta test the exam. The exam will be available for beta testing on June 9 - 12, 2024 at InterSystems Global Summit 2024, but only for Summit registrants (visit this page to learn more about Certification at GS24). Beta testing will open for all other interested beta testers on June 24, 2024. However, interested beta testers should sign up now by emailing certification@intersystems.com (please let us know if you will be beta testing at Global Summit or in our online proctored environment). The beta testing must be completed by August 2, 2024.

What are my responsibilities as a beta tester?

You will be assigned the exam and will need to take it by August 2, 2024. The exam will be administered in an online proctored environment (live-proctored during Summit), free of charge (the standard fee of $150 per exam is waived for all beta testers), and then the InterSystems Certification team will perform a careful statistical analysis of all beta test data to set a passing score for the exam. The analysis of the beta test results will take 6-8 weeks, and after the passing score is established, you will receive an email notification from InterSystems Certification informing you of the results. If your score on the exam is at or above the passing score, you will have earned the certification! 

Note: Beta test scores are completely confidential.

Exam Details

Exam title: InterSystems IRIS SQL Specialist

Candidate description: An IT professional who uses InterSystems IRIS SQL to:

  • design InterSystems IRIS SQL applications,
  • manage InterSystems IRIS SQL operations,
  • and load and efficiently query datasets in InterSystems IRIS SQL.

Number of questions: 47

Time allotted to take exam: 2 hours

Recommended preparation: Review the content found in the table below before taking the exam

 

Recommended practical experience:

  • Basic experience with standard ANSI SQL
  • 1 to 2 years of experience with designing and managing InterSystems IRIS SQL applications or expertise in other SQL platforms and has 1 year experience with managing InterSystems IRIS SQL applications.

Exam practice questions

set of practice questions is provided here to familiarize candidates with question formats and approaches.

Exam format

The questions are presented in two formats: multiple choice and multiple response. Access to InterSystems IRIS Documentation will be available during the exam. 

DISCLAIMER: Please note this exam has a 2-hour time limit. While InterSystems documentation will be available during the exam, candidates will not have time to search the documentation for every question. Thus, completing the recommended preparation before taking the exam, and searching the documentation only when absolutely necessary during the exam, are both strongly encouraged!

System requirements for beta testing (note that laptops will be provided and configured to meet these requirements at Global Summit)

  • Working camera & microphone
  • Dual-core CPU
  • At least 2 GB available of RAM memory
  • At least 500 MB of available disk space
  • Minimum internet speed:
    • Download - 500kb/s
    • Upload - 500kb/s

Exam topics and content

The exam contains questions that cover the areas for the stated role as shown in the exam topics chart immediately below.

Topic

Subtopic

Knowledge, skills, and abilities

1. Designs InterSystems IRIS SQL applications

 

1. Designs a SQL schema

  1. Identifies role of bitmap extent index
  2. Determines use cases for indexes
  3. Distinguishes use cases for different index types​
  4. Distinguishes primary, unique, and ID keys
  5. Identifies properties for foreign key relationships
  6. Identifies behavior of referential actions for update and delete
  7. Identifies tradeoffs for adding ever more indexes
  8. Identifies use cases for composite indexes

 

2. Designs advanced schemas

  1. Distinguishes the differences between date/time data types

 

3. Loads data

  1. Uses LOAD DATA command
  2. Uses SQL diagnostics tables (%SQL_Diag)
  3. Identifies options for exporting data (physical vs logical)
 

4. Writes business logic

  1. Defines stored procedures
  2. Defines triggers
  3. Identifies language options for writing business logic
 

5. Develops object/relational applications

  1. Recalls default object/relational mapping
  2. Recalls SQL best practices when defining classes
 

6. Deploys SQL applications

  1. Lists mechanisms for deploying SQL applications
  2. Determines what needs to be part of a deployment

2. Uses InterSystems IRIS SQL

1. Manages InterSystems IRIS query processing

  1. List considerations made by the optimizer
  2. Differentiates syntax and runtime errors
  3. Uses Statement Index to find statement metadata
  4. Distinguishes between the use of parameters and constants in a query

 

2. Interprets query plans

  1. Identifies ways to view query plans for a statement
  2. Identifies Full Table Scans in a query plan
  3. Identifies the use of indexes in a query plan
  4. Distinguishes between loops and lookups in a query plan
  5. Distinguishes modules called once vs repeatedly in a query plan
  6. Recalls role of table statistics in query planning
  7. Uses hints to troubleshoot query planning
  8. Identifies opportunities for indexes, based on a query plan
  9. Recalls the meaning of relative cost

 

3. Uses InterSystems IRIS SQL in applications

  1. Defines InterSystems IRIS connections
  2. Identifies prepare/execute steps
  3. Recalls how proper use of parameters can guard against SQL injection
  4. Leverages explicit transaction controls effectively

 

4. Uses InterSystems IRIS-specific SQL capabilities

  1. Uses SelectMode appropriately
  2. Uses arrow syntax for implicit joining

 

5. Uses transactions effectively

  1. Determines appropriate transaction boundaries
  2. Uses CommitMode appropriately
  3. Recalls impact of large or long-running transactions

3. Manages InterSystems IRIS SQL operations

1. Manages SQL operations

  1. Uses SQL Process view to monitor SQL activity (2022.2+)
  2. Gathers table statistics
  3. Uses the runtime stats in the Statement Index to find statements with optimization opportunities

 

2. Manages SQL Security

  1. Assigns SQL privileges to users and roles
  2. Differentiates SQL privilege checking and application security
  3. Identifies impact of enabling SQL auditing
 

3. Uses PTools for advanced performance analysis

  1. Distinguishes between performance metrics "time spent", "global references" and "commands executed"

Interested in participating? Email certification@intersystems.com now!

5 Comments
Discussion (5)6
Connectez-vous ou inscrivez-vous pour continuer
Annonce
· Avr 22, 2024

The Global Masters Program will be temporarily PAUSED from April 26th

Access for Global Masters:

Please access Global Masters via
 this link.

Log in using InterSystems SSO ("Login with InterSystems" button on the left). 


At InterSystems, we strive to give you the best quality in everything. Including the realization of our Global Masters program. 

The vendor of this platform has been acquired by another company, and unfortunately, we will no longer be able to continue hosting our esteemed Global Masters program on this platform. We are currently evaluating new platform providers to facilitate the transition of the Global Masters Advocate Hub.

Beginning April 26th, we will temporarily suspend access to the Global Masters program as we transition to a new platform.

FAQ:

YOUR POINTS, BADGES AND LEVEL

All points, badges and achievements will be saved as of April 26th. We will transfer all data to a new platform.

YOUR CONTRIBUTIONS TO DEVELOPER ECOSYSTEM 

During the migration, we will still be counting all contributions to Developer Ecosystems (posts, comments, applications, etc) automatically. These well-deserved points and badges will be added to your profile upon the launch of a new program.

PRIZES

To provide an opportunity to redeem prizes during the migration, we plan to build a special webpage with prizes as soon as possible. However, we encourage you to redeem prizes you had planned to redeem before April 26th (on April 26th prizes will be already unpublished), as this functionality will not be available for some time.

WHAT'S NEXT

All information regarding the upgrade will be published in the Discord and Developer Community channels. We apologize for any inconvenience and will endeavor to complete the migration as soon as possible. 

WHERE TO ASK QUESTION? GLOBAL MASTERS SUPPORT 

Reach out to Olga @Olga Zavrazhnova in DM here or ask questions in a dedicated Global Masters channel on Discord. Let's stay in touch!

WE WILL UPDATE YOU ON THE ESTIMATE DATE OF LAUNCH SOON

We are looking forward to meeting you soon on a new platform!
Sincerely yours, 
Global Masters and Developer Community team

4 Comments
Discussion (4)4
Connectez-vous ou inscrivez-vous pour continuer