Skip to content

Commit

Permalink
added partition-hash logic for spreading the point reads evenly (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Amit Chauhan <[email protected]>
  • Loading branch information
akscjo and Amit Chauhan authored Jun 2, 2023
1 parent 72b3e33 commit dea1dc3
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.yugabyte.simulation.services.ServiceManager;
import com.yugabyte.simulation.workload.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
Expand Down Expand Up @@ -198,11 +199,25 @@ private void seedData(int numberToGenerate, int threads) {
private List<UUID> getQueryList() {
List<UUID> results = new ArrayList<UUID>(ROWS_TO_PRELOAD);
CqlSession session = this.getCassandraClient();
PreparedStatement ps = session.prepare("select pkid from workload_demo.c_generic1 limit "+ROWS_TO_PRELOAD+";");
ResultSet rs = session.execute(ps.bind());
for(Row row : rs){
results.add(row.getUuid("pkid"));
int numOfRanges = 64;
int limit = ROWS_TO_PRELOAD/numOfRanges;
int runningHashCodeVal = 0;

while(runningHashCodeVal < 65536){
int nextHashVal = runningHashCodeVal + 1024;
String query = " SELECT pkid FROM workload_demo.c_generic1 where partition_hash(pkid) >= "+runningHashCodeVal+" and partition_hash(pkid) < "+(nextHashVal-1)+" LIMIT "+limit+" ";
System.out.println("query:"+query);
ResultSet rs = session.execute(query.toString());
for(Row row : rs){
results.add(row.getUuid("pkid"));
}
runningHashCodeVal = nextHashVal;
}
// System.out.println("list of pkids:"+results.size());
// for(UUID pkId: results){
// System.out.print(pkId.toString()+",");
// }

return results;
}

Expand Down

0 comments on commit dea1dc3

Please sign in to comment.