Skip to content

Instantly share code, notes, and snippets.

@sumanentc
Created October 26, 2021 18:06
Show Gist options
  • Save sumanentc/a2b494d103b85a34a7ef7d51c37b1cb1 to your computer and use it in GitHub Desktop.
Save sumanentc/a2b494d103b85a34a7ef7d51c37b1cb1 to your computer and use it in GitHub Desktop.
public List<Player> scanQuerySearch(String text) {
log.info("ScanQuery search to find players with the given field name and text");
IgniteCache<Long, Player> playerCache = Ignition.ignite().getOrCreateCache(PLAYER);
ScanQuery<Long, Player> scanQuery = new ScanQuery<>((k, v) -> v.getTeam().equalsIgnoreCase(text));
List<Player> players = new ArrayList<>();
log.info("Query :: " + scanQuery);
try (QueryCursor<Cache.Entry<Long, Player>> cursor = playerCache.query(scanQuery)) {
Iterator<Cache.Entry<Long, Player>> iterator = cursor.iterator();
while (iterator.hasNext()) {
Cache.Entry<Long, Player> entry = iterator.next();
players.add(entry.getValue());
}
}
return players;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment