Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces major breaking change in the API by removing the existing cursor and changing the way how the columns are accessed during transactions. Since columnar storage is intended to work on ranges of values, this speeds up range queries by around **~20-40%**. In order to access the results of the iteration, prior to calling `Range()` method, we need to **first load column reader(s)** we are going to need, using methods such as `txn.String()`, `txn.Float64()`, etc. These prepare read/write buffers necessary to perform efficient lookups while iterating. In the example below we select all of the rogues from our collection and print out their name by using the `Range()` method and accessing the "name" column using a column reader which is created by calling `txn.String("name")` method. ```go players.Query(func(txn *Txn) error { names := txn.String("name") // Create a column reader return txn.With("rogue").Range(func(i uint32) { name, _ := names.Get() println("rogue name", name) }) }) ``` Similarly, if you need to access more columns, you can simply create the appropriate column reader(s) and use them as shown in the example before. ```go players.Query(func(txn *Txn) error { names := txn.String("name") ages := txn.Int64("age") return txn.With("rogue").Range(func(i uint32) { name, _ := names.Get() age, _ := ages.Get() println("rogue name", name) println("rogue age", age) }) }) ```
- Loading branch information
Showing
25 changed files
with
2,317 additions
and
1,371 deletions.
There are no files selected for viewing
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
Oops, something went wrong.