Skip to content

Commit

Permalink
iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jan 20, 2024
1 parent 8a5fdfc commit d1763a3
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions pkg/transformers/reorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,38 @@ func (tr *TransformerReorder) reorderToStart(
) {
if !inrecAndContext.EndOfStream {
inrec := inrecAndContext.Record

if tr.regexes == nil {
for _, fieldName := range tr.fieldNames {
inrec.MoveToHead(fieldName)
}
outputRecordsAndContexts.PushBack(inrecAndContext)

} else {
// XXX TO DO
outrec := mlrval.NewMlrmapAsRecord()
atEnds := list.New()

Check failure on line 226 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
for pe := inrec.Head; pe != nil; pe = pe.Next {
found := false
for _, regex := range tr.regexes {
if regex.MatchString(pe.Key) {
outrec.PutReference(pe.Key, pe.Value)
found = true
break
}
}
if !found {
atEnds.PushBack(pe)

Check failure on line 237 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
}
}

for atEnd := atEnds.Front(); atEnd != nil; atEnd = atEnd.Next() {

Check failure on line 241 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
// Ownership transfer; no copy needed
pe := atEnd.Value.(*mlrval.MlrmapEntry)
outrec.PutReference(pe.Key, pe.Value)
}

outrecAndContext := types.NewRecordAndContext(outrec, &inrecAndContext.Context)
outputRecordsAndContexts.PushBack(outrecAndContext)
}

} else {
Expand All @@ -242,8 +267,32 @@ func (tr *TransformerReorder) reorderToEnd(
inrec.MoveToTail(fieldName)
}
outputRecordsAndContexts.PushBack(inrecAndContext)

} else {
// XXX TO DO
outrec := mlrval.NewMlrmapAsRecord()
atEnds := list.New()

Check failure on line 273 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
for pe := inrec.Head; pe != nil; pe = pe.Next {
found := false
for _, regex := range tr.regexes {
if regex.MatchString(pe.Key) {
atEnds.PushBack(pe)

Check failure on line 278 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
found = true
break
}
}
if !found {
outrec.PutReference(pe.Key, pe.Value)
}
}

for atEnd := atEnds.Front(); atEnd != nil; atEnd = atEnd.Next() {

Check failure on line 288 in pkg/transformers/reorder.go

View workflow job for this annotation

GitHub Actions / Codespell

atEnds ==> attends
// Ownership transfer; no copy needed
pe := atEnd.Value.(*mlrval.MlrmapEntry)
outrec.PutReference(pe.Key, pe.Value)
}

outrecAndContext := types.NewRecordAndContext(outrec, &inrecAndContext.Context)
outputRecordsAndContexts.PushBack(outrecAndContext)
}
} else {
outputRecordsAndContexts.PushBack(inrecAndContext) // end-of-stream marker
Expand Down

0 comments on commit d1763a3

Please sign in to comment.