Skip to content

Instantly share code, notes, and snippets.

@DocSavage
Last active October 23, 2015 15:53
Show Gist options
  • Save DocSavage/6158a39dc2e1db76baa1 to your computer and use it in GitHub Desktop.
Save DocSavage/6158a39dc2e1db76baa1 to your computer and use it in GitHub Desktop.
BigTable GetRange
tbl := client.Open("mytable")
...
unvKeyBeg, _, _ := ctx.UnversionedKey(tkBeg)
unvKeyEnd, _, _ := ctx.UnversionedKey(tkEnd)
rr := bigtable.NewRange(unvKeyBeg, unvKeyEnd)
err := tbl.ReadRows(bt_ctx, rr, func(r Row) bool {
// get all versions from this row and package into "versions" which is []*storage.KeyValue
...
// run it through our DAG to get the proper value given our version context.
// See the code: https://github.com/janelia-flyem/dvid/blob/master/datastore/datainstance.go#L71
kv, err := ctx.VersionedKeyValue(versions)
return true // keep going
}, bigtable.RowFilter(bigtable.FamilyFilter("versions"))) // No filter necessary if we only have one column family
...
@DocSavage
Copy link
Author

We could potentially refine ctx.VersionedKeyValue(versions) to accept a slice of struct that contains a versionID and value. If the column qualifiers are versionIDs, we don't need to decompose the full keys to get the versionID out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment