Last active
May 22, 2016 20:04
-
-
Save JensRantil/822fccc1eba9cd74907b4855e1f77513 to your computer and use it in GitHub Desktop.
Create an observable that fetches smaller batches of users based on prefix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserLister { | |
... | |
public Observable<User> streamAll(int batchSize) { | |
final int prefixLength = estimatePrefixLength(batchSize); | |
Preconditions.checkState(prefixLength > 0); | |
log.debug("Estimated prefix length: " + prefixLength); | |
return Observable.from(RepositoryUtils.hexPrefixes(prefixLength)).flatMapIterable(new Function1<String, List<User>>() { | |
public List<User> call(String prefix) { | |
repository.listByIdPrefix(useridPrefix); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment