-
Notifications
You must be signed in to change notification settings - Fork 216
/
aaa_record_transformer.go
74 lines (64 loc) · 2.09 KB
/
aaa_record_transformer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package transformers
import (
"container/list"
"os"
"github.com/johnkerl/miller/v6/pkg/cli"
"github.com/johnkerl/miller/v6/pkg/types"
)
// IRecordTransformer is the interface satisfied by all transformers, i.e.,
// Miller verbs. See stream.go for context on the channels, as well as for
// context on end-of-record-stream signaling.
type IRecordTransformer interface {
Transform(
inrecAndContext *types.RecordAndContext,
outputRecordsAndContexts *list.List, // list of *types.RecordAndContext
inputDownstreamDoneChannel <-chan bool,
outputDownstreamDoneChannel chan<- bool,
)
}
type RecordTransformerFunc func(
inrecAndContext *types.RecordAndContext,
outputRecordsAndContexts *list.List, // list of *types.RecordAndContext
inputDownstreamDoneChannel <-chan bool,
outputDownstreamDoneChannel chan<- bool,
)
// Used within some verbs
type RecordTransformerHelperFunc func(
inrecAndContext *types.RecordAndContext,
outputRecordsAndContexts *list.List, // list of *types.RecordAndContext
)
type TransformerUsageFunc func(
ostream *os.File,
)
type TransformerParseCLIFunc func(
pargi *int,
argc int,
args []string,
mainOptions *cli.TOptions,
doConstruct bool, // false for first pass of CLI-parse, true for second pass
) IRecordTransformer
type TransformerSetup struct {
Verb string
UsageFunc TransformerUsageFunc
ParseCLIFunc TransformerParseCLIFunc
// For seqgen only -- all other transformers process records sourced by the
// record-reader. The seqgen verb, by contrast, is a record-source of its
// own. (The seqgen verb probably should have been designed as a zero-file
// record "reader" object, rather than a verb, alas.)
IgnoresInput bool
}
// HandleDefaultDownstreamDone is a utility function for most verbs other than
// head, tee, and seqgen to use for passing downstream-done flags back
// upstream. See ChainTransformer for context.
func HandleDefaultDownstreamDone(
inputDownstreamDoneChannel <-chan bool,
outputDownstreamDoneChannel chan<- bool,
) {
select {
case b := <-inputDownstreamDoneChannel:
outputDownstreamDoneChannel <- b
break
default:
break
}
}