How Indexes Are Updated
Published By | Date | Version | Knowledge Level | Keywords |
---|---|---|---|---|
Sprezzatura Ltd | 01 MAR 1991 | 2.03+ | EXPERT | UPDATE, INDEX, SI.MFS, !INDEXING, BTREE, INPUT.CHAR, INDEX.CONTROL, FILE.DISTRIBUTOR, F.DISTRIBUTOR, F.INDEXER, BTREE.READ, BTREE.WRITE |
Indexing continues to be one of the least understood areas of AREV and our subscribers repeatedly request additional clarification on related issues. Following on from our issue describing index record structures (Volume 2 Issue 1), the following documents the logic flow of the system when updating indexes.
All i/o to an indexed file must first pass through SI.MFS. When this detects that a change has been made it updates the !INDEXING file with transaction records and then as time is made available (or indexes are flushed manually), it updates the indexes and balances the BTREES. This is not achieved by one self contained AREV routine but by a whole string of routines, SI.MFS, INPUT.CHAR, INDEX.CONTROL, FILE.DISTRIBUTOR, F.DISTRIBUTOR, F.INDEXER, BTREE.READ and BTREE.WRITE. The process taken could be represented by the following Pseudo Code
WRITE RECORD (CALLS SI.MFS) SI.MFS LOOP UNTIL LOCK OBTAINED ON !INDEXING,0 REPEAT READ RECORD 0 UPDATE RECORD 0 IF RECORD 0 TOO BIG THEN GET LATEST TRANSACTION RECORD MOVE RECORD 0 INTO LATEST TRANSACTION RECORD UPDATE LATEST TRANSACTION RECORD END UNLOCK !INDEXING,0
Note here that if somebody else on a network is involved in a record write involving several indexes, your station will appear to hang when you file a record with indexes. Your station will have to wait for the !INDEXING,0 lock.
When control is returned to INPUT.CHAR, the following occurs
INPUT.CHAR LOOP UNTIL TIME OUT REACHED REPEAT CALL INDEX.CONTROL
Note here that if there is a replace background process specified in the environment (2.X only), this will be called in place of INDEX.CONTROL and no further processing will take place. References to Post Index Check following also only apply in 2.X.
INDEX.CONTROL LOOP IF NOT KEY STROKE THEN CALL FILE.DISTRIBUTOR FILE.DISTRIBUTOR LOOP UNTIL KEY STROKE MOVE RECORDS FROM !INDEXING TO !FILE REPEAT END IF NOT KEY STROKE THEN CALL F.DISTRIBUTOR F.DISTRIBUTOR LOOP UNTIL KEY STROKES MOVE RECORDS TO FIELD CONTROL RECORDS REPEAT END IF NOT KEY STROKE THEN CALL F.INDEXER F.INDEXER LOOP UNTIL KEY STROKES UPDATE BTREE NODES REPEAT END IF NOT KEY STROKE THEN CALL POST INDEX CHECK END UNTIL KEY STROKE REPEAT RETURN TO INPUT CHAR
Note that these stages can be interrupted at any stage by pressing a key. The process of performing the BTREE update incrementally slows the system down but permits it to be done with minimal interference with normal work.
(Volume 2, Issue 9, Pages 5,6)