Copy data from one table to other in Cassandra using Java -
i trying move data 1 column-family (table) other. since both tables have different descriptions, have pull data table-1 , create new object table-2 , bulk aync insert. table-1 has millions of records cannot data directly in data structure , work out. looking out solutions using spring data cassandra java.
i planned moving data temp table first followed creating composite key relations , querying master table. however, doesn't seems favorable me. can suggest strategy this? leads appreciated. thanks!
my table-1 has millions of records cannot data directly in data structure , work out.
with datastax java driver can data token ranges , work out data each token range. example:
set<tokenrange> tokenranges = cassandrasession.getcluster().getmetadata().gettokenranges(); for(tokenrange tr: tokenranges) { list<row> rows = new arraylist<>(); for(tokenrange sub: tr.unwrap()){ string query = "select * keyspace.table token(pk) > ? , token(pk) <= ?"; simplestatement st = new simplestatement( query, sub.getstart(), sub.getend() ); rows.addall( session.execute( st ).all() ); } transformandwritetonewtable(rows); }
each token range contains piece of data , can handled 1 physical machine. can handle each token range independently (in parallel or asynchronously) more performance.
Comments
Post a Comment