stdset

package
v0.0.0-...-d5de3f3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Add = &turing.Operator{
	Name: "turing/Add",
	Zero: []byte("0"),
	Apply: func(value []byte, ops [][]byte) ([]byte, turing.Ref, error) {

		count, _ := strconv.ParseInt(cast.ToString(value), 10, 64)

		for _, op := range ops {

			increment, _ := strconv.ParseInt(cast.ToString(op), 10, 64)

			count += increment
		}

		buf, ref := fpack.Borrow(int64Len)

		buf = buf[:0]
		buf = strconv.AppendInt(buf, count, 10)

		return buf, ref, nil
	},
	Combine: func(ops [][]byte) ([]byte, turing.Ref, error) {
		// apply operands
		var count int64
		for _, op := range ops {

			increment, _ := strconv.ParseInt(cast.ToString(op), 10, 64)

			count += increment
		}

		buf, ref := fpack.Borrow(int64Len)

		buf = buf[:0]
		buf = strconv.AppendInt(buf, count, 10)

		return buf, ref, nil
	},
}

Add is an operator used by Inc to add together numerical values.

Functions

This section is empty.

Types

type Dump

type Dump struct {
	Prefix []byte
	Map    map[string]string
}

Dump will dump all key value pairs.

func (*Dump) Decode

func (d *Dump) Decode(bytes []byte) error

Decode implements the turing.Instruction interface.

func (*Dump) Describe

func (d *Dump) Describe() *turing.Description

Describe implements the turing.Instruction interface.

func (*Dump) Effect

func (d *Dump) Effect() int

Effect implements the turing.Instruction interface.

func (*Dump) Encode

func (d *Dump) Encode() ([]byte, turing.Ref, error)

Encode implements the turing.Instruction interface.

func (*Dump) Execute

func (d *Dump) Execute(mem turing.Memory, _ turing.Cache) error

Execute implements the turing.Instruction interface.

type Get

type Get struct {
	Key    []byte
	Value  []byte
	Exists bool
}

Get will get a value.

func (*Get) Decode

func (g *Get) Decode(bytes []byte) error

Decode implements the turing.Instruction interface.

func (*Get) Describe

func (g *Get) Describe() *turing.Description

Describe implements the turing.Instruction interface.

func (*Get) Effect

func (g *Get) Effect() int

Effect implements the turing.Instruction interface.

func (*Get) Encode

func (g *Get) Encode() ([]byte, turing.Ref, error)

Encode implements the turing.Instruction interface.

func (*Get) Execute

func (g *Get) Execute(mem turing.Memory, _ turing.Cache) error

Execute implements the turing.Instruction interface.

type Inc

type Inc struct {
	Key   []byte
	Value int64
}

Inc will increment an numerical value.

func (*Inc) Decode

func (i *Inc) Decode(bytes []byte) error

Decode implements the turing.Instruction interface.

func (*Inc) Describe

func (i *Inc) Describe() *turing.Description

Describe implements the turing.Instruction interface.

func (*Inc) Effect

func (i *Inc) Effect() int

Effect implements the turing.Instruction interface.

func (*Inc) Encode

func (i *Inc) Encode() ([]byte, turing.Ref, error)

Encode implements the turing.Instruction interface.

func (*Inc) Execute

func (i *Inc) Execute(mem turing.Memory, _ turing.Cache) error

Execute implements the turing.Instruction interface.

type List

type List struct {
	Prefix []byte
	Keys   [][]byte
}

List will list all keys.

func (*List) Decode

func (l *List) Decode(bytes []byte) error

Decode implements the turing.Instruction interface.

func (*List) Describe

func (l *List) Describe() *turing.Description

Describe implements the turing.Instruction interface.

func (*List) Effect

func (l *List) Effect() int

Effect implements the turing.Instruction interface.

func (*List) Encode

func (l *List) Encode() ([]byte, turing.Ref, error)

Encode implements the turing.Instruction interface.

func (*List) Execute

func (l *List) Execute(mem turing.Memory, _ turing.Cache) error

Execute implements the turing.Instruction interface.

type Set

type Set struct {
	Key   []byte
	Value []byte
}

Set will set a value.

func (*Set) Decode

func (s *Set) Decode(bytes []byte) error

Decode implements the turing.Instruction interface.

func (*Set) Describe

func (s *Set) Describe() *turing.Description

Describe implements the turing.Instruction interface.

func (*Set) Effect

func (s *Set) Effect() int

Effect implements the turing.Instruction interface.

func (*Set) Encode

func (s *Set) Encode() ([]byte, turing.Ref, error)

Encode implements the turing.Instruction interface.

func (*Set) Execute

func (s *Set) Execute(mem turing.Memory, _ turing.Cache) error

Execute implements the turing.Instruction interface.

Jump to

Keyboard shortcuts

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