csv

package
v0.59.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: MIT Imports: 19 Imported by: 21

Documentation

Overview

Package csv contains the csv result encoders and decoders.

Index

Constants

View Source
const DialectType = "csv"

Variables

This section is empty.

Functions

func AddDialectMappings

func AddDialectMappings(mappings flux.DialectMappings) error

AddDialectMappings adds the influxql specific dialect mappings.

Types

type Dialect

type Dialect struct {
	ResultEncoderConfig
}

Dialect describes the output format of queries in CSV.

func DefaultDialect

func DefaultDialect() *Dialect

func (Dialect) DialectType

func (d Dialect) DialectType() flux.DialectType

func (Dialect) Encoder

func (d Dialect) Encoder() flux.MultiResultEncoder

func (Dialect) SetHeaders

func (d Dialect) SetHeaders(w http.ResponseWriter)

type MultiResultDecoder

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

MultiResultDecoder reads multiple results from a single csv file. Results are delimited by an empty line.

func NewMultiResultDecoder

func NewMultiResultDecoder(c ResultDecoderConfig) *MultiResultDecoder

NewMultiResultDecoder creates a new MultiResultDecoder.

func (*MultiResultDecoder) Decode

type ResultDecoder

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

ResultDecoder decodes a csv representation of a result.

func NewResultDecoder

func NewResultDecoder(c ResultDecoderConfig) *ResultDecoder

NewResultDecoder creates a new ResultDecoder.

func (*ResultDecoder) Decode

func (d *ResultDecoder) Decode(r io.Reader) (flux.Result, error)

type ResultDecoderConfig

type ResultDecoderConfig struct {
	// NoHeader indicates that the CSV data will not have a header row.
	NoHeader bool
	// MaxBufferCount is the maximum number of rows that will be buffered when decoding.
	// If 0, then a value of 1000 will be used.
	MaxBufferCount int
	// Allocator is the memory allocator that will be used during decoding.
	// The default is to use an unlimited allocator when this is not set.
	Allocator *memory.Allocator
}

ResultDecoderConfig are options that can be specified on the ResultDecoder.

type ResultEncoder

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

func NewResultEncoder

func NewResultEncoder(c ResultEncoderConfig) *ResultEncoder

NewResultEncoder creates a new encoder with the provided configuration.

func (*ResultEncoder) Encode

func (e *ResultEncoder) Encode(w io.Writer, result flux.Result) (int64, error)

func (*ResultEncoder) EncodeError

func (e *ResultEncoder) EncodeError(w io.Writer, err error) error

type ResultEncoderConfig

type ResultEncoderConfig struct {
	// Annotations is a list of annotations to include.
	Annotations []string

	// NoHeader indicates whether a header row should be added.
	NoHeader bool

	// Delimiter is the character to delimite columns.
	// It must not be \r, \n, or the Unicode replacement character (0xFFFD).
	Delimiter rune
}

ResultEncoderConfig are options that can be specified on the ResultEncoder.

func DefaultEncoderConfig

func DefaultEncoderConfig() ResultEncoderConfig

func (ResultEncoderConfig) MarshalJSON

func (c ResultEncoderConfig) MarshalJSON() ([]byte, error)

func (*ResultEncoderConfig) UnmarshalJSON

func (c *ResultEncoderConfig) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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