state

package
v0.0.0-...-f2127f7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conflict

func Conflict(gamma *Command, delta *Command) bool

func ConflictBatch

func ConflictBatch(batch1 []Command, batch2 []Command) bool

func IsRead

func IsRead(command *Command) bool

IsRead returns true if a operation is read-only

Types

type Command

type Command struct {
	Op Operation
	K  Key
	V  Value
}

func (*Command) Execute

func (c *Command) Execute(st *State) Value

Execute is the function that execute the operation in the key value or list

func (*Command) Marshal

func (t *Command) Marshal(w io.Writer)

func (*Command) Unmarshal

func (t *Command) Unmarshal(r io.Reader) error

type Key

type Key int64

func (*Key) Marshal

func (t *Key) Marshal(w io.Writer)

func (*Key) Unmarshal

func (t *Key) Unmarshal(r io.Reader) error

type Operation

type Operation uint8
const (
	NONE Operation = iota
	PUT
	GET
	DELETE
	RLOCK
	WLOCK
	CONTAINS
)

type State

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

State holds the elements, where each element points to the next element

func InitState

func InitState(listSize int64) *State

InitState instantiates a new state and seed

func (*State) Add

func (state *State) Add(value Key) error

Add appends a value (one or more) at the end of the list

func (*State) Contains

func (state *State) Contains(value Key) (Value, bool)

Contains checks if value are present in the set.

func (*State) Replace

func (state *State) Replace(value Key) (Value, bool)

Replace a element on the list

func (*State) ShowStatus

func (state *State) ShowStatus()

ShowStatus dumps on-screem some statistics

type Value

type Value int64
const NIL Value = 0
const OK Value = 1

func (*Value) Marshal

func (t *Value) Marshal(w io.Writer)

func (*Value) Unmarshal

func (t *Value) Unmarshal(r io.Reader) error

Jump to

Keyboard shortcuts

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