Skip to content

Commit

Permalink
structure: Rename Length to FieldCount
Browse files Browse the repository at this point in the history
  • Loading branch information
ngaut committed Nov 9, 2015
1 parent fc98046 commit 88e129c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions structure/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand All @@ -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.
Expand All @@ -160,7 +160,7 @@ func (t *TxStructure) HDel(key []byte, fields ...[]byte) error {
return errors.Trace(err)
}

meta.Length--
meta.FieldCount--
}
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down

0 comments on commit 88e129c

Please sign in to comment.