|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.musicontroller.core.EventCountLookup
public class EventCountLookup
A class for quick eventcount lookup. Songs can have any number of Events. Counting Events, which happens a lot in MusiController, is relatively slow. Events are lazily loaded by Hibernate, thus a call to getEvents() causes an additional DB-access. Caching Events would be a solution, but is not very realistic, because of the sheer amount of them. Since we're mostly interested in counts, this class helps us.
The EventCountLookup takes up only 8 integers and a Date of memory per Song and User. Therefore, caching makes sense for this object. This class contains a LRU-list, to which all lookup-tables are added.
| Field Summary | |
|---|---|
protected static int |
CACHESIZE
|
| Method Summary | |
|---|---|
void |
addEvent(Event event)
Updates this EventCountLookup object with a new Event. |
static EventCountLookup |
create(java.util.Set<Event> events,
long songid)
Factory method, which returns an EventCountLookup object. |
int |
getEventCount(long userid,
int kind)
Returns the amount of Events of a certain type. |
int |
getEventCountLastYear(long userid,
int kind)
Returns the amount of Events of a certain type, which took place in the last year. |
java.util.Date |
getLastPlay(long userid)
Looks up the Date of the latest Play-Event. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int CACHESIZE
| Method Detail |
|---|
public static EventCountLookup create(java.util.Set<Event> events,
long songid)
events - The Set of Events, for the Song. (Only accessed when a new
EventCountLookup-object must be created. When a cached
object is found, the Events are not touched, so that they
can stay uninitialized when they were lazily loaded.)songid - The id of the Song.
public void addEvent(Event event)
event - The new Event.
public int getEventCount(long userid,
int kind)
userid - The user to look these Events up for.kind - The type of Events to look the count up for.
public int getEventCountLastYear(long userid,
int kind)
userid - The user to look these Events up for.kind - The type of Events to look the count up for.
public java.util.Date getLastPlay(long userid)
userid - The user to look this Date up for.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||