Documentation ¶
Index ¶
- Constants
- Variables
- func BsearchMlrvalArrayForAscendingInsert(array *[]*Mlrval, size int64, value *Mlrval) int64
- func BsearchMlrvalArrayForDescendingInsert(array *[]*Mlrval, size int64, value *Mlrval) int64
- func CaseFoldAscendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func CaseFoldDescendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func Cmp(input1, input2 *Mlrval) int
- func Equals(input1, input2 *Mlrval) bool
- func GetTypeName(mvtype MVType) string
- func GreaterThan(input1, input2 *Mlrval) bool
- func GreaterThanOrEquals(input1, input2 *Mlrval) bool
- func HashRecords(onOff bool)
- func LengthenMlrvalArray(array *[]*Mlrval, newLength64 int)
- func LessThan(input1, input2 *Mlrval) bool
- func LessThanOrEquals(input1, input2 *Mlrval) bool
- func LexicalAscendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func LexicalDescendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func NaturalAscendingComparator(input1, input2 *Mlrval) int
- func NaturalDescendingComparator(input1, input2 *Mlrval) int
- func NotEquals(input1, input2 *Mlrval) bool
- func NumericAscendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func NumericDescendingComparator(input1 *Mlrval, input2 *Mlrval) int
- func SetFloatOutputFormat(formatString string) error
- func SetInferNormally()
- func SetInferrerIntAsFloat()
- func SetInferrerOctalAsInt()
- func SetInferrerStringOnly()
- func TypeNameToMask(typeName string) (mask int, present bool)
- func UnaliasArrayIndex(array *[]*Mlrval, mindex int) (int, bool)
- func UnaliasArrayLengthIndex(n int, mindex int) (int, bool)
- type BsearchMlrvalArrayFunc
- type CmpFuncBool
- type CmpFuncInt
- type IFormatter
- type MVType
- type Mlrmap
- func (mlrmap *Mlrmap) Clear()
- func (mlrmap *Mlrmap) Contains(other *Mlrmap) bool
- func (mlrmap *Mlrmap) Copy() *Mlrmap
- func (mlrmap *Mlrmap) CopyUnflattenFields(fieldNameSet map[string]bool, separator string) *Mlrmap
- func (mlrmap *Mlrmap) CopyUnflattened(separator string) *Mlrmap
- func (mlrmap *Mlrmap) Dump()
- func (mlrmap *Mlrmap) Equals(other *Mlrmap) bool
- func (mlrmap *Mlrmap) Flatten(separator string)
- func (mlrmap *Mlrmap) FlattenFields(fieldNameSet map[string]bool, separator string)
- func (mlrmap *Mlrmap) Fprint(file *os.File)
- func (mlrmap *Mlrmap) Get(key string) *Mlrval
- func (mlrmap *Mlrmap) GetEntry(key string) *MlrmapEntry
- func (mlrmap *Mlrmap) GetFirstPair() *Mlrmap
- func (mlrmap *Mlrmap) GetKeys() []string
- func (mlrmap *Mlrmap) GetKeysExcept(exceptions map[string]bool) []string
- func (mlrmap *Mlrmap) GetKeysJoined() string
- func (mlrmap *Mlrmap) GetKeysJoinedExcept(px *MlrmapEntry) string
- func (mlrmap *Mlrmap) GetNameAtPositionalIndex(position int64) (string, bool)
- func (mlrmap *Mlrmap) GetSelectedValues(selectedFieldNames []string) ([]*Mlrval, bool)
- func (mlrmap *Mlrmap) GetSelectedValuesAndJoined(selectedFieldNames []string) (string, []*Mlrval, bool)
- func (mlrmap *Mlrmap) GetSelectedValuesJoined(selectedFieldNames []string) (string, bool)
- func (mlrmap *Mlrmap) GetValuesJoined() string
- func (mlrmap *Mlrmap) GetValuesJoinedExcept(px *MlrmapEntry) string
- func (mlrmap *Mlrmap) GetWithMlrvalIndex(index *Mlrval) (*Mlrval, error)
- func (mlrmap *Mlrmap) GetWithPositionalIndex(position int64) *Mlrval
- func (mlrmap *Mlrmap) Has(key string) bool
- func (mlrmap *Mlrmap) HasSelectedKeys(selectedFieldNames []string) bool
- func (mlrmap *Mlrmap) IsEmpty() bool
- func (mlrmap *Mlrmap) IsNested() bool
- func (mlrmap *Mlrmap) IsSinglePair() bool
- func (mlrmap *Mlrmap) Label(newNames []string)
- func (mlrmap *Mlrmap) MarshalJSON(jsonFormatting TJSONFormatting, outputIsStdout bool) (string, error)
- func (mlrmap *Mlrmap) Merge(other *Mlrmap)
- func (mlrmap *Mlrmap) MoveToHead(key string)
- func (mlrmap *Mlrmap) MoveToTail(key string)
- func (mlrmap *Mlrmap) PrependCopy(key string, value *Mlrval)
- func (mlrmap *Mlrmap) PrependReference(key string, value *Mlrval)
- func (mlrmap *Mlrmap) Print()
- func (mlrmap *Mlrmap) PutCopy(key string, value *Mlrval)
- func (mlrmap *Mlrmap) PutCopyWithMlrvalIndex(key *Mlrval, value *Mlrval) error
- func (mlrmap *Mlrmap) PutCopyWithPositionalIndex(position int64, value *Mlrval)
- func (mlrmap *Mlrmap) PutIndexed(indices []*Mlrval, rvalue *Mlrval) error
- func (mlrmap *Mlrmap) PutNameWithPositionalIndex(position int64, name *Mlrval)
- func (mlrmap *Mlrmap) PutReference(key string, value *Mlrval)
- func (mlrmap *Mlrmap) PutReferenceAfter(pe *MlrmapEntry, key string, value *Mlrval) *MlrmapEntry
- func (mlrmap *Mlrmap) PutReferenceMaybeDedupe(key string, value *Mlrval, dedupe bool) (string, error)
- func (mlrmap *Mlrmap) ReferenceSelectedValues(selectedFieldNames []string) ([]*Mlrval, bool)
- func (mlrmap *Mlrmap) Remove(key string) bool
- func (mlrmap *Mlrmap) RemoveIndexed(indices []*Mlrval) error
- func (mlrmap *Mlrmap) RemoveWithPositionalIndex(position int64)
- func (mlrmap *Mlrmap) Rename(oldKey string, newKey string) bool
- func (mlrmap *Mlrmap) SortByKey()
- func (mlrmap *Mlrmap) SortByKeyRecursively()
- func (mlrmap Mlrmap) String() string
- func (mlrmap *Mlrmap) StringifyValuesRecursively()
- func (mlrmap *Mlrmap) ToDKVPString() string
- func (mlrmap *Mlrmap) ToNIDXString() string
- func (mlrmap *Mlrmap) ToPairsArray() []MlrmapPair
- func (mlrmap *Mlrmap) Unflatten(separator string)
- func (mlrmap *Mlrmap) UnflattenFields(fieldNameSet map[string]bool, separator string)
- func (mlrmap *Mlrmap) Unlink(pe *MlrmapEntry)
- type MlrmapEntry
- type MlrmapEntryForArray
- type MlrmapPair
- type Mlrval
- func ArrayFold(a []*Mlrval, initval *Mlrval, f func(a, b *Mlrval) *Mlrval) *Mlrval
- func CollectionFold(c *Mlrval, initval *Mlrval, f func(a, b *Mlrval) *Mlrval) *Mlrval
- func CopyMlrvalArray(input []*Mlrval) []*Mlrval
- func FromAnonymousError() *Mlrval
- func FromArray(arrayval []*Mlrval) *Mlrval
- func FromBool(input bool) *Mlrval
- func FromBoolString(input string) *Mlrval
- func FromDeferredType(input string) *Mlrval
- func FromEmptyArray() *Mlrval
- func FromEmptyMap() *Mlrval
- func FromError(err error) *Mlrval
- func FromErrorString(err string) *Mlrval
- func FromFloat(input float64) *Mlrval
- func FromFunction(funcval interface{}, name string) *Mlrval
- func FromInferredType(input string) *Mlrval
- func FromInt(input int64) *Mlrval
- func FromIntShowingOctal(input int64) *Mlrval
- func FromMap(mapval *Mlrmap) *Mlrval
- func FromNotArrayError(funcname string, v *Mlrval) *Mlrval
- func FromNotBooleanError(funcname string, v *Mlrval) *Mlrval
- func FromNotCollectionError(funcname string, v *Mlrval) *Mlrval
- func FromNotFunctionError(funcname string, v *Mlrval) *Mlrval
- func FromNotIntError(funcname string, v *Mlrval) *Mlrval
- func FromNotMapError(funcname string, v *Mlrval) *Mlrval
- func FromNotNamedTypeError(funcname string, v *Mlrval, expected_type_name string) *Mlrval
- func FromNotNumericError(funcname string, v *Mlrval) *Mlrval
- func FromNotStringError(funcname string, v *Mlrval) *Mlrval
- func FromPending() *Mlrval
- func FromPrevalidatedFloatString(input string, floatval float64) *Mlrval
- func FromPrevalidatedIntString(input string, intval int64) *Mlrval
- func FromSingletonArray(element *Mlrval) *Mlrval
- func FromString(input string) *Mlrval
- func FromTypeErrorBinary(funcname string, v, input2 *Mlrval) *Mlrval
- func FromTypeErrorTernary(funcname string, v, input2, input3 *Mlrval) *Mlrval
- func FromTypeErrorUnary(funcname string, v *Mlrval) *Mlrval
- func MapFold(m *Mlrmap, initval *Mlrval, f func(a, b *Mlrval) *Mlrval) *Mlrval
- func MlrvalDecodeFromJSON(decoder *json.Decoder) (mlrval *Mlrval, eof bool, err error)
- func MlrvalFromPending() Mlrval
- func NewMlrvalForAutoDeepen(mvtype MVType) (*Mlrval, error)
- func SplitAXHelper(input string, separator string) *Mlrval
- func TryFromFloatString(input string) *Mlrval
- func TryFromIntString(input string) *Mlrval
- func TryUnmarshalJSON(inputBytes []byte) (pmv *Mlrval, err error)
- func (mv *Mlrval) AcquireArrayValue() []*Mlrval
- func (mv *Mlrval) AcquireBoolValue() bool
- func (mv *Mlrval) AcquireFloatValue() float64
- func (mv *Mlrval) AcquireIntValue() int64
- func (mv *Mlrval) AcquireMapValue() *Mlrmap
- func (mv *Mlrval) AcquireStringValue() string
- func (mv *Mlrval) ArrayAppend(value *Mlrval)
- func (mv *Mlrval) ArrayGet(mindex *Mlrval) Mlrval
- func (mv *Mlrval) ArrayPut(mindex *Mlrval, value *Mlrval)
- func (mv *Mlrval) Arrayify() *Mlrval
- func (mv *Mlrval) AssertNumeric()
- func (mv *Mlrval) Copy() *Mlrval
- func (mv *Mlrval) FlattenToMap(prefix string, delimiter string) Mlrval
- func (mv *Mlrval) GetArray() []*Mlrval
- func (mv *Mlrval) GetArrayLength() (int, bool)
- func (mv *Mlrval) GetArrayValueOrError(funcname string) (ok []*Mlrval, errValue *Mlrval)
- func (mv *Mlrval) GetBoolValue() (boolValue bool, isBool bool)
- func (mv *Mlrval) GetError() (bool, error)
- func (mv *Mlrval) GetFloatValue() (floatValue float64, isFloat bool)
- func (mv *Mlrval) GetFunction() interface{}
- func (mv *Mlrval) GetIntValue() (intValue int64, isInt bool)
- func (mv *Mlrval) GetIntValueOrError(funcname string) (intValue int64, errValue *Mlrval)
- func (mv *Mlrval) GetMap() *Mlrmap
- func (mv *Mlrval) GetMapValueOrError(funcname string) (ok *Mlrmap, errValue *Mlrval)
- func (mv *Mlrval) GetNumericNegativeorDie() bool
- func (mv *Mlrval) GetNumericToFloatValue() (floatValue float64, isFloat bool)
- func (mv *Mlrval) GetNumericToFloatValueOrDie() (floatValue float64)
- func (mv *Mlrval) GetNumericToFloatValueOrError(funcname string) (floatValue float64, errValue *Mlrval)
- func (mv *Mlrval) GetStringValue() (stringValue string, isString bool)
- func (mv *Mlrval) GetStringValueOrError(funcname string) (stringValue string, errValue *Mlrval)
- func (mv *Mlrval) GetTypeBit() int
- func (mv *Mlrval) GetTypeName() string
- func (mv *Mlrval) Increment()
- func (mv *Mlrval) IsAbsent() bool
- func (mv *Mlrval) IsArray() bool
- func (mv *Mlrval) IsArrayOrMap() bool
- func (mv *Mlrval) IsBool() bool
- func (mv *Mlrval) IsEmptyString() bool
- func (mv *Mlrval) IsError() bool
- func (mv *Mlrval) IsErrorOrAbsent() bool
- func (mv *Mlrval) IsErrorOrVoid() bool
- func (mv *Mlrval) IsFalse() bool
- func (mv *Mlrval) IsFloat() bool
- func (mv *Mlrval) IsFunction() bool
- func (mv *Mlrval) IsInt() bool
- func (mv *Mlrval) IsIntZero() bool
- func (mv *Mlrval) IsLegit() bool
- func (mv *Mlrval) IsMap() bool
- func (mv *Mlrval) IsNull() bool
- func (mv *Mlrval) IsNumeric() bool
- func (mv *Mlrval) IsString() bool
- func (mv *Mlrval) IsStringOrInt() bool
- func (mv *Mlrval) IsStringOrVoid() bool
- func (mv *Mlrval) IsTrue() bool
- func (mv *Mlrval) IsVoid() bool
- func (mv *Mlrval) MapGet(key *Mlrval) Mlrval
- func (mv *Mlrval) MapPut(key *Mlrval, value *Mlrval)
- func (mv *Mlrval) MarshalJSON(jsonFormatting TJSONFormatting, outputIsStdout bool) (string, error)
- func (mv *Mlrval) OriginalString() string
- func (mv *Mlrval) PutIndexed(indices []*Mlrval, rvalue *Mlrval) error
- func (mv *Mlrval) RemoveIndexed(indices []*Mlrval) error
- func (mv *Mlrval) SetFromPrevalidatedBoolString(input string, boolval bool) *Mlrval
- func (mv *Mlrval) SetFromPrevalidatedFloatString(input string, floatval float64) *Mlrval
- func (mv *Mlrval) SetFromPrevalidatedIntString(input string, intval int64) *Mlrval
- func (mv *Mlrval) SetFromString(input string) *Mlrval
- func (mv *Mlrval) SetFromVoid() *Mlrval
- func (mv *Mlrval) ShowSizes()
- func (mv *Mlrval) StrictModeCheck(strictMode bool, description string) *Mlrval
- func (mv *Mlrval) String() string
- func (mv *Mlrval) StringMaybeQuoted() string
- func (mv *Mlrval) StringifyValuesRecursively()
- func (mv *Mlrval) Type() MVType
- func (mv *Mlrval) UnmarshalJSON(inputBytes []byte) error
- type TJSONFormatting
Constants ¶
const ( JSON_SINGLE_LINE = 1 JSON_MULTILINE = 2 )
const ABSENT_PRINTREP = "(absent)"
const ERROR_PRINTREP = "(error)"
const INVALID_PRINTREP = "(bug-if-you-see-this:case-2)"
const JSON_INDENT_STRING string = " "
const MT_TYPE_MASK_ANY = (1 << MT_ERROR) | (1 << MT_ABSENT) | MT_TYPE_MASK_VAR | MT_TYPE_MASK_FUNC
Not exposed in userspace
const MT_TYPE_MASK_ARRAY = 1 << MT_ARRAY
const MT_TYPE_MASK_BOOL = 1 << MT_BOOL
const MT_TYPE_MASK_FLOAT = 1 << MT_FLOAT
const MT_TYPE_MASK_FUNC = 1 << MT_FUNC
const MT_TYPE_MASK_INT = 1 << MT_INT
TODO: comment more re typedecls
const MT_TYPE_MASK_MAP = 1 << MT_MAP
const MT_TYPE_MASK_NUM = (1 << MT_INT) | (1 << MT_FLOAT)
const MT_TYPE_MASK_STRING = (1 << MT_STRING) | (1 << MT_VOID)
Variables ¶
var ABSENT = &Mlrval{ mvtype: MT_ABSENT, printrep: ABSENT_PRINTREP, printrepValid: true, }
var FALSE = &Mlrval{ mvtype: MT_BOOL, printrep: "false", printrepValid: true, intf: false, }
var MINUS_ONE = &Mlrval{ mvtype: MT_INT, printrep: "-1", printrepValid: true, intf: int64(-1), }
For malloc-avoidance in the spaceship operator
var NULL = &Mlrval{ mvtype: MT_NULL, printrep: "null", printrepValid: true, }
var ONE = &Mlrval{ mvtype: MT_INT, printrep: "1", printrepValid: true, intf: int64(1), }
var TRUE = &Mlrval{ mvtype: MT_BOOL, printrep: "true", printrepValid: true, intf: true, }
var TYPE_NAMES = [MT_DIM]string{
"int",
"float",
"bool",
"empty",
"string",
"array",
"map",
"funct",
"error",
"null",
"absent",
}
var VOID = &Mlrval{ mvtype: MT_VOID, printrep: "", printrepValid: true, }
var ZERO = &Mlrval{ mvtype: MT_INT, printrep: "0", printrepValid: true, intf: int64(0), }
Functions ¶
func CaseFoldAscendingComparator ¶
CaseFoldAscendingComparator is for case-folded lexical sort: it stringifies everything.
func CaseFoldDescendingComparator ¶
CaseFoldDescendingComparator is for case-folded lexical sort: it stringifies everything.
func GetTypeName ¶
func GreaterThan ¶
func GreaterThanOrEquals ¶
func HashRecords ¶
func HashRecords(onOff bool)
func LengthenMlrvalArray ¶
func LessThanOrEquals ¶
func LexicalAscendingComparator ¶
LexicalAscendingComparator is for lexical sort: it stringifies everything.
func LexicalDescendingComparator ¶
LexicalDescendingComparator is for reverse-lexical sort: it stringifies everything.
func NumericDescendingComparator ¶
NumericDescendingComparator is for "numerical" sort: it uses Mlrval sorting rules by type, including numeric sort for numeric types.
func SetFloatOutputFormat ¶
func TypeNameToMask ¶
Types ¶
type BsearchMlrvalArrayFunc ¶
type CmpFuncBool ¶
type CmpFuncInt ¶
The Go sort API is just a bool a<b, not triple a<b, a==b, a>b. Miller does the latter since when we sort primarily on field 1, then secondarily on field 2, etc., we need to be able to detect ties on field 1 so we can know whether to compare on field 2 or not.
type IFormatter ¶
type IFormatter interface { Format(mlrval *Mlrval) *Mlrval FormatFloat(floatValue float64) string // for --ofmt }
func GetFormatter ¶
func GetFormatter( userLevelFormatString string, ) (IFormatter, error)
type MVType ¶
type MVType int8
const ( // Type not yet determined: during JSON decode, or for JIT-data from file // data whose type doesn't need to be determined yet. For example, when we // operate only on columns 15 & 17 of a 20-column CSV file, those two // columns get type-inferred during processing but the rest keep their // printrep and type MT_PENDING. This is a significant performance // optimization. MT_PENDING MVType = -1 // intf is int64 MT_INT MVType = 0 // intf is float64 MT_FLOAT MVType = 1 // intf is bool MT_BOOL MVType = 2 // Key present in input record with empty value, e.g. input data '$x=,$y=2' MT_VOID MVType = 3 MT_STRING MVType = 4 // intf is []*Mlrval MT_ARRAY MVType = 5 // intf is *Mlrmap MT_MAP MVType = 6 // intf is interface{} -- resolved in the cst package to avoid circular dependencies MT_FUNC MVType = 7 // E.g. error encountered in one eval & it propagates up the AST at // evaluation time. Various runtime errors, such as file-not-found, result // in a message to stderr and os.Exit(1). But errors in user-provided data // are intended to result in "(error)"-valued output rather than a crash. // This is analogous to the way that IEEE-754 arithmetic carries around // Inf and NaN through computation chains. MT_ERROR MVType = 8 // Used only for JSON null, and for 'empty' slots when an array is // auto-extended by assigning to an index having a gap from the last index. // E.g. x=[1,2,3] then x[5]=5; now x[4] is null MT_NULL MVType = 9 // Key not present in input record, e.g. 'foo = $nosuchkey' MT_ABSENT MVType = 10 // Not a type -- this is a dimension for disposition vectors and // disposition matrices. For example, when we want to add two mlrvals, // instead of if/elsing or switching on the types of both operands, we // instead jump directly to a type-specific function in a matrix of // function pointers which is MT_DIM x MT_DIM. MT_DIM MVType = 11 )
Important: the values of these enums are used to index into disposition matrices. If they are changed, it will break the disposition matrices, or they will all need manual re-indexing.
Also note the ordering of types reflects the sort order for mixed types, with the exception that ints and floats sort numerically. So 1 < "abc" and 1 < "1", and 7 < true; but 1 < 1.1 < 2 < 2.2.
type Mlrmap ¶
type Mlrmap struct { FieldCount int64 Head *MlrmapEntry Tail *MlrmapEntry // contains filtered or unexported fields }
----------------------------------------------------------------
func MlrmapFromPairsArray ¶
func MlrmapFromPairsArray(pairsArray []MlrmapPair) *Mlrmap
MlrmapFromPairsArray is used for sorting maps by key/value/etc, e.g. the sortmf DSL function.
func NewMlrmapAsRecord ¶
func NewMlrmapAsRecord() *Mlrmap
----------------------------------------------------------------
func NewMlrmapMaybeHashed ¶
func (*Mlrmap) Contains ¶
True if this contains other, i.e. if other is contained by mlrmap. * If any key of other is not a key of this, return false. * If any key of other has a value unequal to this' value at the same key, return false. * Else return true
func (*Mlrmap) CopyUnflattenFields ¶
func (*Mlrmap) CopyUnflattened ¶
func (*Mlrmap) Dump ¶
func (mlrmap *Mlrmap) Dump()
----------------------------------------------------------------
func (*Mlrmap) FlattenFields ¶
func (*Mlrmap) GetEntry ¶
func (mlrmap *Mlrmap) GetEntry(key string) *MlrmapEntry
---------------------------------------------------------------- Exposed for the 'nest' verb
func (*Mlrmap) GetFirstPair ¶
GetFirstPair returns the first key-value pair as its own map. If the map is empty (i.e. there is no first pair) it returns nil.
func (*Mlrmap) GetKeysExcept ¶
Returns an array of keys, not including the ones specified. The ones specified are to be passed in as a map from string to bool, as Go doesn't have hash-sets.
func (*Mlrmap) GetKeysJoined ¶
----------------------------------------------------------------
func (*Mlrmap) GetKeysJoinedExcept ¶
func (mlrmap *Mlrmap) GetKeysJoinedExcept(px *MlrmapEntry) string
---------------------------------------------------------------- For mlr nest implode across records.
func (*Mlrmap) GetNameAtPositionalIndex ¶
func (*Mlrmap) GetSelectedValues ¶
TODO: rename to CopySelectedValues As previous but with copying. For stats1.
func (*Mlrmap) GetSelectedValuesAndJoined ¶
func (mlrmap *Mlrmap) GetSelectedValuesAndJoined(selectedFieldNames []string) ( string, []*Mlrval, bool, )
As with GetSelectedValuesJoined but also returning the array of mlrvals. For sort. TODO: put 'Copy' into the method name
func (*Mlrmap) GetSelectedValuesJoined ¶
func (*Mlrmap) GetValuesJoinedExcept ¶
func (mlrmap *Mlrmap) GetValuesJoinedExcept(px *MlrmapEntry) string
For mlr nest implode across records.
func (*Mlrmap) GetWithMlrvalIndex ¶
func (*Mlrmap) GetWithPositionalIndex ¶
func (*Mlrmap) HasSelectedKeys ¶
Similar to the above but only checks availability. For join.
func (*Mlrmap) IsNested ¶
---------------------------------------------------------------- Only checks to see if the first entry is a map. For emit/emitp.
func (*Mlrmap) IsSinglePair ¶
func (*Mlrmap) MarshalJSON ¶
func (mlrmap *Mlrmap) MarshalJSON( jsonFormatting TJSONFormatting, outputIsStdout bool, ) (string, error)
----------------------------------------------------------------
func (*Mlrmap) Merge ¶
---------------------------------------------------------------- Merges that into mlrmap.
func (*Mlrmap) MoveToHead ¶
func (*Mlrmap) MoveToTail ¶
func (*Mlrmap) PrependCopy ¶
----------------------------------------------------------------
func (*Mlrmap) PrependReference ¶
PrependReference is the same as PutReference, but puts a new entry first, not last.
func (*Mlrmap) Print ¶
func (mlrmap *Mlrmap) Print()
----------------------------------------------------------------
func (*Mlrmap) PutCopy ¶
PutCopy copies the key and value (deep-copying in case the value is array/map). This is safe for DSL use. See also PutReference.
func (*Mlrmap) PutCopyWithMlrvalIndex ¶
func (*Mlrmap) PutCopyWithPositionalIndex ¶
TODO: put error-return into this API
func (*Mlrmap) PutIndexed ¶
func (*Mlrmap) PutNameWithPositionalIndex ¶
---------------------------------------------------------------- TODO: put error-return into this API
func (*Mlrmap) PutReference ¶
PutReference copies the key but not the value. This is not safe for DSL use, where we could create undesired references between different objects. Only intended to be used at callsites which allocate a mlrval on the spot, solely for the purpose of putting into the map.
func (*Mlrmap) PutReferenceAfter ¶
func (mlrmap *Mlrmap) PutReferenceAfter( pe *MlrmapEntry, key string, value *Mlrval, ) *MlrmapEntry
TODO: COMMENT
func (*Mlrmap) PutReferenceMaybeDedupe ¶
func (mlrmap *Mlrmap) PutReferenceMaybeDedupe(key string, value *Mlrval, dedupe bool) (string, error)
PutReferenceMaybeDedupe is the default inserter for key-value pairs in input records -- if the input is 'x=8,x=9` then we make a record with x=8 and x_2=9. This can be suppressed via a command-line flag which this method's dedupe flag respects.
func (*Mlrmap) ReferenceSelectedValues ¶
As above but only returns the array. Also, these are references, NOT copies. For step and join.
func (*Mlrmap) RemoveIndexed ¶
func (*Mlrmap) RemoveWithPositionalIndex ¶
func (*Mlrmap) SortByKey ¶
func (mlrmap *Mlrmap) SortByKey()
----------------------------------------------------------------
func (*Mlrmap) SortByKeyRecursively ¶
func (mlrmap *Mlrmap) SortByKeyRecursively()
----------------------------------------------------------------
func (Mlrmap) String ¶
---------------------------------------------------------------- Must have non-pointer receiver in order to implement the fmt.Stringer interface to make mlrmap printable via fmt.Println et al.
func (*Mlrmap) StringifyValuesRecursively ¶
func (mlrmap *Mlrmap) StringifyValuesRecursively()
StringifyValuesRecursively is nominally for the `--jvquoteall` flag.
func (*Mlrmap) ToDKVPString ¶
func (*Mlrmap) ToNIDXString ¶
func (*Mlrmap) ToPairsArray ¶
func (mlrmap *Mlrmap) ToPairsArray() []MlrmapPair
ToPairsArray is used for sorting maps by key/value/etc, e.g. the sortmf DSL function.
func (*Mlrmap) Unflatten ¶
Special case: if the resulting string keys are string representations of 1, 2, 3, etc -- without gaps -- then the map is converted to an array.
Examples:
The three fields x.a = 7, x.b = 8, x.c = 9 become the single field x = {"a": 7, "b": 8, "c": 9}.
The three fields x.1 = 7, x.2 = 8, x.3 = 9 become the single field x = [7,8,9].
The two fields x.1 = 7, x.3 = 9 become the single field x = {"1": 7, "3": 9}
func (*Mlrmap) UnflattenFields ¶
---------------------------------------------------------------- For mlr unflatten -f. See comments on Unflatten. Largely copypasta of Unflatten, but split out separately since Flatten needn't check a fieldNameSet.
func (*Mlrmap) Unlink ¶
func (mlrmap *Mlrmap) Unlink(pe *MlrmapEntry)
type MlrmapEntry ¶
type MlrmapEntry struct { Key string Value *Mlrval Prev *MlrmapEntry Next *MlrmapEntry }
func (*MlrmapEntry) JSONParseInPlace ¶
func (entry *MlrmapEntry) JSONParseInPlace()
---------------------------------------------------------------- JSON-parses a single field of a record
func (*MlrmapEntry) JSONStringifyInPlace ¶
func (entry *MlrmapEntry) JSONStringifyInPlace( jsonFormatting TJSONFormatting, )
---------------------------------------------------------------- JSON-stringifies a single field of a record
func (*MlrmapEntry) JSONTryParseInPlace ¶
func (entry *MlrmapEntry) JSONTryParseInPlace()
type MlrmapEntryForArray ¶
MlrmapEntryForArray is for use by sorting routines where the Prev/Next pointers are irrelevant as well as ephemeral
type MlrmapPair ¶
Only used for sorting, map-to-pairs-array and pairs-array-to-map contexts.
type Mlrval ¶
type Mlrval struct {
// contains filtered or unexported fields
}
func ArrayFold ¶
ArrayFold reduces an array to a single value, with a user-supplied starting value and pairwise element-reducer function. Canonical example: start value is 0 and reducer f(a,b) is a+b: this will sum up the values in the array.
func CollectionFold ¶
CollectionFold multiplexes ArrayFold or MapFold. The panic here is not robust, but is done to avoid adding an error-return that would frictionalize the API. The idea is that the caller (internal/library functions, not directly user-facing) must have pre-validated that the argument is an array or map. The panic here is merely a fallback, not the primary check.
func CopyMlrvalArray ¶
func FromAnonymousError ¶
func FromAnonymousError() *Mlrval
func FromBoolString ¶
func FromDeferredType ¶
TODO: comment JIT context. Some things we already know are typed -- DSL things, or JSON contents. Others are deferred, e.g. items from any file format except JSON. TODO: comment re inferBool.
func FromEmptyArray ¶
func FromEmptyArray() *Mlrval
func FromEmptyMap ¶
func FromEmptyMap() *Mlrval
func FromErrorString ¶
func FromFunction ¶
func FromInferredType ¶
TODO: comment non-JIT context like mlr put -s. TODO: comment re inferBool.
func FromIntShowingOctal ¶
func FromNotArrayError ¶
func FromNotBooleanError ¶
func FromNotCollectionError ¶
func FromNotFunctionError ¶
func FromNotIntError ¶
func FromNotMapError ¶
func FromNotNamedTypeError ¶
func FromNotNumericError ¶
func FromNotStringError ¶
func FromPrevalidatedFloatString ¶
TODO: comment
func FromPrevalidatedIntString ¶
TODO: comment
func FromSingletonArray ¶
func FromString ¶
func FromTypeErrorBinary ¶
func FromTypeErrorTernary ¶
func FromTypeErrorUnary ¶
func MapFold ¶
MapFold reduces a map's values to a single value, with a user-supplied starting value and pairwise element-reducer function. Canonical example: start value is 0 and reducer f(a,b) is a+b: this will sum up the values in the map. Nothing here accesses map keys.
func MlrvalDecodeFromJSON ¶
----------------------------------------------------------------
func MlrvalFromPending ¶
func MlrvalFromPending() Mlrval
func NewMlrvalForAutoDeepen ¶
NewMlrvalForAutoDeepen is for auto-deepen of nested maps in things like
$foo[1]["a"][2]["b"] = 3
Autocreated levels are maps. Array levels can be explicitly created e.g.
$foo[1]["a"] ??= [] $foo[1]["a"][2]["b"] = 3
func SplitAXHelper ¶
SplitAXHelper is split out for the benefit of BIF_splitax and BIF_unflatten.
func TryFromFloatString ¶
TryFromFloatString is used by the mlrval Formatter (fmtnum DSL function, format-values verb, etc). Each mlrval has printrep and a printrepValid for its original string, then a type-code like MT_INT or MT_FLOAT, and type-specific storage like intval or floatval.
If the user has taken a mlrval with original string "3.14" and formatted it with "%.4f" then its printrep will be "3.1400" but its type should still be MT_FLOAT.
If on the other hand the user has formatted the same mlrval with "[[%.4f]]" then its printrep will be "[[3.1400]]" and it will be MT_STRING. This function supports that.
func TryFromIntString ¶
TryFromIntString is used by the mlrval Formatter (fmtnum DSL function, format-values verb, etc). Each mlrval has printrep and a printrepValid for its original string, then a type-code like MT_INT or MT_FLOAT, and type-specific storage like intval or floatval.
If the user has taken a mlrval with original string "314" and formatted it with "0x%04x" then its printrep will be "0x013a" but its type should still be MT_INT.
If on the other hand the user has formatted the same mlrval with "[[%0x04x]]" then its printrep will be "[[0x013a]]" and it will be MT_STRING. This function supports that.
func TryUnmarshalJSON ¶
----------------------------------------------------------------
func (*Mlrval) AcquireArrayValue ¶
func (*Mlrval) AcquireBoolValue ¶
func (*Mlrval) AcquireFloatValue ¶
func (*Mlrval) AcquireIntValue ¶
func (*Mlrval) AcquireMapValue ¶
func (*Mlrval) AcquireStringValue ¶
func (*Mlrval) ArrayAppend ¶
---------------------------------------------------------------- TODO: thinking about capacity-resizing
func (*Mlrval) ArrayGet ¶
================================================================ TODO: copy-reduction refactor
func (*Mlrval) ArrayPut ¶
---------------------------------------------------------------- TODO: make this return error so caller can do 'if err == nil { ... }'
func (*Mlrval) AssertNumeric ¶
func (mv *Mlrval) AssertNumeric()
func (*Mlrval) FlattenToMap ¶
func (*Mlrval) GetArrayLength ¶
func (*Mlrval) GetArrayValueOrError ¶
func (*Mlrval) GetBoolValue ¶
func (*Mlrval) GetFloatValue ¶
func (*Mlrval) GetFunction ¶
func (mv *Mlrval) GetFunction() interface{}
func (*Mlrval) GetIntValue ¶
func (*Mlrval) GetIntValueOrError ¶
func (*Mlrval) GetMapValueOrError ¶
func (*Mlrval) GetNumericNegativeorDie ¶
func (*Mlrval) GetNumericToFloatValue ¶
func (*Mlrval) GetNumericToFloatValueOrDie ¶
func (*Mlrval) GetNumericToFloatValueOrError ¶
func (*Mlrval) GetStringValue ¶
func (*Mlrval) GetStringValueOrError ¶
func (*Mlrval) GetTypeBit ¶
func (*Mlrval) GetTypeName ¶
func (*Mlrval) IsAbsent ¶
TODO: comment no JIT-infer here -- absent is non-inferrable and we needn't take the expense of JIT.
func (*Mlrval) IsArrayOrMap ¶
func (*Mlrval) IsEmptyString ¶
* Error is non-empty * Absent is non-empty (shouldn't have been assigned in the first place; error should be surfaced) * Void is empty * Empty string is empty * Int/float/bool/array/map are all non-empty
func (*Mlrval) IsErrorOrAbsent ¶
TODO: comment no JIT-infer here -- absent is non-inferrable and we needn't take the expense of JIT.
func (*Mlrval) IsErrorOrVoid ¶
func (*Mlrval) IsFunction ¶
func (*Mlrval) IsNull ¶
TODO: comment no JIT-infer here -- NULL is non-inferrable and we needn't take the expense of JIT. This is a literal in JSON files, or else explicitly set to NULL.
func (*Mlrval) IsStringOrInt ¶
func (*Mlrval) IsStringOrVoid ¶
func (*Mlrval) MarshalJSON ¶
func (mv *Mlrval) MarshalJSON( jsonFormatting TJSONFormatting, outputIsStdout bool, ) (string, error)
================================================================
func (*Mlrval) OriginalString ¶
OriginalString gets the field value as a string regardless of --ofmt specification. E.g if the ofmt is "%.4f" and input is 3.1415926535, OriginalString() will return "3.1415926535" while String() will return "3.1416".
func (*Mlrval) RemoveIndexed ¶
----------------------------------------------------------------
func (*Mlrval) SetFromPrevalidatedBoolString ¶
TODO: comment
func (*Mlrval) SetFromPrevalidatedFloatString ¶
TODO: comment
func (*Mlrval) SetFromPrevalidatedIntString ¶
TODO: comment
func (*Mlrval) SetFromString ¶
func (*Mlrval) SetFromVoid ¶
func (*Mlrval) StrictModeCheck ¶
func (*Mlrval) String ¶
Must have non-pointer receiver in order to implement the fmt.Stringer interface to make this printable via fmt.Println et al. However, that results in a needless copy of the Mlrval. So, we intentionally use pointer receiver, and if we need to print to stdout, we can fmt.Printf with "%s" and mv.String().
func (*Mlrval) StringMaybeQuoted ¶
StringMaybeQuoted Returns strings double-quoted; all else not.
func (*Mlrval) StringifyValuesRecursively ¶
func (mv *Mlrval) StringifyValuesRecursively()
StringifyValuesRecursively is nominally for the `--jvquoteall` flag.
func (*Mlrval) UnmarshalJSON ¶
----------------------------------------------------------------
type TJSONFormatting ¶
type TJSONFormatting int
Source Files ¶
- mlrmap.go
- mlrmap_accessors.go
- mlrmap_flatten_unflatten.go
- mlrmap_json.go
- mlrmap_print.go
- mlrval_accessors.go
- mlrval_cmp.go
- mlrval_collections.go
- mlrval_constants.go
- mlrval_copy.go
- mlrval_format.go
- mlrval_get.go
- mlrval_infer.go
- mlrval_is.go
- mlrval_json.go
- mlrval_new.go
- mlrval_output.go
- mlrval_sort.go
- mlrval_type.go