mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
iterating
This commit is contained in:
parent
ac2c662bed
commit
a80c173aa4
13 changed files with 21 additions and 22 deletions
|
|
@ -150,7 +150,7 @@ type TransformerBar struct {
|
|||
oobString string
|
||||
blankString string
|
||||
bars []string
|
||||
recordsForAutoMode *list.List
|
||||
recordsForAutoMode *types.List[*types.RecordAndContext]
|
||||
|
||||
recordTransformerFunc RecordTransformerFunc
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func transformerBootstrapParseCLI(
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
type TransformerBootstrap struct {
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
nout int64
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +140,6 @@ func (tr *TransformerBootstrap) Transform(
|
|||
//
|
||||
// For that reason, this transformer must copy all output.
|
||||
|
||||
// TODO: Go list Len() maxes at 2^31. We should track this ourselves in an int.
|
||||
nin := int64(tr.recordsAndContexts.Len())
|
||||
nout := tr.nout
|
||||
if nout == -1 {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ type TransformerCountSimilar struct {
|
|||
counterFieldName string
|
||||
|
||||
// State:
|
||||
recordListsByGroup *lib.OrderedMap // map from string to *list.List
|
||||
recordListsByGroup *lib.OrderedMap // map from string to *types.List[*types.RecordAndContext]
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -142,13 +142,13 @@ func (tr *TransformerCountSimilar) Transform(
|
|||
irecordListForGroup = list.New()
|
||||
tr.recordListsByGroup.Put(groupingKey, irecordListForGroup)
|
||||
}
|
||||
recordListForGroup := irecordListForGroup.(*list.List)
|
||||
recordListForGroup := irecordListForGroup.(*types.List[*types.RecordAndContext])
|
||||
|
||||
recordListForGroup.PushBack(inrecAndContext)
|
||||
} else {
|
||||
|
||||
for outer := tr.recordListsByGroup.Head; outer != nil; outer = outer.Next {
|
||||
recordListForGroup := outer.Value.(*list.List)
|
||||
recordListForGroup := outer.Value.(*types.List[*types.RecordAndContext])
|
||||
// TODO: make 64-bit friendly
|
||||
groupSize := recordListForGroup.Len()
|
||||
mgroupSize := mlrval.FromInt(int64(groupSize))
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ type TransformerFraction struct {
|
|||
groupByFieldNames []string
|
||||
doCumu bool
|
||||
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
// Two-level map: Group-by field names are the first keyset;
|
||||
// fraction field names are keys into the second.
|
||||
sums map[string]map[string]*mlrval.Mlrval
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ type TransformerGroupBy struct {
|
|||
groupByFieldNames []string
|
||||
|
||||
// state
|
||||
// map from string to *list.List
|
||||
// map from string to *types.List[*types.RecordAndContext]
|
||||
recordListsByGroup *lib.OrderedMap
|
||||
}
|
||||
|
||||
|
|
@ -131,11 +131,11 @@ func (tr *TransformerGroupBy) Transform(
|
|||
tr.recordListsByGroup.Put(groupingKey, recordListForGroup)
|
||||
}
|
||||
|
||||
recordListForGroup.(*list.List).PushBack(inrecAndContext)
|
||||
recordListForGroup.(*types.List[*types.RecordAndContext]).PushBack(inrecAndContext)
|
||||
|
||||
} else {
|
||||
for outer := tr.recordListsByGroup.Head; outer != nil; outer = outer.Next {
|
||||
recordListForGroup := outer.Value.(*list.List)
|
||||
recordListForGroup := outer.Value.(*types.List[*types.RecordAndContext])
|
||||
for inner := recordListForGroup.Front(); inner != nil; inner = inner.Next() {
|
||||
outputRecordsAndContexts.PushBack(inner.Value.(*types.RecordAndContext))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func transformerGroupLikeParseCLI(
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
type TransformerGroupLike struct {
|
||||
// map from string to *list.List
|
||||
// map from string to *types.List[*types.RecordAndContext]
|
||||
recordListsByGroup *lib.OrderedMap
|
||||
}
|
||||
|
||||
|
|
@ -110,11 +110,11 @@ func (tr *TransformerGroupLike) Transform(
|
|||
tr.recordListsByGroup.Put(groupingKey, recordListForGroup)
|
||||
}
|
||||
|
||||
recordListForGroup.(*list.List).PushBack(inrecAndContext)
|
||||
recordListForGroup.(*types.List[*types.RecordAndContext]).PushBack(inrecAndContext)
|
||||
|
||||
} else {
|
||||
for outer := tr.recordListsByGroup.Head; outer != nil; outer = outer.Next {
|
||||
recordListForGroup := outer.Value.(*list.List)
|
||||
recordListForGroup := outer.Value.(*types.List[*types.RecordAndContext])
|
||||
for inner := recordListForGroup.Front(); inner != nil; inner = inner.Next() {
|
||||
outputRecordsAndContexts.PushBack(inner.Value.(*types.RecordAndContext))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ type TransformerJoin struct {
|
|||
// For unsorted/half-streaming input
|
||||
ingested bool
|
||||
leftBucketsByJoinFieldValues *lib.OrderedMap
|
||||
leftUnpairableRecordsAndContexts *list.List
|
||||
leftUnpairableRecordsAndContexts *types.List[*types.RecordAndContext]
|
||||
|
||||
// For sorted/doubly-streaming input
|
||||
joinBucketKeeper *utils.JoinBucketKeeper
|
||||
|
|
@ -557,7 +557,7 @@ func (tr *TransformerJoin) ingestLeftFile() {
|
|||
// the doubly-streaming/sorted join.
|
||||
|
||||
func (tr *TransformerJoin) formAndEmitPairs(
|
||||
leftRecordsAndContexts *list.List,
|
||||
leftRecordsAndContexts *types.List[*types.RecordAndContext],
|
||||
rightRecordAndContext *types.RecordAndContext,
|
||||
outputRecordsAndContexts *types.List[*types.RecordAndContext],
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -601,12 +601,12 @@ func (tr *TransformerNest) implodeValueAcrossRecords(
|
|||
|
||||
type tNestBucket struct {
|
||||
representative *mlrval.Mlrmap
|
||||
pairs *list.List
|
||||
pairs *types.List[*mlrval.Mlrmap]
|
||||
}
|
||||
|
||||
func newNestBucket(representative *mlrval.Mlrmap) *tNestBucket {
|
||||
return &tNestBucket{
|
||||
representative: representative,
|
||||
pairs: list.New(),
|
||||
pairs: *types.NewList[*types.RecordAndContext](100), // XXX size
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ func transformerRemoveEmptyColumnsParseCLI(
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
type TransformerRemoveEmptyColumns struct {
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
namesWithNonEmptyValues map[string]bool
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func transformerShuffleParseCLI(
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
type TransformerShuffle struct {
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
}
|
||||
|
||||
func NewTransformerShuffle() (*TransformerShuffle, error) {
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ type TransformerSort struct {
|
|||
comparatorFuncs []mlrval.CmpFuncInt
|
||||
|
||||
// -- State
|
||||
// Map from string to *list.List:
|
||||
// Map from string to *types.List[*types.RecordAndContext]
|
||||
recordListsByGroup *lib.OrderedMap
|
||||
// Map from string to []*lib.Mlrval:
|
||||
groupHeads *lib.OrderedMap
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func transformerTacParseCLI(
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
type TransformerTac struct {
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
}
|
||||
|
||||
func NewTransformerTac() (*TransformerTac, error) {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ func transformerUnsparsifyParseCLI(
|
|||
// ----------------------------------------------------------------
|
||||
type TransformerUnsparsify struct {
|
||||
fillerMlrval *mlrval.Mlrval
|
||||
recordsAndContexts *list.List
|
||||
recordsAndContexts *types.List[*types.RecordAndContext]
|
||||
fieldNamesSeen *lib.OrderedMap
|
||||
recordTransformerFunc RecordTransformerFunc
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue