GetListKeys Gets all the keys in the database
()
| 270 | |
| 271 | // GetListKeys Gets all the keys in the database |
| 272 | func (db *DB) GetListKeys() [][]byte { |
| 273 | // Retrieve an iterator for the index |
| 274 | iterator := db.index.Iterator(false) |
| 275 | |
| 276 | // Create a slice to store the keys |
| 277 | keys := make([][]byte, db.index.Size()) |
| 278 | |
| 279 | var idx int |
| 280 | // Iterate over the index |
| 281 | for iterator.Rewind(); iterator.Valid(); iterator.Next() { |
| 282 | // Retrieve the key from the current iterator position |
| 283 | keys[idx] = iterator.Key() |
| 284 | idx++ |
| 285 | } |
| 286 | |
| 287 | // Return the list of keys |
| 288 | return keys |
| 289 | } |
| 290 | |
| 291 | // Fold get all the data and perform the operation specified by the user. |
| 292 | // The function returns false to exit |