Jedis conn, long[] userIds)
{
Map<String,Long> countries = new HashMap<String,Long>();
Map<String,Map<String,Long>> states = new HashMap<String,Map<String,Long>>();
Pipeline pipe = conn.pipelined();
for (int i = 0; i < userIds.length; i++) {
long userId = userIds[i];
long shardId = userId / USERS_PER_SHARD;
int position = (int)(userId % USERS_PER_SHARD);
int offset = position * 2;
pipe.substr("location:" + shardId, offset, offset + 1);
if ((i + 1) % 1000 == 0) {
updateAggregates(countries, states, pipe.syncAndReturnAll());
}
}
updateAggregates(countries, states, pipe.syncAndReturnAll());
return new Pair<Map<String,Long>,Map<String,Map<String,Long>>>(countries, states);
}