From cef61b83c2ebecc9d90ae3ded309552e0e5bbb5a Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 19 Apr 2016 18:54:25 -0400 Subject: [PATCH] absent-doc iterate --- c/todo.txt | 5 ----- doc/content-for-reference.html | 21 ++++++++--------- doc/reference.html | 41 +++++++++++++++++----------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/c/todo.txt b/c/todo.txt index cee2c485d..dec3c771e 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -5,11 +5,6 @@ BUGFIXES vgrun mlr --ijson --opprint cat reg_test/input/small-non-nested-wrapped.json -* ok: - mlr --from ../data/small put '$new = NR == 3 ? $x : $i' - syntax error: - mlr --from ../data/small put '$new = (NR == 3 ? $x : $i) * 10' - ================================================================ TOP-OF-LIST SUMMARY diff --git a/doc/content-for-reference.html b/doc/content-for-reference.html index 15b3563b1..374e274f7 100644 --- a/doc/content-for-reference.html +++ b/doc/content-for-reference.html @@ -1319,16 +1319,15 @@ with the exception that the min and max functions are special: if one argument is non-null, it wins: POKI_RUN_COMMAND{{echo 'x=,y=3' | mlr put '$a=min($x,$y);$b=max($x,$y)'}}HERE -
  • Functions of absent variables (e.g. mlr put '$y = log10($nonesuch)') evaluate to absent, -and arithmetic/bitwise/boolean operators with both operands being absent evaluate to absent. Furthermore, -any expression which evaluates to absent is not stored in the output record: +
  • Functions of absent variables (e.g. mlr put '$y = +log10($nonesuch)') evaluate to absent, and arithmetic/bitwise/boolean +operators with both operands being absent evaluate to absent. +Arithmetic operators with one absent operand return the other operand. +More specifically, absent values act like zero for addition/subtraction, and +one for multiplication: Furthermore, any expression which evaluates to +absent is not stored in the output record: -POKI_RUN_COMMAND{{echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$x+$y'}}HERE - -
  • Arithmetic operators with one absent operand return the other -operand. More specifically, absent values act like zero for -addition/subtraction, and one for multiplication: -POKI_RUN_COMMAND{{echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$x+$y; $c=$u+$y'}}HERE +POKI_RUN_COMMAND{{echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$u+$y; $c=$x+$y'}}HERE POKI_RUN_COMMAND{{echo 'x=2,y=3' | mlr put '$a=min($x,$v);$b=max($u,$y);$c=min($u,$v)'}}HERE @@ -1375,9 +1374,7 @@ inputs present — you can use a pattern-action block with POKI_RUN_COMMAND{{mlr cat data/het.dkvp}}HERE POKI_RUN_COMMAND{{mlr put 'ispresent($loadsec) { $loadmillis = $loadsec * 1000 }' data/het.dkvp}}HERE - +POKI_RUN_COMMAND{{mlr put '$loadmillis = (ispresent($loadsec) ? $loadsec : 0.0) * 1000' data/het.dkvp}}HERE

    If you’re interested in a formal description of how empty and absent fields participate in arithmetic, here’s a table for plus (other diff --git a/doc/reference.html b/doc/reference.html index 1ea84523b..5910d8123 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -4874,27 +4874,19 @@ x=,y=3,a=3,b=3

    -

  • Functions of absent variables (e.g. mlr put '$y = log10($nonesuch)') evaluate to absent, -and arithmetic/bitwise/boolean operators with both operands being absent evaluate to absent. Furthermore, -any expression which evaluates to absent is not stored in the output record: +
  • Functions of absent variables (e.g. mlr put '$y = +log10($nonesuch)') evaluate to absent, and arithmetic/bitwise/boolean +operators with both operands being absent evaluate to absent. +Arithmetic operators with one absent operand return the other operand. +More specifically, absent values act like zero for addition/subtraction, and +one for multiplication: Furthermore, any expression which evaluates to +absent is not stored in the output record:

    -$ echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$x+$y'
    -x=2,y=3,b=5
    -
    -
    -

    - -

  • Arithmetic operators with one absent operand return the other -operand. More specifically, absent values act like zero for -addition/subtraction, and one for multiplication: -

    -

    -
    -$ echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$x+$y; $c=$u+$y'
    -x=2,y=3,b=5,c=3
    +$ echo 'x=2,y=3' | mlr put '$a=$u+$v; $b=$u+$y; $c=$x+$y'
    +x=2,y=3,b=3,c=5
     

    @@ -4973,9 +4965,18 @@ resource=/some/other/path,loadsec=0.97,ok=false,loadmillis=970.000000

    - +

    +

    +
    +$ mlr put '$loadmillis = (ispresent($loadsec) ? $loadsec : 0.0) * 1000' data/het.dkvp
    +resource=/path/to/file,loadsec=0.45,ok=true,loadmillis=450.000000
    +record_count=100,resource=/path/to/file,loadmillis=0.000000
    +resource=/path/to/second/file,loadsec=0.32,ok=true,loadmillis=320.000000
    +record_count=150,resource=/path/to/second/file,loadmillis=0.000000
    +resource=/some/other/path,loadsec=0.97,ok=false,loadmillis=970.000000
    +
    +
    +

    If you’re interested in a formal description of how empty and absent fields participate in arithmetic, here’s a table for plus (other