Skip to content

Commit

Permalink
Merge pull request #117 from k-r-g/methodValueCache_getObjects_optimi…
Browse files Browse the repository at this point in the history
…zation

Improve performance of getObjects() for EntityGroup
  • Loading branch information
msmith-techempower authored Jul 19, 2022
2 parents 97e94fb + 77d7e0c commit 5afdeb8
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions gemini/src/main/java/com/techempower/cache/MethodValueCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

package com.techempower.cache;

import gnu.trove.iterator.*;
import gnu.trove.map.*;
import gnu.trove.map.hash.*;
import gnu.trove.set.*;
Expand Down Expand Up @@ -211,16 +210,10 @@ public List<T> getObjects(String methodName, Object value)
{
return new ArrayList<>(0);
}

List<T> values = new ArrayList<>();

for (TLongIterator iterator = ids.iterator(); iterator.hasNext();)
{
long id = iterator.next();
values.add(this.cache.get(this.type, id));
}

return values;

// Provide the list of desired IDs to map() so that, if this is an EntityGroup, we can
// efficiently build all of them from a single query.
return new ArrayList<>(this.cache.map(this.type, ids.toArray()).valueCollection());
}
}
finally
Expand Down

0 comments on commit 5afdeb8

Please sign in to comment.