Skip to content


Added RangeGet to query #1

wants to merge 1 commit into from

2 participants


Hi carloscm,

To be able to read a complete CF, I have forked your project gossie and added RangeGet to the query interface and implementation.
I was hoping you could add this to your branch again, so others can benefit the feature.
It consists of one commit and one file that changed.


Geert-Johan added RangeGet mehod to Query. the method accepts a gossie.Range and …
…a boolean to indicate if the startkey(given in range) should be excluded from the result.

Cassandra provides no such method, and the way you are using RangeGet is the correct one for a RP cluster. The Cassandra Thrift API is not designed for streaming-like methods and doesn't provide them. The usual way to do full-table processing in Cassandra is to setup a Hadoop cluster parallel to your Cassandra cluster. Cassandra provides specific Hadoop APIs for this. That's usually much more efficient than using RangeGet via Thrift. In production I only use RangeGet for very small tables, everything else is indexed in some way and there is no need to scan a full table.

As for your channel proposal I would like to not implement it for now. I usually shy away from channels in Gossie since Go already provides excellent multiplexed goroutine execution based on I/O waits. Gossie just by virtue of using (via the Thrift libs) Go sockets is already concurrent and asynchronous if you launch multiple goroutines to talk to it (it's designed to work like this, including sharing the Pool objects). If an application wants to add another layer on top of it using channels (for idiomatic purposes like you mention, or for doing parallel I/O waits with both Gossie and other sources of I/O at the same time) they can do it very easily in their side.

Nice to see your interest in Gossie, keep up the good work!


I guess this can be closed :)

@GeertJohan GeertJohan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 31, 2012
  1. added RangeGet mehod to Query. the method accepts a gossie.Range and …

    Geert-Johan committed
    …a boolean to indicate if the startkey(given in range) should be excluded from the result.
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/gossie/query.go
30 src/gossie/query.go
@@ -50,6 +50,9 @@ type Query interface {
// MultiGet looks up multiple rows given the keys.
MultiGet(keys []interface{}) (Result, error)
+ // RangeGet looks up a range of rows as specified by the parameter Range type
+ RangeGet(rang *Range, excludeStart bool) (Result, error)
// Result reads Query results into Go objects, internally buffering them.
@@ -155,6 +158,33 @@ func (q *query) MultiGet(keys []interface{}) (Result, error) {
return &result{query: *q, buffer: rows}, nil
+func (q *query) RangeGet(rang *Range, excludeStart bool) (Result, error) {
+ var err error
+ reader := q.pool.Reader().Cf(q.mapping.Cf())
+ if q.consistencyLevel != 0 {
+ reader.ConsistencyLevel(q.consistencyLevel)
+ }
+ q.buildSlice(reader)
+ if excludeStart && len(rang.Start) > 0 {
+ rang.Count += 1
+ }
+ rows, err := reader.RangeGet(rang)
+ if err != nil {
+ return nil, err
+ }
+ if excludeStart && len(rang.Start) > 0 {
+ rows = rows[1:]
+ }
+ return &result{query: *q, buffer: rows}, nil
func (q *query) buildSlice(reader Reader) error {
start := make([]byte, 0)
end := make([]byte, 0)
Something went wrong with that request. Please try again.