Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AvitalFineRedis committed Jun 10, 2021
1 parent 3e9191b commit c167917
Showing 1 changed file with 76 additions and 8 deletions.
84 changes: 76 additions & 8 deletions example_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ExampleNewClientFromPool() {
}

// exemplifies the TdCreate function
func ExampleTdCreate() {
func ExampleClient_TdCreate() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

Expand All @@ -66,8 +66,8 @@ func ExampleTdCreate() {

}

// exemplifies the TdCreate function
func ExampleTdAdd() {
// exemplifies the TdAdd function
func ExampleClient_TdAdd() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

Expand All @@ -88,8 +88,8 @@ func ExampleTdAdd() {

}

// exemplifies the TdMin TdMax and TdCdf functions
func ExampleTdQuery() {
// exemplifies the TdMin function
func ExampleClient_TdMin() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

Expand All @@ -110,16 +110,84 @@ func ExampleTdQuery() {
fmt.Println("Error:", err)
}

fmt.Println(min)
// Output: 1
}

// exemplifies the TdMax function
func ExampleClient_TdMax() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

key := "example"
_, err := client.TdCreate(key, 10)
if err != nil {
fmt.Println("Error:", err)
}

samples := map[float64]float64{1.0: 1.0, 2.0: 2.0, 3.0: 3.0}
_, err = client.TdAdd(key, samples)
if err != nil {
fmt.Println("Error:", err)
}

max, err := client.TdMax(key)
if err != nil {
fmt.Println("Error:", err)
}

cdf, err := client.TdCdf(key, 0.0)
fmt.Println(max)
// Output: 3
}

// exemplifies the TdCdf function
func ExampleClient_TdQuantile() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

key := "example"
_, err := client.TdCreate(key, 10)
if err != nil {
fmt.Println("Error:", err)
}

samples := map[float64]float64{1.0: 1.0, 2.0: 1.0, 3.0: 1.0, 4.0: 1.0, 5.0: 1.0}
_, err = client.TdAdd(key, samples)
if err != nil {
fmt.Println("Error:", err)
}

ans, err := client.TdQuantile(key, 1.0)
if err != nil {
fmt.Println("Error:", err)
}

fmt.Println(ans)
// Output: 5
}

// exemplifies the TdCdf function
func ExampleClient_TdCdf() {
host := "localhost:6379"
var client = redisbloom.NewClient(host, "nohelp", nil)

key := "example"
_, err := client.TdCreate(key, 10)
if err != nil {
fmt.Println("Error:", err)
}

samples := map[float64]float64{1.0: 1.0, 2.0: 1.0, 3.0: 1.0, 4.0: 1.0, 5.0: 1.0}
_, err = client.TdAdd(key, samples)
if err != nil {
fmt.Println("Error:", err)
}

cdf, err := client.TdCdf(key, 1.0)
if err != nil {
fmt.Println("Error:", err)
}

fmt.Println(min, max, cdf)
// Output: 1 3 0
fmt.Println(cdf)
// Output: 0.1
}

0 comments on commit c167917

Please sign in to comment.