Fill - fills the DB using numTx transactions and numKeysPerTx.
(bucket []byte, numTx int, numKeysPerTx int, keyGen func(tx int, key int) []byte, valueGen func(tx int, key int) []byte)
| 168 | |
| 169 | // Fill - fills the DB using numTx transactions and numKeysPerTx. |
| 170 | func (db *DB) Fill(bucket []byte, numTx int, numKeysPerTx int, |
| 171 | keyGen func(tx int, key int) []byte, |
| 172 | valueGen func(tx int, key int) []byte) error { |
| 173 | for tr := 0; tr < numTx; tr++ { |
| 174 | err := db.Update(func(tx *bolt.Tx) error { |
| 175 | b, _ := tx.CreateBucketIfNotExists(bucket) |
| 176 | for i := 0; i < numKeysPerTx; i++ { |
| 177 | if err := b.Put(keyGen(tr, i), valueGen(tr, i)); err != nil { |
| 178 | return err |
| 179 | } |
| 180 | } |
| 181 | return nil |
| 182 | }) |
| 183 | if err != nil { |
| 184 | return err |
| 185 | } |
| 186 | } |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | func (db *DB) Path() string { |
| 191 | return db.f |