clintropolis commented on a change in pull request #11369:
URL: https://github.com/apache/druid/pull/11369#discussion_r690710111
##########
File path:
extensions-contrib/redis-cache/src/main/java/org/apache/druid/client/cache/AbstractRedisCache.java
##########
@@ -93,21 +91,12 @@ public void put(NamedKey key, byte[] value)
public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys)
{
totalRequestCount.incrementAndGet();
- Map<NamedKey, byte[]> results = new HashMap<>();
-
try {
- List<NamedKey> namedKeys = Lists.newArrayList(keys);
- List<byte[]> byteKeys = Lists.transform(namedKeys,
NamedKey::toByteArray);
-
- List<byte[]> byteValues = this.mgetFromRedis(byteKeys.toArray(new
byte[0][]));
- for (int i = 0; i < byteValues.size(); ++i) {
- if (byteValues.get(i) != null) {
- results.put(namedKeys.get(i), byteValues.get(i));
- }
- }
+ Map<NamedKey, byte[]> results = this.mgetFromRedis(keys);
hitCount.addAndGet(results.size());
- missCount.addAndGet(namedKeys.size() - results.size());
+ missCount.addAndGet(Stream.of(keys).count() - results.size());
Review comment:
nit: it seems like we could potentially precompute the number of keys in
`mgetFromRedis` when it iterates them, returning some composite type that
contains the count instead of returning `Map<NamedKey, byte[]>` directly.
Not sure if there are enough keys to make this worth doing or not
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]