From 511a1bf3ee7842472a91524286ec0ce22e4fad8a Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 14 Dec 2021 22:11:40 -0500 Subject: [PATCH] bifs/arithmetic_test.go --- .vimrc | 3 +- Makefile | 29 +++++- internal/pkg/bifs/arithmetic.go | 43 ++++----- internal/pkg/bifs/arithmetic_test.go | 90 +++++++++++++++++++ internal/pkg/bifs/base.go | 2 +- internal/pkg/bifs/bits.go | 2 +- internal/pkg/bifs/bits_test.go | 19 ++++ internal/pkg/bifs/booleans.go | 26 ++++-- internal/pkg/bifs/collections.go | 8 +- internal/pkg/bifs/collections_test.go | 56 ++++++++++++ internal/pkg/bifs/datetime.go | 2 +- internal/pkg/bifs/hashing.go | 2 +- internal/pkg/bifs/hashing_test.go | 25 ++++++ internal/pkg/bifs/math.go | 2 +- internal/pkg/bifs/mathlib.go | 2 +- internal/pkg/bifs/random.go | 2 +- internal/pkg/bifs/regex.go | 2 +- internal/pkg/bifs/relative_time.go | 2 +- internal/pkg/bifs/sort.go | 2 +- .../pkg/bifs/{bifs_test.go => sort_test.go} | 9 +- internal/pkg/bifs/stats.go | 16 ++-- internal/pkg/bifs/strings.go | 8 +- internal/pkg/bifs/system.go | 2 +- internal/pkg/bifs/types.go | 2 +- .../pkg/dsl/cst/builtin_function_manager.go | 4 +- internal/pkg/dsl/cst/builtin_functions.go | 4 +- internal/pkg/dsl/cst/hofs.go | 4 +- internal/pkg/transformers/fraction.go | 2 +- .../transformers/utils/percentile-keeper.go | 2 +- .../transformers/utils/stats1-accumulators.go | 14 +-- .../pkg/types-parked/mlrval_collections.go | 24 ++--- todo.txt | 23 +++-- 32 files changed, 325 insertions(+), 108 deletions(-) create mode 100644 internal/pkg/bifs/arithmetic_test.go create mode 100644 internal/pkg/bifs/bits_test.go create mode 100644 internal/pkg/bifs/collections_test.go create mode 100644 internal/pkg/bifs/hashing_test.go rename internal/pkg/bifs/{bifs_test.go => sort_test.go} (91%) diff --git a/.vimrc b/.vimrc index 1a413f44a..562ce7c7f 100644 --- a/.vimrc +++ b/.vimrc @@ -3,4 +3,5 @@ map \r :w:!clear;echo Building ...; echo; make tests-in-order "map \f :w:!clear;echo Building ...; echo; make mlrval-tests "map \f :w:!clear;echo Building ...; echo; make mlrmap-tests "map \f :w:!clear;echo Building ...; echo; make input-tests -map \f :w:!clear;echo Building ...; echo; make mlrval-format-test +"map \f :w:!clear;echo Building ...; echo; make mlrval-format-test +map \f :w:!clear;echo Building ...; echo; make bifs-tests diff --git a/Makefile b/Makefile index c89b2acd7..4c8de0225 100644 --- a/Makefile +++ b/Makefile @@ -96,12 +96,39 @@ input-dkvp-test: internal/pkg/input/record_reader_dkvp_nidx.go input-tests: input-dkvp-test +bifs-arithmetic-test: + go test internal/pkg/bifs/arithmetic_test.go \ + internal/pkg/bifs/base.go \ + internal/pkg/bifs/arithmetic.go +bifs-bits-test: + go test internal/pkg/bifs/bits_test.go \ + internal/pkg/bifs/base.go \ + internal/pkg/bifs/arithmetic.go \ + internal/pkg/bifs/bits.go +bifs-collections-test: + go test internal/pkg/bifs/bits_test.go \ + internal/pkg/bifs/base.go \ + internal/pkg/bifs/arithmetic.go \ + internal/pkg/bifs/collections.go +bifs-hashing-test: + go test internal/pkg/bifs/hashing_test.go \ + internal/pkg/bifs/base.go \ + internal/pkg/bifs/arithmetic.go \ + internal/pkg/bifs/hashing.go +bifs-sort-test: + go test internal/pkg/bifs/sort_test.go \ + internal/pkg/bifs/base.go \ + internal/pkg/bifs/arithmetic.go \ + internal/pkg/bifs/sort.go + +bifs-tests: bifs-arithmetic-test bifs-bits-test bifs-collections-test bifs-hashing-test bifs-sort-test + #mlrval_functions_test: # go test internal/pkg/types/mlrval_functions_test.go $(ls internal/pkg/types/*.go | grep -v test) #mlrval_format_test: # go test internal/pkg/types/mlrval_format_test.go $(ls internal/pkg/types/*.go|grep -v test) -tests-in-order: mlrval-tests mlrmap-tests input-tests +tests-in-order: mlrval-tests mlrmap-tests input-tests bifs-tests # ---------------------------------------------------------------- # Regression tests (large number) diff --git a/internal/pkg/bifs/arithmetic.go b/internal/pkg/bifs/arithmetic.go index ad830656d..03aaacdc6 100644 --- a/internal/pkg/bifs/arithmetic.go +++ b/internal/pkg/bifs/arithmetic.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "math" @@ -56,20 +56,9 @@ func BIF_minus_unary(input1 *mlrval.Mlrval) *mlrval.Mlrval { return uneg_dispositions[input1.Type()](input1) } -// ================================================================ -// Logical NOT operator - -func BIF_logicalnot(input1 *mlrval.Mlrval) *mlrval.Mlrval { - if input1.IsBool() { - return mlrval.FromBool(!input1.AcquireBoolValue()) - } else { - return mlrval.ERROR - } -} - // ================================================================ // Addition with auto-overflow from int to float when necessary. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic // Auto-overflows up to float. Additions & subtractions overflow by at most // one bit so it suffices to check sign-changes. @@ -127,7 +116,7 @@ func BIF_plus_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Subtraction with auto-overflow from int to float when necessary. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic // Adds & subtracts overflow by at most one bit so it suffices to check // sign-changes. @@ -185,7 +174,7 @@ func BIF_minus_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Multiplication with auto-overflow from int to float when necessary. See -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic // Auto-overflows up to float. // @@ -259,7 +248,7 @@ func BIF_times(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Pythonic division. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic // // Int/int pairings don't produce overflow. // @@ -330,7 +319,7 @@ func BIF_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Integer division: DSL operator '//' as in Python. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func int_divide_n_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { a := input1.AcquireIntValue() @@ -391,7 +380,7 @@ func BIF_int_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Non-auto-overflowing addition: DSL operator '.+'. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func dotplus_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromInt(input1.AcquireIntValue() + input2.AcquireIntValue()) @@ -427,7 +416,7 @@ func BIF_dot_plus(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ================================================================ // Non-auto-overflowing subtraction: DSL operator '.-'. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func dotminus_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromInt(input1.AcquireIntValue() - input2.AcquireIntValue()) @@ -463,7 +452,7 @@ func BIF_dot_minus(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ---------------------------------------------------------------- // Non-auto-overflowing multiplication: DSL operator '.*'. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func dottimes_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromInt(input1.AcquireIntValue() * input2.AcquireIntValue()) @@ -499,7 +488,7 @@ func BIF_dot_times(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ---------------------------------------------------------------- // 64-bit integer division: DSL operator './'. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func dotdivide_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromInt(input1.AcquireIntValue() / input2.AcquireIntValue()) @@ -535,7 +524,7 @@ func BIF_dot_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { // ---------------------------------------------------------------- // 64-bit integer division: DSL operator './/'. See also -// https://johnkerl.org/miller6/reference-main-arithmetic.html +// https://miller.readthedocs.io/en/latest/reference-main-arithmetic func dotidivide_i_ii(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { a := input1.AcquireIntValue() @@ -590,7 +579,7 @@ var dotidivide_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{ /*FUNC */ {_erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro}, } -func MlrvalDotIntDivide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_dot_int_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return dotidivide_dispositions[input1.Type()][input2.Type()](input1, input2) } @@ -826,7 +815,7 @@ var min_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{ /*FUNC */ {_erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro}, } -func MlrvalBinaryMin(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_min_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return (min_dispositions[input1.Type()][input2.Type()])(input1, input2) } @@ -837,7 +826,7 @@ func BIF_min_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval { retval := mlrvals[0] for i := range mlrvals { if i > 0 { - retval = MlrvalBinaryMin(retval, mlrvals[i]) + retval = BIF_min_binary(retval, mlrvals[i]) } } return retval @@ -910,7 +899,7 @@ var max_dispositions = [mlrval.MT_DIM][mlrval.MT_DIM]BinaryFunc{ /*FUNC */ {_erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro, _erro}, } -func MlrvalBinaryMax(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_max_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { return (max_dispositions[input1.Type()][input2.Type()])(input1, input2) } @@ -921,7 +910,7 @@ func BIF_max_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval { retval := mlrvals[0] for i := range mlrvals { if i > 0 { - retval = MlrvalBinaryMax(retval, mlrvals[i]) + retval = BIF_max_binary(retval, mlrvals[i]) } } return retval diff --git a/internal/pkg/bifs/arithmetic_test.go b/internal/pkg/bifs/arithmetic_test.go new file mode 100644 index 000000000..5935854ac --- /dev/null +++ b/internal/pkg/bifs/arithmetic_test.go @@ -0,0 +1,90 @@ +package bifs + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/johnkerl/miller/internal/pkg/mlrval" +) + +func TestBIF_plus_unary(t *testing.T) { + input := mlrval.FromDeferredType("123") + output := BIF_plus_unary(input) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, 123, intval) + + input = mlrval.FromDeferredType("-123.5") + output = BIF_plus_unary(input) + floatval, ok := output.GetFloatValue() + assert.True(t, ok) + assert.Equal(t, -123.5, floatval) +} + +func TestBIF_minus_unary(t *testing.T) { + input := mlrval.FromDeferredType("123") + output := BIF_minus_unary(input) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, -123, intval) + + input = mlrval.FromDeferredType("-123.5") + output = BIF_minus_unary(input) + floatval, ok := output.GetFloatValue() + assert.True(t, ok) + assert.Equal(t, 123.5, floatval) +} + +func TestBIF_plus_binary(t *testing.T) { + input1 := mlrval.FromDeferredType("123") + input2 := mlrval.FromDeferredType("456") + output := BIF_plus_binary(input1, input2) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, 579, intval) + + input1 = mlrval.FromDeferredType("123.5") + input2 = mlrval.FromDeferredType("456") + output = BIF_plus_binary(input1, input2) + floatval, ok := output.GetFloatValue() + assert.True(t, ok) + assert.Equal(t, 579.5, floatval) +} + +func TestBIF_plus_binary_overflow(t *testing.T) { + input1 := mlrval.FromInt(0x07ffffffffffffff) + input2 := mlrval.FromInt(0x07fffffffffffffe) + output := BIF_plus_binary(input1, input2) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, 0x0ffffffffffffffd, intval) + + input1 = mlrval.FromInt(0x7fffffffffffffff) + input2 = mlrval.FromInt(0x7ffffffffffffffe) + output = BIF_plus_binary(input1, input2) + floatval, ok := output.GetFloatValue() + assert.True(t, ok) + assert.Equal(t, 18446744073709552000.0, floatval) +} + +// TODO: copy in more unit-test cases from existing regression-test data + +//func BIF_minus_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_times(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_int_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_dot_plus(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_dot_minus(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_dot_times(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_dot_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_dot_int_divide(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_modulus(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_mod_add(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_mod_sub(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_mod_mul(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_mod_exp(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_min_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_min_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval +//func BIF_max_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +//func BIF_max_variadic(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval diff --git a/internal/pkg/bifs/base.go b/internal/pkg/bifs/base.go index 435117993..cd7c04160 100644 --- a/internal/pkg/bifs/base.go +++ b/internal/pkg/bifs/base.go @@ -45,7 +45,7 @@ // ('s') to anything else ('x'). // ================================================================ -package types +package bifs import ( "github.com/johnkerl/miller/internal/pkg/mlrval" diff --git a/internal/pkg/bifs/bits.go b/internal/pkg/bifs/bits.go index 78bdbbbd3..71be7c9a6 100644 --- a/internal/pkg/bifs/bits.go +++ b/internal/pkg/bifs/bits.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "github.com/johnkerl/miller/internal/pkg/mlrval" diff --git a/internal/pkg/bifs/bits_test.go b/internal/pkg/bifs/bits_test.go new file mode 100644 index 000000000..1c5bec2a4 --- /dev/null +++ b/internal/pkg/bifs/bits_test.go @@ -0,0 +1,19 @@ +package bifs + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/johnkerl/miller/internal/pkg/mlrval" +) + +func TestBIF_bitcount(t *testing.T) { + input1 := mlrval.FromDeferredType("0xcafe") + output := BIF_bitcount(input1) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, 11, intval) +} + +// TODO: copy in more unit-test cases from existing regression-test data diff --git a/internal/pkg/bifs/booleans.go b/internal/pkg/bifs/booleans.go index 89cd8b3fd..8228750fc 100644 --- a/internal/pkg/bifs/booleans.go +++ b/internal/pkg/bifs/booleans.go @@ -2,7 +2,7 @@ // Boolean expressions for ==, !=, >, >=, <, <= // ================================================================ -package types +package bifs import ( "github.com/johnkerl/miller/internal/pkg/lib" @@ -400,7 +400,7 @@ func BIF_cmp(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } // For Go's sort.Slice. -func MlrvalLessThanAsBool(input1, input2 *mlrval.Mlrval) bool { +func BIF_less_than_as_bool(input1, input2 *mlrval.Mlrval) bool { // TODO refactor to avoid copy // This is a hot path for sort GC and is worth significant hand-optimization mretval := lt_dispositions[input1.Type()][input2.Type()](input1, input2) @@ -410,7 +410,7 @@ func MlrvalLessThanAsBool(input1, input2 *mlrval.Mlrval) bool { } // For Go's sort.Slice. -func MlrvalLessThanOrEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { +func BIF_less_than_or_equals_as_bool(input1, input2 *mlrval.Mlrval) bool { // TODO refactor to avoid copy // This is a hot path for sort GC and is worth significant hand-optimization mretval := le_dispositions[input1.Type()][input2.Type()](input1, input2) @@ -420,7 +420,7 @@ func MlrvalLessThanOrEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { } // For top-keeper -func MlrvalGreaterThanAsBool(input1, input2 *mlrval.Mlrval) bool { +func BIF_greater_than_as_bool(input1, input2 *mlrval.Mlrval) bool { // TODO refactor to avoid copy // This is a hot path for sort GC and is worth significant hand-optimization mretval := gt_dispositions[input1.Type()][input2.Type()](input1, input2) @@ -430,7 +430,7 @@ func MlrvalGreaterThanAsBool(input1, input2 *mlrval.Mlrval) bool { } // For top-keeper -func MlrvalGreaterThanOrEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { +func BIF_greater_than_or_equals_as_bool(input1, input2 *mlrval.Mlrval) bool { // TODO refactor to avoid copy // This is a hot path for sort GC and is worth significant hand-optimization mretval := ge_dispositions[input1.Type()][input2.Type()](input1, input2) @@ -440,7 +440,7 @@ func MlrvalGreaterThanOrEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { } // Convenience wrapper for non-DSL callsites that just want a bool -func MlrvalEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { +func BIF_equals_as_bool(input1, input2 *mlrval.Mlrval) bool { mretval := eq_dispositions[input1.Type()][input2.Type()](input1, input2) retval, ok := mretval.GetBoolValue() lib.InternalCodingErrorIf(!ok) @@ -448,7 +448,15 @@ func MlrvalEqualsAsBool(input1, input2 *mlrval.Mlrval) bool { } // ---------------------------------------------------------------- -func MlrvalLogicalAND(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_logical_NOT(input1 *mlrval.Mlrval) *mlrval.Mlrval { + if input1.IsBool() { + return mlrval.FromBool(!input1.AcquireBoolValue()) + } else { + return mlrval.ERROR + } +} + +func BIF_logical_AND(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { if input1.IsBool() && input2.IsBool() { return mlrval.FromBool(input1.AcquireBoolValue() && input2.AcquireBoolValue()) } else { @@ -456,7 +464,7 @@ func MlrvalLogicalAND(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } } -func MlrvalLogicalOR(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_logical_OR(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { if input1.IsBool() && input2.IsBool() { return mlrval.FromBool(input1.AcquireBoolValue() || input2.AcquireBoolValue()) } else { @@ -464,7 +472,7 @@ func MlrvalLogicalOR(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { } } -func BIF_logicalxor(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_logical_XOR(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { if input1.IsBool() && input2.IsBool() { return mlrval.FromBool(input1.AcquireBoolValue() != input2.AcquireBoolValue()) } else { diff --git a/internal/pkg/bifs/collections.go b/internal/pkg/bifs/collections.go index 9d003f5c6..649e1d66f 100644 --- a/internal/pkg/bifs/collections.go +++ b/internal/pkg/bifs/collections.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "bytes" @@ -573,12 +573,12 @@ func BIF_splitax(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval { input := input1.AcquireStringValue() fieldSeparator := input2.AcquireStringValue() - return mlrvalSplitAXHelper(input, fieldSeparator) + return bif_splitax_helper(input, fieldSeparator) } -// mlrvalSplitAXHelper is Split out for the benefit of BIF_splitax and +// bif_splitax_helper is split out for the benefit of BIF_splitax and // BIF_unflatten. -func mlrvalSplitAXHelper(input string, separator string) *mlrval.Mlrval { +func bif_splitax_helper(input string, separator string) *mlrval.Mlrval { fields := lib.SplitString(input, separator) output := NewSizedMlrvalArray(int(len(fields))) diff --git a/internal/pkg/bifs/collections_test.go b/internal/pkg/bifs/collections_test.go new file mode 100644 index 000000000..c3e479a25 --- /dev/null +++ b/internal/pkg/bifs/collections_test.go @@ -0,0 +1,56 @@ +package bifs + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/johnkerl/miller/internal/pkg/mlrval" +) + +func TestBIF_length(t *testing.T) { + input1 := mlrval.FromInt(123) + output := BIF_length(input1) + intval, ok := output.GetIntValue() + assert.True(t, ok) + assert.Equal(t, 1, intval) +} + +// TODO: copy in more unit-test cases from existing regression-test data + +// func BIF_length(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func depth_from_array(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func depth_from_map(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func depth_from_scalar(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_depth(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func leafcount_from_array(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func leafcount_from_map(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func leafcount_from_scalar(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_leafcount(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func has_key_in_array(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func has_key_in_map(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_haskey(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_mapselect(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval +// func BIF_mapexcept(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval +// func BIF_mapsum(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval +// func BIF_mapdiff(mlrvals []*mlrval.Mlrval) *mlrval.Mlrval +// func BIF_joink(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_joinv(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_joinkv(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splitkv(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splitkvx(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splitnv(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splitnvx(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splita(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_splitax(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func mlrvalSplitAXHelper(input string, separator string) *mlrval.Mlrval +// func BIF_get_keys(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_get_values(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_append(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_flatten(input1, input2, input3 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_flatten_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_unflatten(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_arrayify(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_json_parse(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_json_stringify_unary(input1 *mlrval.Mlrval) *mlrval.Mlrval +// func BIF_json_stringify_binary(input1, input2 *mlrval.Mlrval) *mlrval.Mlrval diff --git a/internal/pkg/bifs/datetime.go b/internal/pkg/bifs/datetime.go index a35c10c3d..af39fc971 100644 --- a/internal/pkg/bifs/datetime.go +++ b/internal/pkg/bifs/datetime.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "fmt" diff --git a/internal/pkg/bifs/hashing.go b/internal/pkg/bifs/hashing.go index 976202bb9..6c6c0ce39 100644 --- a/internal/pkg/bifs/hashing.go +++ b/internal/pkg/bifs/hashing.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "crypto/md5" diff --git a/internal/pkg/bifs/hashing_test.go b/internal/pkg/bifs/hashing_test.go new file mode 100644 index 000000000..3e736c0a0 --- /dev/null +++ b/internal/pkg/bifs/hashing_test.go @@ -0,0 +1,25 @@ +package bifs + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/johnkerl/miller/internal/pkg/mlrval" +) + +func TestBIF_md5(t *testing.T) { + input1 := mlrval.FromDeferredType("") + output := BIF_md5(input1) + stringval, ok := output.GetStringValue() + assert.True(t, ok) + assert.Equal(t, "d41d8cd98f00b204e9800998ecf8427e", stringval) + + input1 = mlrval.FromDeferredType("miller") + output = BIF_md5(input1) + stringval, ok = output.GetStringValue() + assert.True(t, ok) + assert.Equal(t, "f0af962ddbc82430e947390b2f3f6e49", stringval) +} + +// TODO: copy in more unit-test cases from existing regression-test data diff --git a/internal/pkg/bifs/math.go b/internal/pkg/bifs/math.go index 00e263633..e92712c4f 100644 --- a/internal/pkg/bifs/math.go +++ b/internal/pkg/bifs/math.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "github.com/johnkerl/miller/internal/pkg/mlrval" diff --git a/internal/pkg/bifs/mathlib.go b/internal/pkg/bifs/mathlib.go index fa35782cf..f98fd7b51 100644 --- a/internal/pkg/bifs/mathlib.go +++ b/internal/pkg/bifs/mathlib.go @@ -2,7 +2,7 @@ // Go math-library functions // ================================================================ -package types +package bifs import ( "math" diff --git a/internal/pkg/bifs/random.go b/internal/pkg/bifs/random.go index 43d9997ed..b345e6d65 100644 --- a/internal/pkg/bifs/random.go +++ b/internal/pkg/bifs/random.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "math" diff --git a/internal/pkg/bifs/regex.go b/internal/pkg/bifs/regex.go index c5f30da9e..448a62278 100644 --- a/internal/pkg/bifs/regex.go +++ b/internal/pkg/bifs/regex.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "strings" diff --git a/internal/pkg/bifs/relative_time.go b/internal/pkg/bifs/relative_time.go index 9779fb305..8801017ef 100644 --- a/internal/pkg/bifs/relative_time.go +++ b/internal/pkg/bifs/relative_time.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "fmt" diff --git a/internal/pkg/bifs/sort.go b/internal/pkg/bifs/sort.go index 4fe937030..d7d0ddafe 100644 --- a/internal/pkg/bifs/sort.go +++ b/internal/pkg/bifs/sort.go @@ -2,7 +2,7 @@ // For sorting // ================================================================ -package types +package bifs import ( "fmt" diff --git a/internal/pkg/bifs/bifs_test.go b/internal/pkg/bifs/sort_test.go similarity index 91% rename from internal/pkg/bifs/bifs_test.go rename to internal/pkg/bifs/sort_test.go index 67ee073c2..a47574c80 100644 --- a/internal/pkg/bifs/bifs_test.go +++ b/internal/pkg/bifs/sort_test.go @@ -1,12 +1,9 @@ -// ================================================================ -// Most Miller tests (thousands of them) are command-line-driven via -// mlr regtest. Here are some cases needing special focus. -// ================================================================ - -package types +package bifs import ( "testing" + + "github.com/johnkerl/miller/internal/pkg/mlrval" ) // ---------------------------------------------------------------- diff --git a/internal/pkg/bifs/stats.go b/internal/pkg/bifs/stats.go index c64b408c3..efcabec76 100644 --- a/internal/pkg/bifs/stats.go +++ b/internal/pkg/bifs/stats.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "math" @@ -24,7 +24,7 @@ import ( // output = [m, b, math.sqrt(var_m), math.sqrt(var_b)] // ---------------------------------------------------------------- -func MlrvalGetVar(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_get_var(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { n, isInt := mn.GetIntValue() lib.InternalCodingErrorIf(!isInt) sum, isNumber := msum.GetNumericToFloatValue() @@ -46,8 +46,8 @@ func MlrvalGetVar(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { } // ---------------------------------------------------------------- -func MlrvalGetStddev(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { - mvar := MlrvalGetVar(mn, msum, msum2) +func BIF_get_stddev(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { + mvar := BIF_get_var(mn, msum, msum2) if mvar.IsVoid() { return mvar } @@ -55,8 +55,8 @@ func MlrvalGetStddev(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { } // ---------------------------------------------------------------- -func MlrvalGetMeanEB(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { - mvar := MlrvalGetVar(mn, msum, msum2) +func BIF_get_mean_EB(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { + mvar := BIF_get_var(mn, msum, msum2) if mvar.IsVoid() { return mvar } @@ -87,7 +87,7 @@ func MlrvalGetMeanEB(mn, msum, msum2 *mlrval.Mlrval) *mlrval.Mlrval { // = sumx2 - n mean^2 // ---------------------------------------------------------------- -func MlrvalGetSkewness(mn, msum, msum2, msum3 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_get_skewness(mn, msum, msum2, msum3 *mlrval.Mlrval) *mlrval.Mlrval { n, isInt := mn.GetIntValue() lib.InternalCodingErrorIf(!isInt) if n < 2 { @@ -124,7 +124,7 @@ func MlrvalGetSkewness(mn, msum, msum2, msum3 *mlrval.Mlrval) *mlrval.Mlrval { // = sumx4 - mean*(4 sumx3 - mean*(6 sumx2 - 3 n mean^2)) // ---------------------------------------------------------------- -func MlrvalGetKurtosis(mn, msum, msum2, msum3, msum4 *mlrval.Mlrval) *mlrval.Mlrval { +func BIF_get_kurtosis(mn, msum, msum2, msum3, msum4 *mlrval.Mlrval) *mlrval.Mlrval { n, isInt := mn.GetIntValue() lib.InternalCodingErrorIf(!isInt) if n < 2 { diff --git a/internal/pkg/bifs/strings.go b/internal/pkg/bifs/strings.go index 48b13e099..95a893427 100644 --- a/internal/pkg/bifs/strings.go +++ b/internal/pkg/bifs/strings.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "regexp" @@ -217,10 +217,10 @@ func BIF_strip(input1 *mlrval.Mlrval) *mlrval.Mlrval { // ---------------------------------------------------------------- func BIF_collapse_whitespace(input1 *mlrval.Mlrval) *mlrval.Mlrval { - return MlrvalCollapseWhitespaceRegexp(input1, WhitespaceRegexp()) + return BIF_collapse_whitespace_regexp(input1, WhitespaceRegexp()) } -func MlrvalCollapseWhitespaceRegexp(input1 *mlrval.Mlrval, whitespaceRegexp *regexp.Regexp) *mlrval.Mlrval { +func BIF_collapse_whitespace_regexp(input1 *mlrval.Mlrval, whitespaceRegexp *regexp.Regexp) *mlrval.Mlrval { if input1.IsString() { return mlrval.FromString(whitespaceRegexp.ReplaceAllString(input1.AcquireStringValue(), " ")) } else { @@ -273,7 +273,7 @@ func BIF_capitalize(input1 *mlrval.Mlrval) *mlrval.Mlrval { // ---------------------------------------------------------------- func BIF_clean_whitespace(input1 *mlrval.Mlrval) *mlrval.Mlrval { return BIF_strip( - MlrvalCollapseWhitespaceRegexp( + BIF_collapse_whitespace_regexp( input1, WhitespaceRegexp(), ), ) diff --git a/internal/pkg/bifs/system.go b/internal/pkg/bifs/system.go index b35c5737d..974325b8e 100644 --- a/internal/pkg/bifs/system.go +++ b/internal/pkg/bifs/system.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "os" diff --git a/internal/pkg/bifs/types.go b/internal/pkg/bifs/types.go index 912af535a..bd2347421 100644 --- a/internal/pkg/bifs/types.go +++ b/internal/pkg/bifs/types.go @@ -1,4 +1,4 @@ -package types +package bifs import ( "fmt" diff --git a/internal/pkg/dsl/cst/builtin_function_manager.go b/internal/pkg/dsl/cst/builtin_function_manager.go index d90eec326..2367349fd 100644 --- a/internal/pkg/dsl/cst/builtin_function_manager.go +++ b/internal/pkg/dsl/cst/builtin_function_manager.go @@ -263,7 +263,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { name: "!", class: FUNC_CLASS_BOOLEAN, help: `Logical negation.`, - unaryFunc: types.BIF_logicalnot, + unaryFunc: types.BIF_logical_NOT, }, { @@ -348,7 +348,7 @@ func makeBuiltinFunctionLookupTable() []BuiltinFunctionInfo { name: "^^", class: FUNC_CLASS_BOOLEAN, help: `Logical XOR.`, - binaryFunc: types.BIF_logicalxor, + binaryFunc: types.BIF_logical_XOR, }, { diff --git a/internal/pkg/dsl/cst/builtin_functions.go b/internal/pkg/dsl/cst/builtin_functions.go index 760303019..4d4cc9d33 100644 --- a/internal/pkg/dsl/cst/builtin_functions.go +++ b/internal/pkg/dsl/cst/builtin_functions.go @@ -805,7 +805,7 @@ func (node *LogicalANDOperatorNode) Evaluate( return types.MLRVAL_ABSENT } - return mlrval.MlrvalLogicalAND(aout, bout) + return mlrval.BIF_logical_AND(aout, bout) } // ================================================================ @@ -852,7 +852,7 @@ func (node *LogicalOROperatorNode) Evaluate( if btype == types.MT_ABSENT { return types.MLRVAL_ABSENT } - return mlrval.MlrvalLogicalOR(aout, bout) + return mlrval.BIF_logical_OR(aout, bout) } // ================================================================ diff --git a/internal/pkg/dsl/cst/hofs.go b/internal/pkg/dsl/cst/hofs.go index 12cd187a4..ef2bd7fe4 100644 --- a/internal/pkg/dsl/cst/hofs.go +++ b/internal/pkg/dsl/cst/hofs.go @@ -616,11 +616,11 @@ func sortA( func sortANumerical(array []mlrval.Mlrval, reverse bool) { if !reverse { sort.Slice(array, func(i, j int) bool { - return mlrval.MlrvalLessThanAsBool(&array[i], &array[j]) + return mlrval.BIF_less_than_as_bool(&array[i], &array[j]) }) } else { sort.Slice(array, func(i, j int) bool { - return mlrval.MlrvalGreaterThanAsBool(&array[i], &array[j]) + return mlrval.BIF_greater_than_as_bool(&array[i], &array[j]) }) } } diff --git a/internal/pkg/transformers/fraction.go b/internal/pkg/transformers/fraction.go index 5074c627c..96cb03f22 100644 --- a/internal/pkg/transformers/fraction.go +++ b/internal/pkg/transformers/fraction.go @@ -267,7 +267,7 @@ func (tr *TransformerFraction) Transform( } denominator := sumsForGroup[fractionFieldName] - if !mlrval.MlrvalEqualsAsBool(value, tr.zero) { + if !mlrval.BIF_equals_as_bool(value, tr.zero) { outputValue = bifs.BIF_divide(numerator, denominator) outputValue = bifs.BIF_times(outputValue, tr.multiplier) } else { diff --git a/internal/pkg/transformers/utils/percentile-keeper.go b/internal/pkg/transformers/utils/percentile-keeper.go index 3219bccd7..a13127fb4 100644 --- a/internal/pkg/transformers/utils/percentile-keeper.go +++ b/internal/pkg/transformers/utils/percentile-keeper.go @@ -258,7 +258,7 @@ func getPercentileLinearlyInterpolated(array []*mlrval.Mlrval, n int, p float64) func (keeper *PercentileKeeper) sortIfNecessary() { if !keeper.sorted { sort.Slice(keeper.data, func(i, j int) bool { - return mlrval.MlrvalLessThanAsBool(keeper.data[i], keeper.data[j]) + return mlrval.BIF_less_than_as_bool(keeper.data[i], keeper.data[j]) }) keeper.sorted = true } diff --git a/internal/pkg/transformers/utils/stats1-accumulators.go b/internal/pkg/transformers/utils/stats1-accumulators.go index c0fee9e84..0bd4f9d07 100644 --- a/internal/pkg/transformers/utils/stats1-accumulators.go +++ b/internal/pkg/transformers/utils/stats1-accumulators.go @@ -440,7 +440,7 @@ func NewStats1MinAccumulator() IStats1Accumulator { } } func (acc *Stats1MinAccumulator) Ingest(value *mlrval.Mlrval) { - acc.min = mlrval.MlrvalBinaryMin(acc.min, value) + acc.min = mlrval.BIF_min_binary(acc.min, value) } func (acc *Stats1MinAccumulator) Emit() *mlrval.Mlrval { if acc.min.IsAbsent() { @@ -464,7 +464,7 @@ func NewStats1MaxAccumulator() IStats1Accumulator { } } func (acc *Stats1MaxAccumulator) Ingest(value *mlrval.Mlrval) { - acc.max = mlrval.MlrvalBinaryMax(acc.max, value) + acc.max = mlrval.BIF_max_binary(acc.max, value) } func (acc *Stats1MaxAccumulator) Emit() *mlrval.Mlrval { if acc.max.IsAbsent() { @@ -498,7 +498,7 @@ func (acc *Stats1VarAccumulator) Ingest(value *mlrval.Mlrval) { acc.sum2 = types.BIF_plus_binary(acc.sum2, value2) } func (acc *Stats1VarAccumulator) Emit() *mlrval.Mlrval { - return mlrval.MlrvalGetVar(mlrval.MlrvalFromInt(acc.count), acc.sum, acc.sum2) + return mlrval.BIF_get_var(mlrval.MlrvalFromInt(acc.count), acc.sum, acc.sum2) } func (acc *Stats1VarAccumulator) Reset() { acc.count = 0 @@ -527,7 +527,7 @@ func (acc *Stats1StddevAccumulator) Ingest(value *mlrval.Mlrval) { acc.sum2 = types.BIF_plus_binary(acc.sum2, value2) } func (acc *Stats1StddevAccumulator) Emit() *mlrval.Mlrval { - return mlrval.MlrvalGetStddev(mlrval.MlrvalFromInt(acc.count), acc.sum, acc.sum2) + return mlrval.BIF_get_stddev(mlrval.MlrvalFromInt(acc.count), acc.sum, acc.sum2) } func (acc *Stats1StddevAccumulator) Reset() { acc.count = 0 @@ -557,7 +557,7 @@ func (acc *Stats1MeanEBAccumulator) Ingest(value *mlrval.Mlrval) { } func (acc *Stats1MeanEBAccumulator) Emit() *mlrval.Mlrval { mcount := mlrval.MlrvalFromInt(acc.count) - return mlrval.MlrvalGetMeanEB(mcount, acc.sum, acc.sum2) + return mlrval.BIF_get_mean_EB(mcount, acc.sum, acc.sum2) } func (acc *Stats1MeanEBAccumulator) Reset() { acc.count = 0 @@ -591,7 +591,7 @@ func (acc *Stats1SkewnessAccumulator) Ingest(value *mlrval.Mlrval) { } func (acc *Stats1SkewnessAccumulator) Emit() *mlrval.Mlrval { mcount := mlrval.MlrvalFromInt(acc.count) - return mlrval.MlrvalGetSkewness(mcount, acc.sum, acc.sum2, acc.sum3) + return mlrval.BIF_get_skewness(mcount, acc.sum, acc.sum2, acc.sum3) } func (acc *Stats1SkewnessAccumulator) Reset() { acc.count = 0 @@ -630,7 +630,7 @@ func (acc *Stats1KurtosisAccumulator) Ingest(value *mlrval.Mlrval) { } func (acc *Stats1KurtosisAccumulator) Emit() *mlrval.Mlrval { mcount := mlrval.MlrvalFromInt(acc.count) - return mlrval.MlrvalGetKurtosis(mcount, acc.sum, acc.sum2, acc.sum3, acc.sum4) + return mlrval.BIF_get_kurtosis(mcount, acc.sum, acc.sum2, acc.sum3, acc.sum4) } func (acc *Stats1KurtosisAccumulator) Reset() { acc.count = 0 diff --git a/internal/pkg/types-parked/mlrval_collections.go b/internal/pkg/types-parked/mlrval_collections.go index d12f5b017..3cd7037bd 100644 --- a/internal/pkg/types-parked/mlrval_collections.go +++ b/internal/pkg/types-parked/mlrval_collections.go @@ -575,18 +575,18 @@ func BsearchMlrvalArrayForDescendingInsert( return 0 } - if MlrvalGreaterThanAsBool(value, (*array)[0]) { + if BIF_greater_than_as_bool(value, (*array)[0]) { return 0 } - if MlrvalLessThanAsBool(value, (*array)[hi]) { + if BIF_less_than_as_bool(value, (*array)[hi]) { return size } for lo < hi { middleElement := (*array)[mid] - if MlrvalEqualsAsBool(value, middleElement) { + if BIF_equals_as_bool(value, middleElement) { return mid - } else if MlrvalGreaterThanAsBool(value, middleElement) { + } else if BIF_greater_than_as_bool(value, middleElement) { hi = mid newmid = (hi + lo) / 2 } else { @@ -594,9 +594,9 @@ func BsearchMlrvalArrayForDescendingInsert( newmid = (hi + lo) / 2 } if mid == newmid { - if MlrvalGreaterThanOrEqualsAsBool(value, (*array)[lo]) { + if BIF_greater_than_or_equals_as_bool(value, (*array)[lo]) { return lo - } else if MlrvalGreaterThanOrEqualsAsBool(value, (*array)[hi]) { + } else if BIF_greater_than_or_equals_as_bool(value, (*array)[hi]) { return hi } else { return hi + 1 @@ -622,18 +622,18 @@ func BsearchMlrvalArrayForAscendingInsert( return 0 } - if MlrvalLessThanAsBool(value, (*array)[0]) { + if BIF_less_than_as_bool(value, (*array)[0]) { return 0 } - if MlrvalGreaterThanAsBool(value, (*array)[hi]) { + if BIF_greater_than_as_bool(value, (*array)[hi]) { return size } for lo < hi { middleElement := (*array)[mid] - if MlrvalEqualsAsBool(value, middleElement) { + if BIF_equals_as_bool(value, middleElement) { return mid - } else if MlrvalLessThanAsBool(value, middleElement) { + } else if BIF_less_than_as_bool(value, middleElement) { hi = mid newmid = (hi + lo) / 2 } else { @@ -641,9 +641,9 @@ func BsearchMlrvalArrayForAscendingInsert( newmid = (hi + lo) / 2 } if mid == newmid { - if MlrvalLessThanOrEqualsAsBool(value, (*array)[lo]) { + if BIF_less_than_or_equals_as_bool(value, (*array)[lo]) { return lo - } else if MlrvalLessThanOrEqualsAsBool(value, (*array)[hi]) { + } else if BIF_less_than_or_equals_as_bool(value, (*array)[hi]) { return hi } else { return hi + 1 diff --git a/todo.txt b/todo.txt index 7eda5d923..6590403aa 100644 --- a/todo.txt +++ b/todo.txt @@ -4,6 +4,12 @@ PUNCHDOWN LIST * --ifs-regex & --ips-regex -- guessing is not safe as evidence by '.' and '|' * JIT next: o mlrmap copy + o krepl miller6 new doclink-comments + +* perf next: + o batchify source-quench + ! hash-records back off + ? further channelize (CSV-first focus) mlrval infer vs record-put ? * big-picture item @ Rmd (csv memes; and beyond); also webdoc intro page @@ -100,8 +106,9 @@ PUNCHDOWN LIST ---------------------------------------------------------------- * JIT refactor o x 'tens/dozens of UT cases' + o populate each bifs/X_test.go for each bifs/X.go from existing regression-test data m internal/pkg/mlrval - - UT-driven mlrval defer/infer + k UT-driven mlrval defer/infer - pkg/mlrval doc.go & README.md o internal/pkg/types k UT-driven mlrmap constructor refactor @@ -112,9 +119,8 @@ PUNCHDOWN LIST mlrmap.PutReference(key, value) k UT-driven DKVP-from-line - - UT-driven X-from-line: nidx, xtab, csvlite, csv - - UT-driven JSON-from-line - - defer channelizers to a separate PR + ~ UT-driven X-from-line: nidx, xtab, csvlite, csv + - UT-driven JSON-from-string o internal/pkg/output - basic mlrval.String() @@ -145,17 +151,16 @@ PUNCHDOWN LIST ---------------------------------------------------------------- * perf more - o see other branch o nim6 note on perf: baseline/cat; processor/pipelining; o update https://miller.readthedocs.io/en/latest/cpu/, and/or https://miller.readthedocs.io/en/latest/streaming-and-memory/, and/or make a new page w/ info on per o JIT: maasure - o pipelined reader - o batched reader separately - o buffered output + k pipelined reader + k batched reader separately + k buffered output o re-check hashed/unhashed and do so periodically - - env-var back door + - CLI switch - check with more than just abixy ----------------------------------------------------------------