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

Last change on this file since 1451 was 1343, checked in by George Lilly, 13 years ago

beginning some retrieval code

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