mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-22 18:06:52 +00:00
iterating
This commit is contained in:
parent
a80c173aa4
commit
ed6e07fbf0
6 changed files with 13 additions and 17 deletions
|
|
@ -193,7 +193,7 @@ func NewTransformerBar(
|
|||
|
||||
if doAuto {
|
||||
tr.recordTransformerFunc = tr.processAuto
|
||||
tr.recordsForAutoMode = list.New()
|
||||
tr.recordsForAutoMode = types.NewList[*types.RecordAndContext](10) // XXX size
|
||||
} else {
|
||||
tr.recordTransformerFunc = tr.processNoAuto
|
||||
tr.recordsForAutoMode = nil
|
||||
|
|
@ -270,9 +270,8 @@ func (tr *TransformerBar) processAuto(
|
|||
|
||||
// The first pass computes lo and hi from the data
|
||||
onFirst := true
|
||||
for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() {
|
||||
recordAndContexts := e.Value.(*types.RecordAndContext)
|
||||
record := recordAndContexts.Record
|
||||
for _, recordAndContext := range tr.recordsForAutoMode.Items {
|
||||
record := recordAndContext.Record
|
||||
mvalue := record.Get(fieldName)
|
||||
if mvalue == nil {
|
||||
continue
|
||||
|
|
@ -300,8 +299,7 @@ func (tr *TransformerBar) processAuto(
|
|||
slo := fmt.Sprintf("%g", lo)
|
||||
shi := fmt.Sprintf("%g", hi)
|
||||
|
||||
for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() {
|
||||
recordAndContext := e.Value.(*types.RecordAndContext)
|
||||
for _, recordAndContext := range tr.recordsForAutoMode.Items {
|
||||
record := recordAndContext.Record
|
||||
mvalue := record.Get(fieldName)
|
||||
if mvalue == nil {
|
||||
|
|
@ -332,10 +330,6 @@ func (tr *TransformerBar) processAuto(
|
|||
}
|
||||
}
|
||||
|
||||
for e := tr.recordsForAutoMode.Front(); e != nil; e = e.Next() {
|
||||
recordAndContext := e.Value.(*types.RecordAndContext)
|
||||
outputRecordsAndContexts.PushBack(recordAndContext)
|
||||
}
|
||||
|
||||
outputRecordsAndContexts.PushBackMultiple(tr.recordsForAutoMode.Items)
|
||||
outputRecordsAndContexts.PushBack(inrecAndContext) // Emit the end-of-stream marker
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ type TransformerBootstrap struct {
|
|||
|
||||
func NewTransformerBootstrap(nout int64) (*TransformerBootstrap, error) {
|
||||
tr := &TransformerBootstrap{
|
||||
recordsAndContexts: list.New(),
|
||||
recordsAndContexts: types.NewList[*types.RecordAndContext](int(100)), // XXX size
|
||||
nout: nout,
|
||||
}
|
||||
return tr, nil
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ func (tr *TransformerCountSimilar) Transform(
|
|||
}
|
||||
}
|
||||
|
||||
outputRecordsAndContexts.PushBack(inrecAndContext) // Emit the stream-terminating null record
|
||||
// Emit the stream-terminating null record
|
||||
outputRecordsAndContexts.PushBack(inrecAndContext)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func NewTransformerFraction(
|
|||
doCumu bool,
|
||||
) (*TransformerFraction, error) {
|
||||
|
||||
recordsAndContexts := list.New()
|
||||
recordsAndContexts := types.NewList[*types.RecordAndContext](100) // XXX SIZE
|
||||
sums := make(map[string]map[string]*mlrval.Mlrval)
|
||||
cumus := make(map[string]map[string]*mlrval.Mlrval)
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ type tRegexAndReplacement struct {
|
|||
|
||||
type TransformerRename struct {
|
||||
oldToNewNames *lib.OrderedMap
|
||||
regexesAndReplacements *list.List
|
||||
regexesAndReplacements *types.List[*tRegexAndReplacement]
|
||||
doGsub bool
|
||||
recordTransformerFunc RecordTransformerFunc
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ func NewTransformerRename(
|
|||
tr.doGsub = false
|
||||
tr.recordTransformerFunc = tr.transformWithoutRegexes
|
||||
} else {
|
||||
tr.regexesAndReplacements = list.New()
|
||||
tr.regexesAndReplacements = types.NewList[*tRegexAndReplacement](10)
|
||||
for pe := oldToNewNames.Head; pe != nil; pe = pe.Next {
|
||||
regexString := pe.Key
|
||||
regex := lib.CompileMillerRegexOrDie(regexString)
|
||||
|
|
|
|||
|
|
@ -309,7 +309,8 @@ type TransformerSort struct {
|
|||
recordListsByGroup *lib.OrderedMap
|
||||
// Map from string to []*lib.Mlrval:
|
||||
groupHeads *lib.OrderedMap
|
||||
spillGroup *list.List // e.g. sort by field "a" -- this is for records lacking a field named "a"
|
||||
// E.g. for sort by field "a", this is for records lacking a field named "a"
|
||||
spillGroup *types.List[*types.RecordAndContext]
|
||||
}
|
||||
|
||||
func NewTransformerSort(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue