Paging, and MapScan or SliceMap

417 views
Skip to first unread message

herbert...@crossengage.io

unread,
Oct 31, 2016, 12:27:17 PM10/31/16
to gocql
Hi,

I'm doing a small utility that needs to go through all rows of one Cassandra table, without knowing previously the schema of such table.

For that it looks like MapScan or SliceMap were what I needed, but:

1) MapScan works, but only returns the first row, even if PageSize has, let's say, 1000 rows.
2) I don't get how to use SliceMap with Iter and pages.

Do you guys have made something like this before in gocql?

best,

Herbert

Dan Kinder

unread,
Oct 31, 2016, 12:41:59 PM10/31/16
to herbert...@crossengage.io, gocql
Hi Herbert,

I'm not quite sure what you mean about MapScan returning only the first row, here is how we have used it to select many rows:

    values = map[string]interface{}{}                                                                                       
    iter = db.Query("SELECT * FROM my_table").Iter()                                                  
    for iter.MapScan(values) {                                                                                               
        doStuff(values)                                                                                
        values = map[string]interface{}{}                                                                                   
    }                                                                                                                       
    err = iter.Close()


--
You received this message because you are subscribed to the Google Groups "gocql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gocql+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dan Kinder
Principal Software Engineer
Turnitin – www.turnitin.com
dki...@turnitin.com

Herbert Fischer

unread,
Oct 31, 2016, 1:13:14 PM10/31/16
to Dan Kinder, gocql
Hi,

Thanks for the example. The last line was crucial to understand why MapScan was returning only one row.

2016/10/31 18:04:02 can not unmarshal X uuid into gocql.UUID

Now it's another issue I'll have to go through.

On 31 October 2016 at 17:41, Dan Kinder <dki...@turnitin.com> wrote:
Hi Herbert,

I'm not quite sure what you mean about MapScan returning only the first row, here is how we have used it to select many rows:

    values = map[string]interface{}{}                                                                                       
    iter = db.Query("SELECT * FROM my_table").Iter()                                                  
    for iter.MapScan(values) {                                                                                               
        doStuff(values)                                                                                
        values = map[string]interface{}{}                                                                                   
    }                                                                                                                       
    err = iter.Close()

On Mon, Oct 31, 2016 at 9:27 AM, <herbert.fischer@crossengage.io> wrote:
Hi,

I'm doing a small utility that needs to go through all rows of one Cassandra table, without knowing previously the schema of such table.

For that it looks like MapScan or SliceMap were what I needed, but:

1) MapScan works, but only returns the first row, even if PageSize has, let's say, 1000 rows.
2) I don't get how to use SliceMap with Iter and pages.

Do you guys have made something like this before in gocql?

best,

Herbert

--
You received this message because you are subscribed to the Google Groups "gocql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gocql+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dan Kinder
Principal Software Engineer
Turnitin – www.turnitin.com
dki...@turnitin.com



--
Herbert Fischer | Senior IT Architect
CrossEngage GmbH Gontardstraße 11 | 10178 Berlin

E-Mail: herbert...@crossengage.io

Amtsgericht Berlin-Charlottenburg | HRB 169537 B
Geschäftsführer: Dr. Markus Wübben, Manuel Hinz | USt-IdNr.: DE301504202
Reply all
Reply to author
Forward
0 new messages