Skip to content

Commit 519238d

Browse files
committed
I added the page parameter in both use cases.
1 parent e15ebaa commit 519238d

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

rdbms-reduce/src/main/java/com/rcosnita/experiments/rdbmsreduce/examples/TopDomains.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,20 @@ public void execute(Connection conn) throws SQLException {
8282
}
8383

8484
public static void main(String[] args) {
85-
if(args.length != 2) {
86-
throw new RuntimeException("Invalid usage... Ex: java com.rcosnita.experiments.rdbmsreduce.examples.TopDomains <account_id> <number_of_domains>");
85+
if(args.length < 2) {
86+
throw new RuntimeException("Invalid usage... Ex: java com.rcosnita.experiments.rdbmsreduce.examples.TopDomains <account_id> <number_of_domains> <first_page>");
8787
}
8888

8989
int accountId = Integer.parseInt(args[0]);
9090
int maxDomains = Integer.parseInt(args[1]);
9191

92+
int firstPage = Integer.parseInt(args.length == 3 ? args[2] : "0") * maxDomains;
93+
9294
long startTime = Calendar.getInstance().getTimeInMillis();
9395

9496
List<Integer> provIds = JPABuilder.getProvisioningIds(accountId);
9597

96-
String sql = "SELECT * FROM domains WHERE prov_id IN (%(prov_ids)) ORDER BY name ASC LIMIT 100,%(max_domains)";
98+
String sql = "SELECT * FROM domains WHERE prov_id IN (%(prov_ids)) ORDER BY name ASC LIMIT " + firstPage + ",%(max_domains)";
9799

98100
Reductor reductor = new Reductor(14, SupportedEngines.MySQL);
99101

rdbms-reduce/src/main/java/com/rcosnita/experiments/rdbmsreduce/examples/TopDomainsTld.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,25 @@ public class TopDomainsTld {
2222
private final static Logger logger = Logger.getLogger(TopDomainsTld.class);
2323

2424
public static void main(String[] args) {
25-
if(args.length != 3) {
26-
throw new RuntimeException("Invalid usage... Ex: java com.rcosnita.experiments.rdbmsreduce.examples.TopDomains <account_id> <number_of_domains> <tld>");
25+
if(args.length < 3) {
26+
throw new RuntimeException("Invalid usage... Ex: java com.rcosnita.experiments.rdbmsreduce.examples.TopDomains <account_id> <number_of_domains> <tld> <first_page>");
2727
}
2828

2929
int accountId = Integer.parseInt(args[0]);
3030
int maxDomains = Integer.parseInt(args[1]);
3131
String tld = args[2];
32-
32+
int firstPage = Integer.parseInt(args.length == 4 ? args[3] : "0") * maxDomains;
33+
3334
long startTime = Calendar.getInstance().getTimeInMillis();
3435

3536
List<Integer> provIds = JPABuilder.getProvisioningIds(accountId);
3637

37-
String sql = "SELECT * FROM domains WHERE name LIKE '%%(tld)%' AND prov_id IN (%(prov_ids)) ORDER BY name ASC LIMIT 0,%(max_domains)";
38+
String sql = "SELECT * FROM domains WHERE name LIKE '%%(tld)%' AND prov_id IN (%(prov_ids)) ORDER BY name ASC LIMIT " + firstPage + ",%(max_domains)";
3839

3940
Reductor reductor = new Reductor(14, SupportedEngines.MySQL);
4041

4142
Map<String, Object> sqlValues = new HashMap<String, Object>();
42-
sqlValues.put("tld", ".co.uk");
43+
sqlValues.put("tld", tld);
4344
sqlValues.put("max_domains", maxDomains);
4445
TopDomains topDomains = new TopDomains(reductor, sql, sqlValues, maxDomains, provIds);
4546

0 commit comments

Comments
 (0)