From:	AITGW::"nieland_t@asd-yf.wpafb.af.mil" 13-DEC-1991 13:08:55.62
To:	arisia::everhart
CC:	
Subj:	Submission for the tape....

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Fri, 13 Dec 91 13:06:49 EST
Received: from [129.48.124.1] by aitgw.ge.com (5.65/GE Gateway 1.4)
	id AA22955; Fri, 13 Dec 91 13:06:00 -0500
Received: by kahuna.asd-yf.wpafb.af.mil (MX V2.3-1) id 15696; Fri, 13 Dec 1991
          12:32:37 EST
Date: Fri, 13 Dec 1991 12:32:37 EST
From: Ted Nieland <nieland_t@kahuna.asd-yf.wpafb.af.mil>
Reply-To: nieland_t@asd-yf.wpafb.af.mil
To: arisia::everhart
Message-Id: <009530D0.7F1A8CCA.15696@kahuna.asd-yf.wpafb.af.mil>
Subject: Submission for the tape....
 
Glenn,
 
Here is a submission I just received.
 
Ted
 
 
 
 
From:	MX%"DOW@EISNER.decus.org" 12-DEC-1991 18:41:57.16
To:	NIELAND_T
CC:	
Subj:	OPTIMIZE_RMS.COM tape submission
 
From: DOW@EISNER.decus.org
Subject: OPTIMIZE_RMS.COM tape submission
To: NIELAND_T@ASD-YF.WPAFB.AF.MIL
 
                  <<< EISNER::DUA2:[NOTES$HIVOL]VMS.NOTE;1 >>>
                         -< VMS and bundled utilities >-
================================================================================
Note 1178.38                     RMS File tuning                        38 of 38
EISNER::DOW "Bruce Dow, STS Consultants"            304 lines   3-DEC-1991 15:51
                           -< OPTIMIZE_RMS.COM V2.1 >-
--------------------------------------------------------------------------------
$!
$! STSBIN:OPTIMIZE_RMS.COM - V2.1 - optimizes indexed files using EDIT/FDL
$!
$!	new modifications:
$!
$!		12/03/91	Save ACLs.  Suggested by Curtis Reid.
$!
$!				If the logical OPTRMS_TESTING is TRUE, then
$!				FDL files are NOT deleted.  (I.e., FDL files
$!				will be deleted by default.)  Suggested by
$!				Curtis Reid.		B. Dow.
 
--------------------  cut here ---------------------------------------------
$!
$! STSBIN:OPTIMIZE_RMS.COM - V2.1 - optimizes indexed files using EDIT/FDL
$!
$!	downloaded from the CompuServe VAXFORUM.  author unknown.
$!	tested for STS by Bruce Dow.	7/16/90
$!
$!
$! p1 = Name of file
$! p2 = number of additional records to add (defaults to 0 if blank)
$! p3 = "Y" to do a convert at the end		! only valid in batch
$! p4 = "Y" to turn Key and Data Compression OFF (default = No)
$! p5 = "Y" to turn Index Compression OFF (default = YES to provide
$!						upward compatibility)
$! p6 = "Y" to explicitly turn compression ON if requested (default = No)
$!
$!      **** NOTE ****
$!      This procedure is based on an undocumented
$!      feature of the EDIT/FDL program (EDF).
$!       - Normally, EDF won't take input from anything but a
$!         real terminal (i.e. not a mailbox, command file, etc.)
$!         However, defining the logical name EDF$$PLAYBACK_INPUT
$!         equal to anything changes the behavior to allow input
$!         to come from a command file.
$!      ***************
$!
$!	**** NOTE *****
$!	   If you decide to turn compression OFF, the procedure does so
$!	explicitly.
$!
$!	   If you don't turn compression OFF, by default the procedure
$!	does NOT change the compression status (either OFF or ON) that
$!	the file already has, UNLESS P6 = "Y".
$!
$!	   If P6 = "Y", then compression will be explicitly turned ON.
$!	This is useful to compare whether compression actually helps.
$!      ***************
$!
$!
$!	modifications:
$!
$!		07/16/90	Turn OFF Index Compression for all files,
$!				to avoid **sequential** index search.
$!				Allow Data Compression & Key Compression
$!				to be turned off also.      B. Dow.
$!
$!		09/24/91	Provide option to turn Index Compression
$!				on or off.  Suggested by Don Roberts.
$!
$!				Convert to 'filename'.NEW and rename to
$!				'filename' if success status returned from
$!				convert.  Suggested by Carl Friedberg.
$!
$!				If compression is NOT turned OFF,
$!				provide option to explicitly turn
$!				compression ON.
$!
$!				If the logical OPTRMS_DEBUG is TRUE, then
$!				it will only create the command procedure
$!				without running and deleting it.  B. Dow.
$!
$!		12/03/91	Save ACLs.  Suggested by Curtis Reid.
$!
$!				If the logical OPTRMS_TESTING is TRUE, then
$!				FDL files are NOT deleted.  (I.e., FDL files
$!				will be deleted by default.)  Suggested by
$!				Curtis Reid.		B. Dow.
 
$!
$!
$ set noon
$ exit_status = 1
$ if p1 .nes. "" then goto batch
$!
$get_file:
$ inquire p1 "File to be optimized (^Y to quit)"
$!
$ filename = p1
$ spec = f$search(filename)
$!
$got_name_interactive:
$ name = f$parse(filename,,,"name")             ! get name part
$!
$ if f$file_attribute(filename,"org") .eqs. "IDX" then  -
   $ goto interactive_check_adds             ! check if indexed
$ write sys$output "%OPTIMIZE_RMS-F        File type is not indexed"
$ goto GET_FILE
$!
$INTERACTIVE_CHECK_ADDS:
$ INQUIRE P2 "Number of records to add after initial load"
$ if p2 .eqs. "" then p2 = 0
$!
$ if p2 .ge. 0 then goto interactive_check_convert
$ write sys$output "%OPTIMIZE_RMS-F        Added records must be >= 0 "
$ goto got_name_interactive
$!
$INTERACTIVE_CHECK_CONVERT:
$! INQUIRE P3 "Perform the convert? (Y/N)" 		! only valid in batch, don't ask
$ INQUIRE P4 "Turn OFF Data and Key Compression? (Y/N)"
$!
$ INQUIRE P5 "Turn OFF Index Compression? (Y/N) [default = Yes]" ! for upward compatibility
$ if p5 .eqs. "" then p5 = "YES"				 ! not necessarily the best default
$!
$ goto ADD_OK
$!
$BATCH:
$GOT_NAME:
$ filename = p1
$ spec = f$search(filename)
$ if spec .nes. "" then goto file_exists
$ write sys$output "%OPTIMIZE_RMS-F        File does not exist"
$ exit_status = %X18292           ! should be no-such-file
$ GOTO DONE
$!
$FILE_EXISTS:
$ name = f$parse(filename,,,"name")             ! get name part
$ new_name = f$parse(".new;0",spec)       ! make a full .NEW file spec
$!
$ if f$file_attribute(filename,"org") .eqs. "IDX" THEN GOTO TYPE_OK
$ write sys$output %OPTIMIZE_RMS-F        File type is not indexed"
$ exit_status = 1000024   ! wrong file type
$ goto done
$!
$type_ok:
$ if p2 .eqs. "" then p2 = 0
$ if p2 .ge. 0 then goto add_ok
$!
$ write sys$output "%OPTIMIZE_RMS-F        Added records must be >= 0 "
$ exit_status     =       %x38060      ! Bad DCL Parameter
$ goto done
$!
$add_ok:
$ add_records = p2
$!
$ number_of_keys == 'f$file_attribute(filename,"nok")
$!
$ do_convert = p3
$ turn_data_compression_off = p4
$ if p5 .eqs. "" then p5 = "YES"	  ! for upward compatibility, not necessarily the best default
$ turn_index_compression_off = p5
$ explicitly_turn_compression_on = p6
$!
$ fdl_name = f$parse(".fdl;0",spec)       ! make a full fdl file spec
$!
$!now start creating the temporary file which will be input to EDIT/FDL/optim
$!
$ temp_file = "sys$scratch:''name'_temp_temp.COM"
$ open/write/error=open_error out 'temp_file
$ write out       "$ DEFINE/USER  SYS$COMMAND     SYS$INPUT"
$ write out       "$ ANALYZE/RMS/FDL/out=''FDL_NAME'      ''FILENAME'"
$ write out       "$ DEFINE/USER  SYS$COMMAND     SYS$INPUT"
$ write out       "$ define/user  EDF$$PLAYBACK_INPUT     KLUDGE"
$! check the fiche - it allows it to run in a .COM
$ write out   "$ EDIT/FDL/SCRIPT=OPTIMIZE/ANALYZE=''FDL_NAME' ''FDL_NAME'"
$ write out       ""
$ write out       ""
$ write out       ""
$ write out       ""
$ write out       'add_records
$ if add_records .eq. 0 then goto skip_non_zero
$ write out       ""
$ write out       ""
$!
$skip_non_zero:
$ write out       ""      ! segmentation question
$ if turn_index_compression_off
$ then
$  	write out	  "IC"	  ! Index Compression
$ 	write out	  "NO"	  ! ... turn IC off
$ else
$	if explicitly_turn_compression_on
$	then
$  		write out	  "IC"	  ! Index Compression
$ 		write out	  "YES"	  ! ... turn IC on
$	endif
$ endif
$ if turn_data_compression_off
$ then
$ 	write out	  "RC"	  ! Data Record Compression
$ 	write out	  "NO"	  ! ... turn RC off
$ 	write out	  "KC"	  ! Key Compression
$ 	write out	  "NO"	  ! ... turn KC off
$ else
$	if explicitly_turn_compression_on
$	then
$ 		write out	  "RC"	  ! Data Record Compression
$ 		write out	  "YES"	  ! ... turn RC on
$ 		write out	  "KC"	  ! Key Compression
$ 		write out	  "YES"	  ! ... turn KC on
$ 	endif
$ endif
$ write out       "FD"    ! final design question
$ write out       "Created from OPTIMIZE_RMS.COM, WITH SPACE/BUCKET SIZE FOR ''ADD_RECORDS' ADDED RECORDS"
$ write out       ""      ! the bucket size question
$ write out       ""      ! return to main menu
$! now loop around for secondary keys
$loop:
$ if number_of_keys .eq. 1 then goto close_file !Done
$ write out       ""
$ write out       ""      ! graph type
$ write out       ""      ! Key segmentation
$ if turn_index_compression_off
$ then
$  	write out	  "IC"	  ! Index Compression
$ 	write out	  "NO"	  ! ... turn IC off
$ else
$	if explicitly_turn_compression_on
$	then
$  		write out	  "IC"	  ! Index Compression
$ 		write out	  "YES"	  ! ... turn IC on
$ 	endif
$ endif
$ if turn_data_compression_off
$ then
$ 	write out	  "KC"	  ! Key Compression
$ 	write out	  "NO"	  ! ... turn KC off
$ else
$	if explicitly_turn_compression_on
$	then
$ 		write out	  "KC"	  ! Key Compression
$ 		write out	  "YES"	  ! ... turn KC on
$ 	endif
$ endif
$ write out       "FD"    ! final design for this key
$ write out       ""      ! bucket size
$ write out       ""      ! return to main menu
$!
$ number_of_keys = 'number_of_keys - 1
$ goto loop
$!
$close_file:
$ write out       "E"     ! Exit
$ close out
$!
$! NOW ACTUALLY RUN THE COMMAND FILE
$!
$ if f$trnlnm("optrms_debug") then exit		!!! debugging
$
$ @'TEMP_FILE             ! THAT SHOULD DO IT
$ delete 'temp_file;*     ! clean it up
$
$ if DO_CONVERT
$ then
$!
$! Don't let this be run interactively.
$!
$ 	if f$environment("interactive")
$ 	then 	type sys$input
 
You shouldn't try to CONVERT this file interactively, first because it will
take a very long time to CONVERT large indexed files, and second because the
file can be corrupted if the procedure is terminated by pressing control-y.
To run it in batch, submit it using:
 
   /PARAM=(file-name [, n-records-to-add] [, Y]
	[, turn-data-compression-off] [, turn-index-compression-off])
 
 
$ 		goto done
$	else
$		write sys$output ""
$ 		write sys$output "Starting CONVERT of ''FILENAME' on ''F$TIME()'."
$	 	CONVERT /NOSORT /STAT/FDL='FDL_NAME     'FILENAME     'NEW_NAME
$	        exit_status = $status
$		if exit_status
$		then	set file/acl/like='filename 'new_name
$			rename 'new_name 'filename
$			if .not. f$trnlnm("OPTRMS_TESTING") then -
				delete/nolog 'f$parse(".fdl;*", fdl_name)
$		else	write sys$output ""
$			write sys$output ""
$			write sys$output "There was an error during the conversion."
$			write sys$output "Check the log file.
$			write sys$output ""
$			write sys$output f$message(exit_status)
$			write sys$output ""
$		endif
$		write sys$output ""
$	endif
$ endif
$ goto done
$!
$EOF:
$ write sys$output "%OPTIMIZE_RMS-F        ^Z of input"
$ EXIT_STATUS = %X1827A
$ goto done
$open_error:
$ write sys$output "%OPTIMIZE_RMS-F        Unable to open ''temp_file'"
$!
$ EXIT_STATUS = 4
$done:
$ exit 'exit_status
--------------------------------------------------------------------------------
Return-Path: <@KAHUNA.ASD-YF.WPAFB.AF.MIL:DOW@EISNER.decus.org>
Received: from DECUS.ORG by KAHUNA.ASD-YF.WPAFB.AF.MIL (MX V2.3-1) with SMTP;
          Thu, 12 Dec 1991 18:41:44 EST
Received: from decus.org by decus.org (PMDF #12130) id
          <01GE1AP5XCPS8WW2GK@decus.org>; Thu, 12 Dec 1991 18:41 EDT
Message-ID: <01GE1AP5XCPS8WW2GK@decus.org>
X-Organization: Digital Equipment Computer Users Society
X-VMS-To: TOPAZ::NIELAND
