Documentation
¶
Index ¶
Constants ¶
View Source
const ( GetOp = iota PutOp = iota DelOp = iota )
Variables ¶
View Source
var Model = pp.Model[MapState, Input, Output]{ Init: NewMapState, Partition: func(history []pp.Operation[Input, Output]) [][]pp.Operation[Input, Output] { indexMap := map[string]int{} var partitions [][]pp.Operation[Input, Output] for _, op := range history { i := op.Input ix, found := indexMap[i.Key] if !found { partitions = append(partitions, []pp.Operation[Input, Output]{op}) indexMap[i.Key] = len(partitions) - 1 } else { partitions[ix] = append(partitions[ix], op) } } return partitions }, Step: func(s MapState, i Input, o Output) (bool, MapState) { stateVal, found := s.m[i.Key] switch i.Operation { case GetOp: if errors.Is(o.Err, simpledb.ErrNotFound) { return !found, s } else if stateVal == o.Val { return true, s } break case PutOp: if o.Err == nil { s.m[i.Key] = i.Val return true, s } break case DelOp: if o.Err == nil { delete(s.m, i.Key) return true, s } break } if o.Err != nil { log.Printf("unexpected error state found for key: [%s] %v\n", i.Key, o.Err) panic(o.Err) } return false, s }, DescribeOperation: func(i Input, o Output) string { opName := "" switch i.Operation { case GetOp: opName = "Get" break case PutOp: opName = "Put" break case DelOp: opName = "Del" break } return fmt.Sprintf("%s(%s) -> %s", opName, i.Key, shorten(o.Val, 5)) }, }
Functions ¶
Types ¶
type DatabaseClientRecorder ¶
type DatabaseClientRecorder struct {
// contains filtered or unexported fields
}
func NewDatabaseRecorder ¶
func NewDatabaseRecorder(db simpledb.DatabaseI, clientId int) *DatabaseClientRecorder
func (*DatabaseClientRecorder) Delete ¶
func (d *DatabaseClientRecorder) Delete(key string) error
func (*DatabaseClientRecorder) Get ¶
func (d *DatabaseClientRecorder) Get(key string) (string, error)
func (*DatabaseClientRecorder) Operations ¶
func (d *DatabaseClientRecorder) Operations() []porcupine.Operation[Input, Output]
func (*DatabaseClientRecorder) Put ¶
func (d *DatabaseClientRecorder) Put(key, value string) error
type MapState ¶
type MapState struct {
// contains filtered or unexported fields
}
func NewMapState ¶
func NewMapState() MapState
Click to show internal directories.
Click to hide internal directories.