helper

package
v1.17.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNextByteEqual

func AssertNextByteEqual(z *bytepool.ZReader, expect byte) error

AssertNextByteEqual reads the next non space byte from z throws error if byte is not same as expect

func BlockToFrame

func BlockToFrame(blockStream <-chan *data.Block) (<-chan [][]string, []*column.CHColumn, func([][]string), bool)

BlockToFrame converts all blocks to respective string frame in order. assumes that blocks coming at least have 1 row. returns false if channel is closed initially.

func DiscardUntilByteEscaped

func DiscardUntilByteEscaped(z *bytepool.ZReader, stop byte) error

func FlushZReader

func FlushZReader(z *bytepool.ZReader)

func ReadCHElemTillStop

func ReadCHElemTillStop(w Writer, z *bytepool.ZReader, col column.CHColumnData, stop byte) error

func ReadColumnTextsCont

func ReadColumnTextsCont(fb *bytepool.FrameBuffer, numRows int, cols []*column.CHColumn, rReader RowReader) (int, error)

func ReadFirstColumnTexts

func ReadFirstColumnTexts(fb *bytepool.FrameBuffer, numRows int, cols []*column.CHColumn, rReader RowReader) (int, error)

func ReadNextNonSpaceByte

func ReadNextNonSpaceByte(z *bytepool.ZReader) (byte, error)

func ReadNextNonSpaceExceptNewLineByte

func ReadNextNonSpaceExceptNewLineByte(z *bytepool.ZReader) (byte, error)

func ReadRow

func ReadRow(fb *bytepool.FrameBuffer, cols []*column.CHColumn, e ElemReader) error

func ReadStringUntilByte

func ReadStringUntilByte(w Writer, z *bytepool.ZReader, b byte) (int, error)

ReadStringUntilByte reads content of buffer until including given byte appear or EOF Write the bytes into Writer Returns number of bytes (excluding quote) written and error

func TableToBlockStream

func TableToBlockStream(ctx context.Context, sample *data.Block, blockSize int, tReader TableReader,
) (blockStream <-chan *data.Block, yield func() (int, error))

func WriteCHElemString

func WriteCHElemString(w io.Writer, s string, col *column.CHColumn) error

func WriteFirstFrame

func WriteFirstFrame(frame [][]string, cols []*column.CHColumn, rWriter RowWriter) (int, error)

func WriteFrameCont

func WriteFrameCont(frame [][]string, cols []*column.CHColumn, rWriter RowWriter) (int, error)

func WriteTableFromBlockStream

func WriteTableFromBlockStream(blockStream <-chan *data.Block, tWriter TableWriter) (int, error)

func YieldTableStream

func YieldTableStream(eg *errgroup.Group, colTextsStreamer *ColumnTextsStreamer, toBlockProcess *ColumnTextsToBlock,
) func() (int, error)

Types

type ColumnTextsPool

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

func NewColumnTextsPool

func NewColumnTextsPool(numCols, numRows int) *ColumnTextsPool

func (*ColumnTextsPool) NewColumnTextsResult

func (c *ColumnTextsPool) NewColumnTextsResult(fb *bytepool.FrameBuffer) *ColumnTextsResult

type ColumnTextsResult

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

func (*ColumnTextsResult) Close

func (c *ColumnTextsResult) Close()

func (*ColumnTextsResult) Get

func (c *ColumnTextsResult) Get() [][]string

type ColumnTextsStreamer

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

func NewColumnTextsStreamer

func NewColumnTextsStreamer(sample *data.Block, blockSize int, tReader TableReader) *ColumnTextsStreamer

func (*ColumnTextsStreamer) Finish

func (c *ColumnTextsStreamer) Finish() (int, error)

func (*ColumnTextsStreamer) Start

func (c *ColumnTextsStreamer) Start(ctx context.Context) <-chan *ColumnTextsResult

type ColumnTextsToBlock

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

func NewColumnTextsToBlock

func NewColumnTextsToBlock(ctStream <-chan *ColumnTextsResult, sample *data.Block) *ColumnTextsToBlock

func (*ColumnTextsToBlock) Error

func (a *ColumnTextsToBlock) Error() error

func (*ColumnTextsToBlock) Finish

func (a *ColumnTextsToBlock) Finish() (rowsProcessed int, err error)

func (*ColumnTextsToBlock) Start

func (a *ColumnTextsToBlock) Start(ctx context.Context) <-chan *data.Block

type ElemReader

type ElemReader interface {
	ReadElem(fb *bytepool.FrameBuffer, cols []*column.CHColumn, idx int) error
}

type ReadColumnTexts

type ReadColumnTexts func(fb *bytepool.FrameBuffer, rows int, cols []*column.CHColumn) (int, error)

type RecycleColumnTexts

type RecycleColumnTexts func(columnTexts [][]string)
var RecycleColumnTextsNoOp RecycleColumnTexts = func(columnTexts [][]string) {}

type RowReader

type RowReader interface {
	ReadFirstRow(fb *bytepool.FrameBuffer, cols []*column.CHColumn) error
	ReadRowCont(fb *bytepool.FrameBuffer, cols []*column.CHColumn) error
}

type RowWriter

type RowWriter interface {
	WriteFirstRow(record []string, cols []*column.CHColumn) error
	WriteRowCont(record []string, cols []*column.CHColumn) error
}

type TableReader

type TableReader interface {
	ReadFirstColumnTexts(fb *bytepool.FrameBuffer, numRows int, cols []*column.CHColumn) (int, error)
	ReadColumnTextsCont(fb *bytepool.FrameBuffer, numRows int, cols []*column.CHColumn) (int, error)
}

type TableWriter

type TableWriter interface {
	// WriteFirstFrame writes the first frame generated from the first block with data from server.
	// meant for writing Headers if any (eg. JSON)
	// return number of rows written and error if any.
	WriteFirstFrame(frame [][]string, cols []*column.CHColumn) (int, error)
	// WriteFrameCont is same as WriteFirstFrame but not for first row
	WriteFrameCont(frame [][]string, cols []*column.CHColumn) (int, error)
	// Flush indicates all blocks are read and caller should write any last data and do clean up
	Flush() error
}

type Writer

type Writer interface {
	io.Writer
	io.StringWriter
	io.ByteWriter
}

Jump to

Keyboard shortcuts

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