row

package
v0.5.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 17 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenRow

func FlattenRow(row types.Row) types.Row

Types

type AddFieldMiddleware

type AddFieldMiddleware struct {
	Fields map[string]string
}

func NewAddFieldMiddleware

func NewAddFieldMiddleware(fields map[string]string) *AddFieldMiddleware

func (*AddFieldMiddleware) Close added in v0.3.1

func (a *AddFieldMiddleware) Close(ctx context.Context) error

func (*AddFieldMiddleware) Process

func (a *AddFieldMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type ColumnMiddlewareConfig

type ColumnMiddlewareConfig struct {
	FieldRenames map[types.FieldName]types.FieldName `yaml:"renames"`
	// FIXME regex renames actually need to ordered
	RegexpRenames RegexpReplacements `yaml:"regexpRenames"`
}

type ColumnsChannelMiddleware added in v0.3.1

type ColumnsChannelMiddleware struct {
	// contains filtered or unexported fields
}

ColumnsChannelMiddleware sends the column names of each row it receives to a channel. The column names are sent in a separate goroutine so as not to block the pipeline.

func NewColumnsChannelMiddleware added in v0.3.1

func NewColumnsChannelMiddleware(c chan<- []types.FieldName, onlyFirstRow bool) *ColumnsChannelMiddleware

func (*ColumnsChannelMiddleware) Close added in v0.3.1

func (*ColumnsChannelMiddleware) Process added in v0.3.1

func (c *ColumnsChannelMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type FieldsFilterMiddleware

type FieldsFilterMiddleware struct {
	// contains filtered or unexported fields
}

FieldsFilterMiddleware keeps columns that are in the fields list and removes columns that are in the filters list.

empty lists means that all columns are accepted.

The returned rows are SimpleRows

func NewFieldsFilterMiddleware

func NewFieldsFilterMiddleware(fields []string, filters []string) *FieldsFilterMiddleware

func (*FieldsFilterMiddleware) Close added in v0.3.1

func (ffm *FieldsFilterMiddleware) Close(ctx context.Context) error

func (*FieldsFilterMiddleware) Process

func (ffm *FieldsFilterMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type FlattenObjectMiddleware

type FlattenObjectMiddleware struct {
}

func NewFlattenObjectMiddleware

func NewFlattenObjectMiddleware() *FlattenObjectMiddleware

func (*FlattenObjectMiddleware) Close added in v0.3.1

func (fom *FlattenObjectMiddleware) Close(ctx context.Context) error

func (*FlattenObjectMiddleware) Process

func (fom *FlattenObjectMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type LambdaMiddleware added in v0.3.8

type LambdaMiddleware struct {
	Function func(ctx context.Context, row types.Row) ([]types.Row, error)
}

func NewLambdaMiddleware added in v0.3.8

func NewLambdaMiddleware(function func(ctx context.Context, row types.Row) ([]types.Row, error)) *LambdaMiddleware

func (*LambdaMiddleware) Close added in v0.3.8

func (l *LambdaMiddleware) Close(ctx context.Context) error

func (*LambdaMiddleware) Process added in v0.3.8

func (l *LambdaMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type OutputChannelMiddleware added in v0.3.1

type OutputChannelMiddleware[T interface{ ~string }] struct {
	// contains filtered or unexported fields
}

OutputChannelMiddleware sends each row it receives to a channel after formatting it with the given formatter. This will block the pipeline until the channel is read from (or the buffer of the channel is full).

func NewOutputChannelMiddleware added in v0.3.1

func NewOutputChannelMiddleware[T interface{ ~string }](
	formatter formatters.RowOutputFormatter,
	c chan<- T,
) *OutputChannelMiddleware[T]

func (*OutputChannelMiddleware[T]) Close added in v0.3.1

func (o *OutputChannelMiddleware[T]) Close(ctx context.Context) error

func (*OutputChannelMiddleware[T]) Process added in v0.3.1

func (o *OutputChannelMiddleware[T]) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type OutputMiddleware added in v0.3.1

type OutputMiddleware struct {
	// contains filtered or unexported fields
}

func NewOutputMiddleware added in v0.3.1

func NewOutputMiddleware(formatter formatters.RowOutputFormatter, writer io.Writer) *OutputMiddleware

func (OutputMiddleware) Close added in v0.3.1

func (o OutputMiddleware) Close(ctx context.Context) error

func (OutputMiddleware) Process added in v0.3.1

func (o OutputMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type RegexReplacement

type RegexReplacement struct {
	Regexp      *regexp.Regexp
	Replacement string
}

type RegexpReplacement

type RegexpReplacement struct {
	Regexp      *regexp.Regexp
	Replacement string
}

type RegexpReplacements

type RegexpReplacements []*RegexpReplacement

func (*RegexpReplacements) UnmarshalYAML

func (rr *RegexpReplacements) UnmarshalYAML(value *yaml.Node) error

type RegexpSkip

type RegexpSkip struct {
	Regexp *regexp.Regexp
}

type RemoveDuplicatesMiddleware

type RemoveDuplicatesMiddleware struct {
	// contains filtered or unexported fields
}

func NewRemoveDuplicatesMiddleware

func NewRemoveDuplicatesMiddleware(columns ...string) *RemoveDuplicatesMiddleware

func (*RemoveDuplicatesMiddleware) Close added in v0.3.1

func (*RemoveDuplicatesMiddleware) Process

func (r *RemoveDuplicatesMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type RemoveNullsMiddleware

type RemoveNullsMiddleware struct {
}

func NewRemoveNullsMiddleware

func NewRemoveNullsMiddleware() *RemoveNullsMiddleware

func (*RemoveNullsMiddleware) Close added in v0.3.1

func (rnm *RemoveNullsMiddleware) Close(ctx context.Context) error

func (*RemoveNullsMiddleware) Process

func (rnm *RemoveNullsMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type RenameColumnMiddleware

type RenameColumnMiddleware struct {
	Renames map[types.FieldName]types.FieldName
	// orderedmap *regexp.Regexp -> string
	RegexpRenames RegexpReplacements
	// contains filtered or unexported fields
}

func NewFieldRenameColumnMiddleware

func NewFieldRenameColumnMiddleware(renames map[types.FieldName]types.FieldName) *RenameColumnMiddleware

func NewRegexpRenameColumnMiddleware

func NewRegexpRenameColumnMiddleware(renames RegexpReplacements) *RenameColumnMiddleware

func NewRenameColumnMiddleware

func NewRenameColumnMiddleware(
	renames map[types.FieldName]types.FieldName,
	regexpRenames RegexpReplacements,
) *RenameColumnMiddleware

func NewRenameColumnMiddlewareFromYAML

func NewRenameColumnMiddlewareFromYAML(decoder *yaml.Decoder) (*RenameColumnMiddleware, error)

func (*RenameColumnMiddleware) Close added in v0.3.1

func (*RenameColumnMiddleware) Process

func (r *RenameColumnMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type ReorderColumnOrderMiddleware

type ReorderColumnOrderMiddleware struct {
	// contains filtered or unexported fields
}

func NewReorderColumnOrderMiddleware

func NewReorderColumnOrderMiddleware(columns []types.FieldName) *ReorderColumnOrderMiddleware

func (*ReorderColumnOrderMiddleware) Close added in v0.3.1

func (*ReorderColumnOrderMiddleware) Process

func (scm *ReorderColumnOrderMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type ReplaceMiddleware

type ReplaceMiddleware struct {
	Replacements      map[types.FieldName][]*Replacement
	RegexReplacements map[types.FieldName][]*RegexpReplacement
	RegexSkips        map[types.FieldName][]*RegexpSkip
	Skips             map[types.FieldName][]*Skip
}

func NewReplaceMiddleware

func NewReplaceMiddleware(
	replacements map[types.FieldName][]*Replacement,
	regexReplacements map[types.FieldName][]*RegexpReplacement,
	regexSkips map[types.FieldName][]*RegexpSkip,
	skips map[types.FieldName][]*Skip,
) *ReplaceMiddleware

func NewReplaceMiddlewareFromYAML

func NewReplaceMiddlewareFromYAML(b []byte) (*ReplaceMiddleware, error)

func (*ReplaceMiddleware) Close added in v0.3.1

func (r *ReplaceMiddleware) Close(ctx context.Context) error

func (*ReplaceMiddleware) Process

func (r *ReplaceMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type Replacement

type Replacement struct {
	Pattern     string
	Replacement string
}

type Skip

type Skip struct {
	Pattern string
}

type SkipLimitMiddleware added in v0.4.21

type SkipLimitMiddleware struct {
	Skip  int
	Limit int
	// contains filtered or unexported fields
}

func (*SkipLimitMiddleware) Close added in v0.4.21

func (h *SkipLimitMiddleware) Close(ctx context.Context) error

func (*SkipLimitMiddleware) Process added in v0.4.21

func (h *SkipLimitMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type SortColumnsMiddleware

type SortColumnsMiddleware struct {
}

func NewSortColumnsMiddleware

func NewSortColumnsMiddleware() *SortColumnsMiddleware

func (*SortColumnsMiddleware) Close added in v0.3.1

func (scm *SortColumnsMiddleware) Close(ctx context.Context) error

func (*SortColumnsMiddleware) Process

func (scm *SortColumnsMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type TemplateMiddleware

type TemplateMiddleware struct {

	// this field is used to replace "." in keys before passing them to the template,
	// in order to avoid having to use the `index` template function to access fields
	// that contain a ".", which is frequent due to flattening.
	RenameSeparator string
	// contains filtered or unexported fields
}

func NewTemplateMiddleware

func NewTemplateMiddleware(
	templateStrings map[types.FieldName]string,
	renameSeparator string) (*TemplateMiddleware, error)

NewTemplateMiddleware creates a new TemplateMiddleware which is the simplest go template middleware.

It will render the template for each row and return the result as a new column called with the given title.

Because nested objects will be flattened to individual columns using the . separator, this will make fields inaccessible to the template. One way around this is to use {{ index . "field.subfield" }} in the template. Another is to pass a separator rename option.

TODO(manuel, 2023-02-02) Add support for passing in custom funcmaps See #110 https://github.com/go-go-golems/glazed/issues/110

func (*TemplateMiddleware) Close added in v0.3.1

func (rgtm *TemplateMiddleware) Close(ctx context.Context) error

func (*TemplateMiddleware) Process

func (rgtm *TemplateMiddleware) Process(ctx context.Context, row types.Row) ([]types.Row, error)

type TemplateMiddlewareOption added in v0.3.1

type TemplateMiddlewareOption func(*TemplateMiddleware)

func WithFuncMaps added in v0.3.1

func WithFuncMaps(funcMaps ...template.FuncMap) TemplateMiddlewareOption

func WithRenameSeparator added in v0.3.1

func WithRenameSeparator(separator string) TemplateMiddlewareOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL