|
|||||||
How Indexes Are UpdatedIndexing 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 0001 WRITE RECORD (CALLS SI.MFS) 0002 SI.MFS 0003 LOOP 0004 UNTIL LOCK OBTAINED ON !INDEXING,0 0005 REPEAT 0006 READ RECORD 0 0007 UPDATE RECORD 0 0008 IF RECORD 0 TOO BIG THEN 0009 GET LATEST TRANSACTION RECORD 0010 MOVE RECORD 0 INTO LATEST TRANSACTION RECORD 0011 UPDATE LATEST TRANSACTION RECORD 0012 END 0013 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 0001 INPUT.CHAR 0002 LOOP 0003 UNTIL TIME OUT REACHED 0004 REPEAT 0005 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. 0001 INDEX.CONTROL 0002 LOOP 0003 IF NOT KEY STROKE THEN 0004 CALL FILE.DISTRIBUTOR 0005 FILE.DISTRIBUTOR 0006 LOOP 0007 UNTIL KEY STROKE 0008 MOVE RECORDS FROM !INDEXING TO !FILE 0009 REPEAT 0010 END 0011 IF NOT KEY STROKE THEN 0012 CALL F.DISTRIBUTOR 0013 F.DISTRIBUTOR 0014 LOOP 0015 UNTIL KEY STROKES 0016 MOVE RECORDS TO FIELD CONTROL RECORDS 0017 REPEAT 0018 END 0019 IF NOT KEY STROKE THEN 0020 CALL F.INDEXER 0021 F.INDEXER 0022 LOOP 0023 UNTIL KEY STROKES 0024 UPDATE BTREE NODES 0025 REPEAT 0026 END 0027 IF NOT KEY STROKE THEN CALL POST INDEX CHECK 0028 END 0029 UNTIL KEY STROKE 0030 REPEAT 0031 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) |
|||||||
| |||||||