Created
October 16, 2014 18:46
-
-
Save tgruben/840d1c34bfd38cfba671 to your computer and use it in GitHub Desktop.
Simpler Go script to reproduce loss ob sign bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/gocql/gocql" | |
"time" | |
) | |
type bm struct { | |
id int64 | |
block int64 | |
} | |
func main() { | |
cluster := gocql.NewCluster("127.0.0.1") | |
cluster.Keyspace = "hotbox" | |
cluster.Consistency = gocql.One | |
cluster.Timeout = 5 * time.Second | |
cluster.RetryPolicy = gocql.RetryPolicy{NumRetries: 10} | |
s, e := cluster.CreateSession() | |
if e != nil { | |
fmt.Println(e) | |
return | |
} | |
s.Query(`CREATE TABLE IF NOT EXISTS bitmap2 (bitmap_id bigint,block bigint, PRIMARY KEY (bitmap_id) )`).Exec() | |
s.Query(`truncate bitmap2`).Exec() | |
stmt := `INSERT INTO bitmap2 ( bitmap_id, block) VALUES (?,?);` | |
for id := 0; id < 32; id++ { | |
val := int64(0) | |
for i := uint(0); i < 64; i++ { | |
b := int64(1) << i | |
val |= b | |
s.Query(stmt, id, val).Exec() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment