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());
}
}