Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Diehl <[email protected]>
  • Loading branch information
owen-d committed Feb 1, 2024
1 parent 1e32ead commit a0ec9cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
19 changes: 3 additions & 16 deletions pkg/storage/bloom/v1/bounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v1
import (
"fmt"
"hash"
"strconv"
"strings"

"github.com/pkg/errors"
Expand All @@ -20,14 +19,6 @@ const (
After
)

func ParseFingerprint(s string) (model.Fingerprint, error) {
fp, err := strconv.ParseUint(s, 16, 64)
if err != nil {
return 0, fmt.Errorf("error parsing fingerprint %s : %w", s, err)
}
return model.Fingerprint(fp), nil
}

// ParseBoundsFromAddr parses a fingerprint bounds from a string
func ParseBoundsFromAddr(s string) (FingerprintBounds, error) {
parts := strings.Split(s, "-")
Expand All @@ -36,11 +27,11 @@ func ParseBoundsFromAddr(s string) (FingerprintBounds, error) {

// ParseBoundsFromParts parses a fingerprint bounds already separated strings
func ParseBoundsFromParts(a, b string) (FingerprintBounds, error) {
minFingerprint, err := ParseFingerprint(a)
minFingerprint, err := model.ParseFingerprint(a)
if err != nil {
return FingerprintBounds{}, fmt.Errorf("error parsing minFingerprint %s : %w", a, err)
}
maxFingerprint, err := ParseFingerprint(b)
maxFingerprint, err := model.ParseFingerprint(b)
if err != nil {
return FingerprintBounds{}, fmt.Errorf("error parsing maxFingerprint %s : %w", b, err)
}
Expand Down Expand Up @@ -68,12 +59,8 @@ func (b FingerprintBounds) Hash(h hash.Hash32) error {
// content addressable storage.
// TODO(owen-d): incorporate this into the schema so we can change it,
// similar to `{,Parse}ExternalKey`
func (b FingerprintBounds) Addr() string {
return fmt.Sprintf("%x-%x", uint64(b.Min), uint64(b.Max))
}

func (b FingerprintBounds) String() string {
return b.Addr()
return fmt.Sprint(fmt.Sprintf("%016x-%016x", uint64(b.Min), uint64(b.Max)))
}

func (b FingerprintBounds) Less(other FingerprintBounds) bool {
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/bloom/v1/bounds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
)

func Test_ParseFingerprint(t *testing.T) {
fp, err := ParseFingerprint("7d0")
fp, err := model.ParseFingerprint("7d0")
assert.NoError(t, err)
assert.Equal(t, model.Fingerprint(2000), fp)
}

func Test_FingerprintBounds_Addr(t *testing.T) {
func Test_FingerprintBounds_String(t *testing.T) {
bounds := NewBounds(10, 2000)
assert.Equal(t, "a-7d0", bounds.Addr())
assert.Equal(t, "000000000000000a-00000000000007d0", bounds.String())
}

func Test_ParseBoundsFromAddr(t *testing.T) {
Expand Down

0 comments on commit a0ec9cc

Please sign in to comment.