swap

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfigSelector  = errors.New("please verify the selectors attribute in the configuration file, it is invalid")
	ErrInvalidConfigFrameSize = errors.New("please verify the frameSize attribute in the configuration file, it must be greater than 0")
)

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(selector *Selector, seed int64) *Cache

NewCache creates a new empty cache.

func (*Cache) GetSelector

func (c *Cache) GetSelector() *Selector

GetSelector returns the selector used by the cache.

func (*Cache) Post

func (c *Cache) Post(row Row)

Post the row to feed the cache with new tuples.

func (*Cache) PullRandom

func (c *Cache) PullRandom() Tuple

PullRandom removes a random tuple from the cache and returns it.

type CacheList

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

func NewCacheList

func NewCacheList() *CacheList

NewCacheList creates a new empty cache list.

func (*CacheList) Add

func (cl *CacheList) Add(cache *Cache)

Add a cache to the cache list.

func (*CacheList) All

func (cl *CacheList) All() []*Cache

All returns all caches in the cache list.

func (*CacheList) Post

func (cl *CacheList) Post(row Row)

Post the row to feed all caches with new tuples.

type Configuration

type Configuration struct {
	Version   string `yaml:"version"`
	Seed      int64  `yaml:"seed"`
	FrameSize int    `yaml:"frameSize"`
	Selectors []any  `yaml:"selectors"`
}

func LoadConfigurationFromYAML

func LoadConfigurationFromYAML(filename string) (Configuration, error)

LoadConfigurationFromYAML returns the configuration of the yaml file in a Configuration object.

func (Configuration) BuildDriver

func (c Configuration) BuildDriver() *Driver

func (Configuration) MustValidate

func (c Configuration) MustValidate()

type Driver

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

func NewDriver

func NewDriver(seed int64, frameSize int) *Driver

func (*Driver) AddSelector

func (d *Driver) AddSelector(selector *Selector)

func (*Driver) Run

func (d *Driver) Run(reader RowReader, collector RowCollector)

type Frame

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

func NewFrame

func NewFrame(size int) *Frame

NewFrame creates a new empty frame.

func (*Frame) FillUp

func (f *Frame) FillUp(reader RowReader, callback func(Row)) bool

FillUp fills the frame with Rows read from reader, calls the callback function for each row added to the frame, and finally returns false if there is no more values in the Frame and it can't read from the reader.

func (*Frame) PullFirst

func (f *Frame) PullFirst() Row

PullFirst get the first row and removes it from the frame.

type Provider

type Provider = func() Tuple

type Row

type Row = *parser.Object

type RowCollector

type RowCollector interface {
	Collect(row Row) error
}

type RowReader

type RowReader interface {
	HasRow() bool
	ReadRow() (Row, error)
}

type Selector

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

func NewSelector

func NewSelector(jsonpaths ...string) *Selector

NewSelector creates a new selector.

func (*Selector) Select

func (s *Selector) Select(row Row) []Tuple

Select all tuples from the given row that are matched by the selector.

func (*Selector) Update

func (s *Selector) Update(row Row, provider Provider)

Update all tuples matched by the selector with values provided by the provider.

type Tuple

type Tuple = *parser.Array

func NewTuple

func NewTuple() Tuple

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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