Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of getObjects() for EntityGroup #117

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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