@@ -21,8 +21,6 @@ program gcollapse, rclass
2121 ///
2222 merge /// Merge statistics back to original data, replacing if applicable
2323 replace /// Allow replacing existing variables with output with merge
24- compress /// Try to compress strL variables
25- forcestrl /// Force reading strL variables (stata 14 and above only)
2624 freq(passthru) /// Include frequency count with observations per group
2725 ///
2826 LABELFormat(passthru) /// Custom label engine: (#stat#) #sourcelabel# is the default
@@ -40,16 +38,18 @@ program gcollapse, rclass
4038 forcemem /// Use memory for writing/reading collapsed data
4139 double /// Generate all targets as doubles
4240 ///
41+ compress /// Try to compress strL variables
42+ forcestrl /// Force reading strL variables (stata 14 and above only)
4343 Verbose /// Print info during function execution
4444 BENCHmark /// print function benchmark info
4545 BENCHmarklevel(int 0) /// print plugin benchmark info
46- ///
4746 HASHmethod(passthru) /// Hashing method: 0 (default), 1 (biject), 2 (spooky)
47+ ///
4848 hashlib(passthru) /// (Windows only) Custom path to spookyhash.dll
4949 oncollision(passthru) /// error|fallback: On collision, use native command or throw error
5050 ///
51- debug /// (internal) Allow replacing by variables with output
52- DEBUG_level(int 0) /// (internal) Allow replacing by variables with output
51+ debug /// (internal) Debug
52+ DEBUG_level(int 0) /// (internal) Debug (passed to internals)
5353 debug_replaceby /// (internal) Allow replacing by variables with output
5454 debug_io_read(int 1) /// (internal) Read IO data using mata or C
5555 debug_io_check(real 1e6) /// (internal) Threshold to check for I/O speed gains
@@ -395,7 +395,8 @@ program gcollapse, rclass
395395
396396 qui mata: st_addvar(__gtools_gc_recasttypes, __gtools_gc_recastvars, 1)
397397 if ( `= _N > 0' ) {
398- cap noi _gtools_internal, recast(targets(`gtools_recastvars') sources(`gtools_recastsrc'))
398+ cap noi _gtools_internal, ///
399+ recast(targets(`gtools_recastvars') sources(`gtools_recastsrc'))
399400 if ( _rc ) {
400401 local rc = _rc
401402 CleanExit
@@ -481,13 +482,16 @@ program gcollapse, rclass
481482 local sources sources(`__gtools_gc_vars')
482483 local stats stats(`__gtools_gc_stats')
483484 local targets targets(`__gtools_gc_targets')
484- local opts missing replace `keepmissing' `compress' `forcestrl' debug(`debug_level')
485- local opts `opts' `verbose' `benchmark' `benchmarklevel' `hashlib' `oncollision' `hashmethod'
485+ local opts missing replace `keepmissing' `compress' `forcestrl'
486+ local opts `opts' `verbose' `benchmark' `benchmarklevel' `hashmethod'
487+ local opts `hashlib' `oncollision' debug(`debug_level')
486488 local opts `opts' `anymissing' `allmissing' `rawstat'
487489 local action `sources' `targets' `stats'
488490
489491 local switch = (`= scalar(__gtools_gc_k_extra)' > 3) & (`debug_io_check' < `= _N')
490- local mem = (" `forcemem'" ! = " " ) | (" `merge'" ! = " " ) | (`= scalar(__gtools_gc_k_extra)' == 0)
492+ local mem = (" `forcemem'" ! = " " ) ///
493+ | (" `merge'" ! = " " ) ///
494+ | (`= scalar(__gtools_gc_k_extra)' == 0)
491495 local io = (" `forceio'" ! = " " ) & (`= scalar(__gtools_gc_k_extra)' > 0)
492496
493497 if ( `io' ) {
@@ -518,7 +522,10 @@ program gcollapse, rclass
518522 * Benchmark adding 2 variables to gauge how long it might take to
519523 * add __gtools_gc_k_extra variables.
520524 tempvar __gtools_gc_index __gtools_gc_ix __gtools_gc_info
521- cap noi benchmark_memvars, index(`__gtools_gc_index') ix(`__gtools_gc_ix') info(`__gtools_gc_info')
525+ cap noi benchmark_memvars, ///
526+ index(`__gtools_gc_index') ///
527+ ix(`__gtools_gc_ix') ///
528+ info(`__gtools_gc_info')
522529 if ( _rc ) {
523530 local rc = _rc
524531 CleanExit
@@ -561,10 +568,14 @@ program gcollapse, rclass
561568 gtools_timer info 97 `" `msg'"' , prints(`bench')
562569
563570 if ( (" `forceio'" == " forceio" ) & (`= scalar(__gtools_gc_k_extra)' == 0) ) {
564- if ( `verb' ) di as text " (ignored -forceio- because sources are being used as targets)"
571+ if ( `verb' ) {
572+ di as text " (ignored -forceio- because sources are being used as targets)"
573+ }
565574 }
566575
567- if ( " `added'" ! = " " ) qui mata: st_addvar(__gtools_gc_addtypes, __gtools_gc_addvars, 1)
576+ if ( " `added'" ! = " " ) {
577+ qui mata: st_addvar(__gtools_gc_addtypes, __gtools_gc_addvars, 1)
578+ }
568579 local msg " Generated additional targets"
569580 gtools_timer info 97 `" `msg'"' , prints(`bench')
570581
@@ -672,7 +683,10 @@ program gcollapse, rclass
672683 * If we collapsed to disk, read back the data
673684 * -------------------------------------------
674685
675- if ( (`= _N > 0') & (`= scalar(__gtools_gc_k_extra)' > 0) & ( `used_io' | (" `forceio'" == " forceio" ) ) ) {
686+ local ifcond (`= _N > 0') ///
687+ & (`= scalar(__gtools_gc_k_extra)' > 0) ///
688+ & ( `used_io' | (" `forceio'" == " forceio" ) )
689+ if ( `ifcond' ) {
676690 gtools_timer on 97
677691
678692 qui mata: st_addvar(__gtools_gc_addtypes, __gtools_gc_addvars, 1)
805819
806820cap mata: mata drop gtools_get_collapsed()
807821mata
808- real matrix function gtools_get_collapsed(string scalar fname, real scalar nrow, real scalar ncol)
822+ real matrix function gtools_get_collapsed(
823+ string scalar fname,
824+ real scalar nrow,
825+ real scalar ncol)
809826{
810827 real scalar fh
811828 real matrix X
@@ -1212,7 +1229,11 @@ program parse_keep_drop, rclass
12121229 else {
12131230 * We only recast integers. Floats and doubles are preserved unless
12141231 * requested or the target is a sum.
1215- parse_ok_astarget, sourcevar(`var') targetvar(`var') stat(`collstat') `double' `weights'
1232+ parse_ok_astarget, ///
1233+ sourcevar(`var') ///
1234+ targetvar(`var') ///
1235+ stat(`collstat') ///
1236+ `double' `weights'
12161237 local recast = ! (`r(ok_astarget)')
12171238
12181239 if ( `recast' ) {
0 commit comments