DIOQ ;SFISC/GS,TKW-QUERY OPTIMIZER ;4/5/95 14:02
;;22.0;VA FileMan;;Mar 30, 1999
;Per VHA Directive 10-93-142, this routine should not be modified.
SER(F,DIOQGET,DIOQCHEK,C,X,%,W) ; COMPUTE SEARCH EFFICIENCY RATING
; F=FILE#, DIOQGET=GET CODE, DIOQCHEK=EVALUATION CODE,
; C=USEABLE INDEX? (1=YES, 0=NO)
; X=EFFICIENCY RATING, %=PREVALANCE OF HITS (PROBABILITY)
; W=WRITE PROGRESS MSG.TO USER
N Z S (X,%)=0,W=$G(W),Z=$G(^DIC(+$G(F),0,"GL")) Q:Z=""
N I,N,T,D0,DA,DITRUE,DIFIRST S DIFIRST=1
I W S W=$P($H,",",2)+.1
S (T,N)=0,I=$P(@(Z_"0)"),U,4)\100
F D0=0:I S D0=$O(@(Z_D0_")")) Q:'D0 Q:N>100 S DA=D0,N=N+1 D TEST I DITRUE S T=T+1
S %=$S(N=0:1,T=0:0,1:T/N),(X,%)=1-% I C S:%=1 X=100 S:%'=1 X=%/(1-%)
S X=$J(X,1,4),%=$J(%,1,4) Q
;
TEST ; GET VALUE AND EVALUATE IT
N I,L,N,T,Z,DIOQSVD0 S DIOQSVD0=D0 D S D0=DIOQSVD0
. N F,C,W,DIFIRST
. X DIOQGET,DIOQCHEK S DITRUE=$T Q
Q:'W Q:($P($H,",",2)-W)'>3 S W=$P($H,",",2)+.1
I DIFIRST S DIFIRST=0 W !,"Computing search efficiency..." Q
W "." Q
DIOQ ;SFISC/GS,TKW-QUERY OPTIMIZER ;4/5/95 14:02
+1 ;;22.0;VA FileMan;;Mar 30, 1999
+2 ;Per VHA Directive 10-93-142, this routine should not be modified.
SER(F,DIOQGET,DIOQCHEK,C,X,%,W) ; COMPUTE SEARCH EFFICIENCY RATING
+1 ; F=FILE#, DIOQGET=GET CODE, DIOQCHEK=EVALUATION CODE,
+2 ; C=USEABLE INDEX? (1=YES, 0=NO)
+3 ; X=EFFICIENCY RATING, %=PREVALANCE OF HITS (PROBABILITY)
+4 ; W=WRITE PROGRESS MSG.TO USER
+5 NEW Z
SET (X,%)=0
SET W=$GET(W)
SET Z=$GET(^DIC(+$GET(F),0,"GL"))
IF Z=""
QUIT
+6 NEW I,N,T,D0,DA,DITRUE,DIFIRST
SET DIFIRST=1
+7 IF W
SET W=$PIECE($HOROLOG,",",2)+.1
+8 SET (T,N)=0
SET I=$PIECE(@(Z_"0)"),U,4)\100
+9 FOR D0=0:I
SET D0=$ORDER(@(Z_D0_")"))
IF 'D0
QUIT
IF N>100
QUIT
SET DA=D0
SET N=N+1
DO TEST
IF DITRUE
SET T=T+1
+10 SET %=$SELECT(N=0:1,T=0:0,1:T/N)
SET (X,%)=1-%
IF C
IF %=1
SET X=100
IF %'=1
SET X=%/(1-%)
+11 SET X=$JUSTIFY(X,1,4)
SET %=$JUSTIFY(%,1,4)
QUIT
+12 ;
TEST ; GET VALUE AND EVALUATE IT
+1 NEW I,L,N,T,Z,DIOQSVD0
SET DIOQSVD0=D0
Begin DoDot:1
+2 NEW F,C,W,DIFIRST
+3 XECUTE DIOQGET
XECUTE DIOQCHEK
SET DITRUE=$TEST
QUIT
End DoDot:1
SET D0=DIOQSVD0
+4 IF 'W
QUIT
IF ($PIECE($HOROLOG,",",2)-W)'>3
QUIT
SET W=$PIECE($HOROLOG,",",2)+.1
+5 IF DIFIRST
SET DIFIRST=0
WRITE !,"Computing search efficiency..."
QUIT
+6 WRITE "."
QUIT