// Put sets the value for the given key. It overwrites any previous value for that key
Put sets the value for the given key. It overwrites any previous value for that key
// Put sets the value for the given key . It overwrites any previous value for that key
func (k *KVStore) Put(hkey uint64, value storage.Entry) error {
	if len(k.tables) == 0 {
		if err := k.makeTable(); err != nil {
			return err
		}
	}
	for {
		t := k.tables[len(k.tables)-1]
		err := t.Put(hkey, value)
		if errors.Is(err, table.ErrNotEnoughSpace) {
			err := k.makeTable()
			if err != nil {
				return err
			}
			continue
		}
		if err != nil {
			return err
		}
		break
	}
	return nil
}
func ( k * KVStore ) Put ( hkey uint64 , value storage . Entry ) error { if len ( k . tables ) == 0 { if err := k . makeTable ( ) ; err != nil { return err } } for { t := k . tables [ len ( k . tables ) - 1 ] err := t . Put ( hkey , value ) if errors . Is ( err , table . ErrNotEnoughSpace ) { err := k . makeTable ( ) if err != nil { return err } continue } if err != nil { return err } break } return nil }
Put sets the value for the given key.
Put sets the value for the given key .
// Get the last value, storage only calls Put on the last created table. // try again // everything is ok