From 88e129c3a167bda7252c00a43744084ac66bb26d Mon Sep 17 00:00:00 2001 From: ngaut Date: Mon, 9 Nov 2015 13:37:30 +0800 Subject: [PATCH] structure: Rename Length to FieldCount --- structure/hash.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/structure/hash.go b/structure/hash.go index 5195c945a8540..80dbf3236f9fc 100644 --- a/structure/hash.go +++ b/structure/hash.go @@ -30,17 +30,17 @@ type HashPair struct { } type hashMeta struct { - Length int64 + FieldCount int64 } func (meta hashMeta) Value() []byte { buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf[0:8], uint64(meta.Length)) + binary.BigEndian.PutUint64(buf[0:8], uint64(meta.FieldCount)) return buf } func (meta hashMeta) IsEmpty() bool { - return meta.Length <= 0 + return meta.FieldCount <= 0 } // HSet sets the string value of a hash field. @@ -119,7 +119,7 @@ func (t *TxStructure) updateHash(key []byte, field []byte, fn func(oldValue []by } if oldValue == nil { - meta.Length++ + meta.FieldCount++ if err = t.txn.Set(metaKey, meta.Value()); err != nil { return errors.Trace(err) } @@ -135,7 +135,7 @@ func (t *TxStructure) HLen(key []byte) (int64, error) { if err != nil { return 0, errors.Trace(err) } - return meta.Length, nil + return meta.FieldCount, nil } // HDel deletes one or more hash fields. @@ -160,7 +160,7 @@ func (t *TxStructure) HDel(key []byte, fields ...[]byte) error { return errors.Trace(err) } - meta.Length-- + meta.FieldCount-- } } @@ -260,7 +260,7 @@ func (t *TxStructure) loadHashMeta(metaKey []byte) (hashMeta, error) { return hashMeta{}, errors.Trace(err) } - meta := hashMeta{Length: 0} + meta := hashMeta{FieldCount: 0} if v == nil { return meta, nil } @@ -269,7 +269,7 @@ func (t *TxStructure) loadHashMeta(metaKey []byte) (hashMeta, error) { return meta, errors.New("invalid list meta data") } - meta.Length = int64(binary.BigEndian.Uint64(v[0:8])) + meta.FieldCount = int64(binary.BigEndian.Uint64(v[0:8])) return meta, nil }