Skip to content

Commit

Permalink
Integrate fixes from PR#91. (#126)
Browse files Browse the repository at this point in the history
This PR has been in review for a while and now there are a bunch of
conflicts and it's a branch in a fork repo so I cannot edit the branch
directly.
  • Loading branch information
martinmr authored Jan 18, 2020
1 parent 29b4dd7 commit 593823e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 3 additions & 5 deletions cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/dgraph-io/ristretto/z"
)

var wait time.Duration = time.Millisecond * 10
var wait = time.Millisecond * 10

func TestCacheKeyToHash(t *testing.T) {
keyToHashCount := 0
Expand Down Expand Up @@ -305,10 +305,8 @@ func TestCacheSet(t *testing.T) {
if val, ok := c.Get(1); val == nil || val.(int) != 1 || !ok {
t.Fatal("set/get returned wrong value")
}
} else {
if val, ok := c.Get(1); val != nil || ok {
t.Fatal("set was dropped but value still added")
}
} else if val, ok := c.Get(1); val != nil || ok {
t.Fatal("set was dropped but value still added")
}
c.Set(1, 2, 2)
val, ok := c.store.Get(z.KeyToHash(1))
Expand Down
2 changes: 1 addition & 1 deletion policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (p *tinyLFU) Push(keys []uint64) {
func (p *tinyLFU) Estimate(key uint64) int64 {
hits := p.freq.Estimate(key)
if p.door.Has(key) {
hits += 1
hits++
}
return hits
}
Expand Down
3 changes: 1 addition & 2 deletions z/rtutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func SipHash(p []byte) (l, h uint64) {

// Compression.
for len(p) >= 8 {

m := uint64(p[0]) | uint64(p[1])<<8 | uint64(p[2])<<16 | uint64(p[3])<<24 |
uint64(p[4])<<32 | uint64(p[5])<<40 | uint64(p[6])<<48 | uint64(p[7])<<56

Expand Down Expand Up @@ -252,8 +251,8 @@ func SipHash(p []byte) (l, h uint64) {
h = hash >> 1
l = hash << 1 >> 1
return l, h

}

func BenchmarkNanoTime(b *testing.B) {
for i := 0; i < b.N; i++ {
NanoTime()
Expand Down

0 comments on commit 593823e

Please sign in to comment.