source: fmts/trunk/p/C0XTKSB.m@ 1719

Last change on this file since 1719 was 1629, checked in by George Lilly, 11 years ago

misc updates

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