[1539] | 1 | C0XTEST ; GPL - Fileman Triples bulk load tester ;11/6/11 17:05
|
---|
| 2 | ;;1.0;FILEMAN TRIPLE STORE;;Sep 26, 2012;Build 10
|
---|
| 3 | ;Copyright 2011 George Lilly. Licensed under the terms of the GNU
|
---|
| 4 | ;General Public License See attached copy of the License.
|
---|
| 5 | ;
|
---|
| 6 | ;This program is free software; you can redistribute it and/or modify
|
---|
| 7 | ;it under the terms of the GNU General Public License as published by
|
---|
| 8 | ;the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | ;(at your option) any later version.
|
---|
| 10 | ;
|
---|
| 11 | ;This program is distributed in the hope that it will be useful,
|
---|
| 12 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | ;GNU General Public License for more details.
|
---|
| 15 | ;
|
---|
| 16 | ;You should have received a copy of the GNU General Public License along
|
---|
| 17 | ;with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
| 18 | ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
| 19 | ;
|
---|
| 20 | Q
|
---|
| 21 | ;
|
---|
| 22 | EN ; run the test
|
---|
| 23 | ;
|
---|
| 24 | k C0XFDA ; clear the node variable
|
---|
| 25 | i '$d(^C0X(101,0)) d ; global doesn't exist
|
---|
| 26 | . s ^C0X(101,0)="C0X TRIPLE^172.101^1^1"
|
---|
| 27 | n zg
|
---|
| 28 | S zg="_:G"_$$LKY9 ; all nodes are in the same graph
|
---|
| 29 | n zi
|
---|
| 30 | f zi=1:1:100000 d ; try a test of 10000 nodes
|
---|
| 31 | . s C0XFDA(172.101,zi,.01)="N"_$$LKY17 ; node name
|
---|
| 32 | . s C0XFDA(172.101,zi,.02)=zg
|
---|
| 33 | . s C0XFDA(172.101,zi,.03)=$R(100000)
|
---|
| 34 | . s C0XFDA(172.101,zi,.04)=$R(100000)
|
---|
| 35 | . s C0XFDA(172.101,zi,.05)=$R(100000)
|
---|
| 36 | S C0XST=$$NOW^XLFDT ; start of the insertion test
|
---|
| 37 | W !,"INSERTION STARTS AT ",C0XST,!
|
---|
| 38 | d BULKLOAD(.C0XFDA)
|
---|
| 39 | s C0XEND=$$NOW^XLFDT ; end of the insertion test
|
---|
| 40 | W !,"INSERTION ENDS AT ",C0XEND
|
---|
| 41 | S C0XDIFF=$$FMDIFF^XLFDT(C0XEND,C0XST,2)
|
---|
| 42 | W !," ELAPSED TIME: ",C0XDIFF," SECONDS"
|
---|
| 43 | I C0XDIFF>0 W !," APPROXIMATELY ",$P(100000/C0XDIFF,".")," NODES PER SECOND"
|
---|
| 44 | q
|
---|
| 45 | ;
|
---|
| 46 | LKY9() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
|
---|
| 47 | ; UNIQUE NODE AND GRAPH NAMES
|
---|
| 48 | N ZN,ZI
|
---|
| 49 | S ZN=""
|
---|
| 50 | F ZI=1:1:9 D ;
|
---|
| 51 | . S ZN=ZN_$R(10)
|
---|
| 52 | Q ZN
|
---|
| 53 | ;
|
---|
| 54 | LKY17() ;EXTRINIC THAT RETURNS A RANDOM 9 DIGIT NUMBER. USED FOR GENERATING
|
---|
| 55 | ; UNIQUE NODE AND GRAPH NAMES
|
---|
| 56 | N ZN,ZI
|
---|
| 57 | S ZN=""
|
---|
| 58 | F ZI=1:1:17 D ;
|
---|
| 59 | . S ZN=ZN_$R(10)
|
---|
| 60 | Q ZN
|
---|
| 61 | ;
|
---|
| 62 | BULKLOAD(ZBFDA) ; BULK LOADER FOR LOADING TRIPLES INTO FILE 172.101
|
---|
| 63 | ; USING GLOBAL SETS INSTEAD OF UPDATE^DIE
|
---|
| 64 | ; QUITS IF FILE IS NOT 172.101
|
---|
| 65 | ; EXPECTS AN FDA WITHOUT STRINGS FOR THE IENS, STARTING AT 1
|
---|
| 66 | ; QUITS IF FIRST ENTRY IS NOT IENS 1
|
---|
| 67 | ; ASSUMES THAT THE LAST IENS IS THE COUNT OF ENTRIES
|
---|
| 68 | ; ZBFDA IS PASSED BY REFERENCE
|
---|
| 69 | ;
|
---|
| 70 | ; -- reserves a block of iens from file 172.101 by locking the zero node
|
---|
| 71 | ; -- ^C0X(101,0) and adding the count of entries to piece 2 and 3
|
---|
| 72 | ; -- then unlocking to minimize the duration of the lock
|
---|
| 73 | ;
|
---|
| 74 | W !,"USING BULKLOAD"
|
---|
| 75 | I '$D(ZBFDA) Q ; EMPTY FDA
|
---|
| 76 | I $O(ZBFDA(""))'=172.101 Q ; WRONG FILE
|
---|
| 77 | N ZCNT,ZP3,ZP4
|
---|
| 78 | ; -- find the number of nodes to insert
|
---|
| 79 | S ZCNT=$O(ZBFDA(172.101,""),-1)
|
---|
| 80 | I ZCNT="" D Q ;
|
---|
| 81 | . W !,"ERROR IN BULK LOAD - INVALID NODE COUNT"
|
---|
| 82 | . B
|
---|
| 83 | ; -- lock the zero node and reserve a block of iens to insert
|
---|
| 84 | W !,"LOCKING ZERO NODE"
|
---|
| 85 | LOCK +^C0X(101,0)
|
---|
| 86 | S ZP3=$P(^C0X(101,0),U,3)
|
---|
| 87 | S ZP4=$P(^C0X(101,0),U,4)
|
---|
| 88 | S $P(^C0X(101,0),U,3)=ZP3+ZCNT+1
|
---|
| 89 | S $P(^C0X(101,0),U,4)=ZP4+ZCNT+1
|
---|
| 90 | LOCK -^C0X(101,0)
|
---|
| 91 | N ZI,ZN,ZG,ZS,ZP,ZO,ZIEN,ZBASE
|
---|
| 92 | S ZBASE=ZP3 ; the last ien in the file
|
---|
| 93 | W !,"ZERO NODE UNLOCKED, IENS RESERVED=",ZCNT
|
---|
| 94 | W !,$$NOW^XLFDT
|
---|
| 95 | S ZI=""
|
---|
| 96 | F S ZI=$O(ZBFDA(172.101,ZI)) Q:ZI="" D ;
|
---|
| 97 | . S ZN=$G(ZBFDA(172.101,ZI,.01)) ; node name
|
---|
| 98 | . I ZN="" D BLKERR Q ;
|
---|
| 99 | . S ZG=$G(ZBFDA(172.101,ZI,.02)) ; graph pointer
|
---|
| 100 | . I ZG="" D BLKERR Q ;
|
---|
| 101 | . S ZS=$G(ZBFDA(172.101,ZI,.03)) ; subject pointer
|
---|
| 102 | . I ZS="" D BLKERR Q ;
|
---|
| 103 | . S ZP=$G(ZBFDA(172.101,ZI,.04)) ; predicate pointer
|
---|
| 104 | . I ZP="" D BLKERR Q ;
|
---|
| 105 | . S ZO=$G(ZBFDA(172.101,ZI,.05)) ; object pointer
|
---|
| 106 | . I ZO="" D BLKERR Q ;
|
---|
| 107 | . S ZIEN=ZI+ZBASE ; the new ien
|
---|
| 108 | . S ^C0X(101,ZIEN,0)=ZN_U_ZG_U_ZS_U_ZP_U_ZO ; set the zero node
|
---|
| 109 | . S ^C0X(101,"B",ZN,ZIEN)="" ; the B index
|
---|
| 110 | . S ^C0X(101,"G",ZG,ZIEN)="" ; the G for Graph index
|
---|
| 111 | . S ^C0X(101,"SPO",ZS,ZP,ZO)=""
|
---|
| 112 | . S ^C0X(101,"SOP",ZS,ZO,ZP)=""
|
---|
| 113 | . S ^C0X(101,"OPS",ZO,ZP,ZS)=""
|
---|
| 114 | . S ^C0X(101,"OSP",ZO,ZS,ZP)=""
|
---|
| 115 | . S ^C0X(101,"GOPS",ZG,ZO,ZP,ZS)=""
|
---|
| 116 | . S ^C0X(101,"GOSP",ZG,ZO,ZS,ZP)=""
|
---|
| 117 | . S ^C0X(101,"GPSO",ZG,ZP,ZS,ZO)=""
|
---|
| 118 | . S ^C0X(101,"GSPO",ZG,ZS,ZP,ZO)=""
|
---|
| 119 | Q
|
---|
| 120 | ;
|
---|
| 121 | BLKERR ;
|
---|
| 122 | W !,"ERROR IN BULK LOAD",! ZWR ZBFDA(ZI)
|
---|
| 123 | B
|
---|
| 124 | Q
|
---|
| 125 | ;
|
---|