From 1cad1cf939476bce3589ecf8519f98c7eb3d7397 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 23 Mar 2016 00:20:42 +0100 Subject: [PATCH] parallel: Implemented buggy :::+ and ::::+ --- NEWS | 3 ++- doc/release_new_version | 23 +++++++--------- src/niceload | 2 +- src/parallel | 58 ++++++++++++++++++++++++++++++++--------- src/sql | 2 +- 5 files changed, 59 insertions(+), 29 deletions(-) diff --git a/NEWS b/NEWS index b4286fea..3ed1bafe 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,8 @@ 20160322 * env_parallel is a function that exports the environment (functions, - aliases, variables, and arrays) to GNU Parallel. + aliases, variables, and arrays) to GNU Parallel. Run 'man + env_parallel' for details. * niceload --prg now searches for substrings if no process with the name is found. diff --git a/doc/release_new_version b/doc/release_new_version index 777d1db2..c8c39970 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -154,6 +154,12 @@ git push origin $YYYYMMDD == Update documentation == Update version number + 1 + +YYYYMMDD=$(echo `yyyymmdd`+1 | bc) +perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/parallel +perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/sql +perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/niceload + Unmodified beta since last version => production Unmodified alpha since last version => beta Modified => alpha @@ -213,14 +219,15 @@ cc:Tim Cuthbertson , Ryoichiro Suzuki , Jesse Alama -Subject: GNU Parallel 20160322 ('Bruxelles') released <<[stable]>> +Subject: GNU Parallel 20160422 ('') released <<[stable]>> -GNU Parallel 20160322 ('Bruxelles') <<[stable]>> has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ +GNU Parallel 20160422 ('') <<[stable]>> has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ <> Haiku of the month: +<<>> -- Ole Tange New in this release: @@ -241,18 +248,6 @@ for Big Data Applications https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumb * <> -* env_parallel is a function that exports the environment (functions, aliases, variables, and arrays) to GNU Parallel. - -* niceload --prg now searches for substrings if no process with the name is found. - -* GNU Parallel was cited in: Random Forest DBSCAN for USPTO Inventor Name Disambiguation http://arxiv.org/pdf/1602.01792.pdf - -* GNU Parallel was mentioned (with wrong citation) in: Dual Level Parallel Computations for LargeScale High-Fidelity Database to Design Aerospace Vehicles http://www.nas.nasa.gov/assets/pdf/papers/Guruswamy_2013_DualLevelParallelComputations.pdf - -* Using ‘Parallel’ in Unix https://shearnrylan.wordpress.com/2016/02/22/using-parallel-in-unix/ - -* JPEG Squish uses (and co-distributes) GNU Parallel: http://dantidswell.co.uk/jpeg-squish/ - * Bug fixes and man page updates. GNU Parallel - For people who live life in the parallel lane. diff --git a/src/niceload b/src/niceload index abd55669..ac71c15c 100755 --- a/src/niceload +++ b/src/niceload @@ -24,7 +24,7 @@ use strict; use Getopt::Long; $Global::progname="niceload"; -$Global::version = 20160322; +$Global::version = 20160323; Getopt::Long::Configure("bundling","require_order"); get_options_from_array(\@ARGV) || die_usage(); if($opt::version) { diff --git a/src/parallel b/src/parallel index e3b3e669..11eaa93c 100755 --- a/src/parallel +++ b/src/parallel @@ -854,6 +854,7 @@ sub options_hash { "tollef" => \$opt::tollef, "gnu" => \$opt::gnu, "xapply" => \$opt::xapply, + "xapplyinputsource=i" => \@opt::xapplyinputsource, "bibtex|citation" => \$opt::bibtex, "wc|willcite|will-cite|nn|nonotice|no-notice" => \$opt::willcite, # Termination and retries @@ -1180,7 +1181,7 @@ sub check_invalid_option_combinations { sub init_globals { # Defaults: - $Global::version = 20160322; + $Global::version = 20160323; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -1693,9 +1694,12 @@ sub read_args_from_command_line { # Arguments given on the command line after: # ::: ($Global::arg_sep) # :::: ($Global::arg_file_sep) + # :::+ ($Global::arg_sep with --xapply) + # ::::+ ($Global::arg_file_sep with --xapply) # Removes the arguments from @ARGV and: # - puts filenames into -a # - puts arguments into files and add the files to -a + # - adds --xapplyinputsource with 0/1 for each -a depending on :::+/::::+ # Input: # @::ARGV = command option ::: arg arg arg :::: argfiles # Uses: @@ -1710,29 +1714,47 @@ sub read_args_from_command_line { for(my $arg = shift @ARGV; @ARGV; $arg = shift @ARGV) { if($arg eq $Global::arg_sep or - $arg eq $Global::arg_file_sep) { + $arg eq $Global::arg_sep."+" + or + $arg eq $Global::arg_file_sep + or + $arg eq $Global::arg_file_sep."+") { my $group = $arg; # This group of arguments is args or argfiles my @group; while(defined ($arg = shift @ARGV)) { if($arg eq $Global::arg_sep or - $arg eq $Global::arg_file_sep) { + $arg eq $Global::arg_sep."+" + or + $arg eq $Global::arg_file_sep + or + $arg eq $Global::arg_file_sep."+") { # exit while loop if finding new separator last; } else { - # If not hitting ::: or :::: + # If not hitting ::: :::+ :::: or ::::+ # Append it to the group push @group, $arg; } } + if($group=~/\+$/) { + # :::+ or ::::+ + push @opt::xapplyinputsource, 1; + } else { + push @opt::xapplyinputsource, 0; + } if($group eq $Global::arg_file_sep + or + $group eq $Global::arg_file_sep."+" or ($opt::internal_pipe_means_argfiles and $opt::pipe) ) { # Group of file names on the command line. # Append args into -a push @opt::a, @group; - } elsif($group eq $Global::arg_sep) { + } elsif($group eq $Global::arg_sep + or + $group eq $Global::arg_sep."+") { # Group of arguments on the command line. # Put them into a file. # Create argfile @@ -9411,13 +9433,15 @@ sub nest_get { # make all new combinations my @combarg = (); for (my $fhn = 0; $fhn < $no_of_inputsources; $fhn++) { - push @combarg, [0, $#{$self->{'arg_matrix'}[$fhn]}]; + push(@combarg, [0, $#{$self->{'arg_matrix'}[$fhn]}], + # Is input source --xapply linked to the next? + $opt::xapplyinputsource[$fhn+1]); } - $combarg[$fhno] = [$len,$len]; # Find only combinations with this new entry + $combarg[2*$fhno] = [$len,$len]; # Find only combinations with this new entry # map combinations # [ 1, 3, 7 ], [ 2, 4, 1 ] # => - # [ m[0][1], m[1][3], m[3][7] ], [ m[0][2], m[1][4], m[2][1] ] + # [ m[0][1], m[1][3], m[2][7] ], [ m[0][2], m[1][4], m[2][1] ] my @mapped; for my $c (expand_combinations(@combarg)) { my @a; @@ -9429,7 +9453,9 @@ sub nest_get { # append the mapped to the ungotten arguments push @{$self->{'unget'}}, @mapped; # get the first - return shift @{$self->{'unget'}}; + if(@mapped) { + return shift @{$self->{'unget'}}; + } } } # all are eof or at EOF string; return from the unget queue @@ -9496,14 +9522,22 @@ sub expand_combinations { # Returns: ([x,y,...],[x,y,...]) # where xmin <= x <= xmax and ymin <= y <= ymax my $minmax_ref = shift; + my $xapply = shift; # This is linked to the next input source my $xmin = $$minmax_ref[0]; my $xmax = $$minmax_ref[1]; my @p; if(@_) { - # If there are more columns: Compute those recursively my @rest = expand_combinations(@_); - for(my $x = $xmin; $x <= $xmax; $x++) { - push @p, map { [$x, @$_] } @rest; + if($xapply) { + # Linked to next col with xapply + # TODO BUG does not wrap values if not same number of vals + push(@p, map { [$$_[0], @$_] } + grep { $xmin <= $$_[0] and $$_[0] <= $xmax } @rest); + } else { + # If there are more columns: Compute those recursively + for(my $x = $xmin; $x <= $xmax; $x++) { + push @p, map { [$x, @$_] } @rest; + } } } else { for(my $x = $xmin; $x <= $xmax; $x++) { diff --git a/src/sql b/src/sql index 82db4569..f3dc15fd 100755 --- a/src/sql +++ b/src/sql @@ -566,7 +566,7 @@ $Global::Initfile && unlink $Global::Initfile; exit ($err); sub parse_options { - $Global::version = 20160322; + $Global::version = 20160323; $Global::progname = 'sql'; # This must be done first as this may exec myself