Skip to content

Commit

Permalink
fixing indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kwertop committed Aug 24, 2023
1 parent dd23e8b commit 6d03992
Showing 1 changed file with 68 additions and 68 deletions.
136 changes: 68 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,35 +146,35 @@ import (
)

func main() {
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")

// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)
// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)

// create a new redis backed cuckoo filter with 1000000 items and a false positive rate of 0.0001
// see doc for more details
filter, _ := gostatix.NewCuckooFilterRedisWithErrorRate(1000000, 4, 100, 0.001)
filter, _ := gostatix.NewCuckooFilterRedisWithErrorRate(1000000, 4, 100, 0.001)

// insert a few elements - "cat" and "dog"
filter.Insert(e1, false)
filter.Insert(e2, false)
// insert a few elements - "cat" and "dog"
filter.Insert(e1, false)
filter.Insert(e2, false)

// do a lookup for an element
ok, _ = filter.Lookup(e1)
fmt.Printf("found cat, %v\n", ok) // found cat, true
// do a lookup for an element
ok, _ = filter.Lookup(e1)
fmt.Printf("found cat, %v\n", ok) // found cat, true

ok, _ = filter.Lookup([]byte("elephant"))
fmt.Printf("found elephant, %v\n", ok) // found elephant, false
ok, _ = filter.Lookup([]byte("elephant"))
fmt.Printf("found elephant, %v\n", ok) // found elephant, false

ok, _ = filter.Lookup(e2)
fmt.Printf("found dog, %v\n", ok) // found dog, true
ok, _ = filter.Lookup(e2)
fmt.Printf("found dog, %v\n", ok) // found dog, true

//remove an element
_, _ = filter.Remove(e2)
//remove an element
_, _ = filter.Remove(e2)

ok, _ = filter.Lookup(e2)
fmt.Printf("found dog, %v\n", ok) // found dog, false
ok, _ = filter.Lookup(e2)
fmt.Printf("found dog, %v\n", ok) // found dog, false
}
```

Expand Down Expand Up @@ -225,26 +225,26 @@ import (
)

func main() {
// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)
// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)

// create a new redis backed count-min sketch with error rate of 0.0001 and delta of 0.9999
sketch, _ := gostatix.NewCountMinSketchRedisFromEstimates(0.001, 0.999)
sketch, _ := gostatix.NewCountMinSketchRedisFromEstimates(0.001, 0.999)

e1 := []byte("cat")
e2 := []byte("dog")

// insert counts of few elements - "cat" and "dog"
err := sketch.Update(e1, 2)
if err != nil {
fmt.Printf("error: %v\n", err)
}
sketch.Update(e2, 3)
sketch.Update(e1, 1)
e2 := []byte("dog")

// do a lookup for an count for any element
count, _ = sketch.Count(e1)
fmt.Printf("found %v cats\n", count) // found 3 cats
// insert counts of few elements - "cat" and "dog"
err := sketch.Update(e1, 2)
if err != nil {
fmt.Printf("error: %v\n", err)
}
sketch.Update(e2, 3)
sketch.Update(e1, 1)

// do a lookup for an count for any element
count, _ = sketch.Count(e1)
fmt.Printf("found %v cats\n", count) // found 3 cats
}

```
Expand Down Expand Up @@ -296,26 +296,26 @@ import (
)

func main() {
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")

// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)
// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)

// create a new redis backed hyperloglog with 4 registers
hll, _ := gostatix.NewHyperLogLogRedis(4)
// create a new redis backed hyperloglog with 4 registers
hll, _ := gostatix.NewHyperLogLogRedis(4)

e1 := []byte("cat")
e2 := []byte("dog")
e2 := []byte("dog")

// insert counts of few elements
hll.Update(e1)
hll.Update(e2)
hll.Update(e1)
// insert counts of few elements
hll.Update(e1)
hll.Update(e2)
hll.Update(e1)

// do a lookup for count of distinct elements
distinct, _ := hll.Count(true, true)
fmt.Printf("found %v distinct elements\n", distinct) // found 2 distinct elements
// do a lookup for count of distinct elements
distinct, _ := hll.Count(true, true)
fmt.Printf("found %v distinct elements\n", distinct) // found 2 distinct elements
}

```
Expand Down Expand Up @@ -370,29 +370,29 @@ import (
)

func main() {
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")
// parse redis uri
redisConnOpt, _ := gostatix.ParseRedisURI("redis://127.0.0.1:6379")

// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)
// create redis connection
gostatix.MakeRedisClient(*redisConnOpt)

// create a new redis backed top-k with k=2, error rate of 0.001 and delta of 0.999
t1 := gostatix.NewTopKRedis(2, 0.001, 0.999)
// create a new redis backed top-k with k=2, error rate of 0.001 and delta of 0.999
t1 := gostatix.NewTopKRedis(2, 0.001, 0.999)

e1 := []byte("cat")
e2 := []byte("dog")
e3 := []byte("lion")
e4 := []byte("tiger")

// insert counts of few elements
t1.Insert(e1, 3)
t1.Insert(e2, 2)
t1.Insert(e1, 1)
t1.Insert(e3, 3)
t1.Insert(e4, 1)

// do a lookup for top-k (2) elements
values1, _ := t1.Values()
fmt.Printf("%v\n", values1) // [{cat 4} {lion 3}]
e2 := []byte("dog")
e3 := []byte("lion")
e4 := []byte("tiger")

// insert counts of few elements
t1.Insert(e1, 3)
t1.Insert(e2, 2)
t1.Insert(e1, 1)
t1.Insert(e3, 3)
t1.Insert(e4, 1)

// do a lookup for top-k (2) elements
values1, _ := t1.Values()
fmt.Printf("%v\n", values1) // [{cat 4} {lion 3}]
}
```

0 comments on commit 6d03992

Please sign in to comment.