container

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package container implementation of some Container interfaces

@update 2023-03-26 03:57:31

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayContainer

type ArrayContainer[T any] struct {
	// contains filtered or unexported fields
}

ArrayContainer not thread safe

@author kevineluo
@update 2023-03-25 03:51:33

func NewArrayContainer

func NewArrayContainer[T any](flushSize int, flushAsync bool, flushBatch func(array []T) error) *ArrayContainer[T]

NewArrayContainer new an ArrayContainer

@param size int
@param flushAsync bool
@param flushBatch func(array []T) error
@return *ArrayContainer
@author kevineluo
@update 2023-03-26 03:46:01

func (*ArrayContainer[T]) Flush

func (container *ArrayContainer[T]) Flush() error

Flush implement interface Container

@param container *ArrayContainer[T]
@return Flush
@author kevineluo
@update 2023-03-26 05:47:10

func (*ArrayContainer[T]) Index added in v0.1.1

func (container *ArrayContainer[T]) Index(idx int) T

Index index and return target element

@receiver container *ArrayContainer
@param idx int
@return T
@author kevineluo
@update 2023-03-28 07:31:26

func (*ArrayContainer[T]) IsFull

func (container *ArrayContainer[T]) IsFull() bool

IsFull implement interface Container

@param container *ArrayContainer[T]
@return IsFull
@author kevineluo
@update 2023-03-26 05:48:23

func (*ArrayContainer[T]) Len

func (container *ArrayContainer[T]) Len() int

Len return the length of ArrayContainer

@param container *ArrayContainer[T]
@return Len
@author kevineluo
@update 2023-03-26 07:26:11

func (*ArrayContainer[T]) Put

func (container *ArrayContainer[T]) Put(element T) error

Put implement interface Container

@param container *ArrayContainer[T]
@return Put
@author kevineluo
@update 2023-03-26 05:47:12

func (*ArrayContainer[T]) Reset

func (container *ArrayContainer[T]) Reset()

Reset implement interface Container

@param container *ArrayContainer[T]
@return Reset
@author kevineluo
@update 2023-03-26 05:48:25

type ClickHouseContainer

type ClickHouseContainer struct {
	Table string

	BulkSize int
	// contains filtered or unexported fields
}

func NewClickHouseContainer

func NewClickHouseContainer(pool *chpool.Pool, table string, bulkSize int, newInputFunc func() proto.Input) (*ClickHouseContainer, error)

func (*ClickHouseContainer) Flush

func (container *ClickHouseContainer) Flush() error

func (*ClickHouseContainer) IsFull

func (container *ClickHouseContainer) IsFull() bool

func (*ClickHouseContainer) Put

func (container *ClickHouseContainer) Put(element ClickHouseRow) error

func (*ClickHouseContainer) Reset

func (container *ClickHouseContainer) Reset()

type ClickHouseRow

type ClickHouseRow interface {
	Insert(proto.Input) error
}

type Container

type Container[T any] interface {
	// Put int an element. Will NEVER check if is full so be caution.
	Put(data T) error
	// Flush will apply some action on this container. SHOULD RESET CONTAINER when called
	// when it's a sync Flush, container.put will be blocked until Flush, so Container can empty it's data properly
	// when it's a async Flush, please set the chanBufSize of the buffer to 0 to block container.put,
	// or container.put will still being called when doing Flush, so Container should split a batch from it's data to be flushed and reset itself
	Flush() error
	// IsFull return true if this container is full
	IsFull() bool
	// will call Reset when flush return error
	Reset()
}

Container data Container in the Buffer

@author kevineluo
@update 2023-03-15 09:35:51

Jump to

Keyboard shortcuts

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