we have 1 cf has 1000 rows. there way astyanax read 1000 rows? thrift support that?
thanks, dean
you can read rows thrift call get_range_slices. note returns rows in token order, not key order. it's fine read rows not ranges across row keys.
you can use in astyanax getallrows(). here sample code (copied docs @ https://github.com/netflix/astyanax/wiki/reading-data#iterate-all-rows-in-a-column-family)
rows<string, string>> rows; try { rows = keyspace.preparequery("columnfamilyname") .getallrows() .setblocksize(10) .withcolumnrange(new rangebuilder().setmaxsize(10).build()) .setexceptioncallback(new exceptioncallback() { @override public boolean onexception(connectionexception e) { try { thread.sleep(1000); } catch (interruptedexception e1) { } return true; }}) .execute().getresult(); } catch (connectionexception e) { } // never throw exception (row<string, string> row : rows.getresult()) { log.info("row: " + row.getkey() + " " + row.getcolumns().size()); }
this return first 10 columns of each row, in batches of 10 rows. increase number passed rangebuilder().setmaxsize more (or fewer) columns.
Comments
Post a Comment