|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.depot.DepotRepository
com.threerings.stats.server.persist.StatRepository
public class StatRepository
Responsible for the persistent storage of per-player statistics.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.samskivert.depot.DepotRepository |
|---|
com.samskivert.depot.DepotRepository.CacheStrategy |
| Field Summary | |
|---|---|
protected Map<Stat.Type,IntMap<String>> |
_codeToString
|
protected Map<Stat.Type,Map<String,Integer>> |
_stringToCode
|
protected static int |
MAX_UPDATE_TRIES
|
| Fields inherited from class com.samskivert.depot.DepotRepository |
|---|
_ctx, _dataMigs |
| Constructor Summary | |
|---|---|
StatRepository(com.samskivert.depot.PersistenceContext context)
Constructs a new statistics repository with the specified persistence context. |
|
| Method Summary | ||
|---|---|---|
protected Integer |
assignStringCode(Stat.Type type,
String value)
Helper function for getStringCode(com.threerings.stats.data.Stat.Type, java.lang.String). |
|
void |
clearMapping(Stat.Type type,
String value)
This is only used for testing. |
|
protected Stat |
decodeStat(int statCode,
byte[] data,
byte modCount)
Instantiates the appropriate stat class and decodes the stat from the data. |
|
protected Stat |
decodeStat(Stat stat,
byte[] data,
byte modCount)
Instantiates the appropriate stat class and decodes the stat from the data. |
|
void |
deleteStats(int playerId)
Deletes all stats associated with the specified player. |
|
String |
getCodeString(Stat.Type type,
int code)
Maps the specified unique code back to its string value. |
|
protected void |
getManagedRecords(Set<Class<? extends com.samskivert.depot.PersistentRecord>> classes)
|
|
int |
getStringCode(Stat.Type type,
String value)
Maps the specified string to a unique integer value. |
|
protected void |
init()
|
|
ArrayList<Stat> |
loadStats(int playerId)
Loads the stats associated with the specified player. |
|
protected void |
loadStringCodes(Stat.Type type)
Helper function used at repository startup. |
|
protected void |
mapStringCode(Stat.Type type,
String value,
int code)
Helper function used at repository startup. |
|
void |
purgePlayers(Collection<Integer> playerIds)
Deletes all data associated with the supplied players. |
|
protected boolean |
updateStat(int playerId,
Stat stat,
boolean forceWrite)
Updates the specified stat in the database, inserting it if necessary. |
|
|
updateStat(int playerId,
StatModifier<T> modifier)
Applies a modification to a single stat. |
|
void |
writeModified(int playerId,
Iterable<Stat> stats)
Writes out any of the stats in the supplied iterable that have been modified since they were first loaded. |
|
void |
writeModified(int playerId,
Stat[] stats)
Writes out any of the stats in the supplied array that have been modified since they were first loaded. |
|
| Methods inherited from class com.samskivert.depot.DepotRepository |
|---|
delete, delete, deleteAll, deleteAll, deleteAll, deleteAll, doUpdate, findAll, findAll, findAll, findAll, findAllKeys, findAllKeys, from, insert, load, load, load, load, loadAll, loadAll, makeValue, map, registerMigration, requireNotComputed, resolveRecords, runMigration, store, update, update, updatePartial, updatePartial, updatePartial, updatePartial, updatePartial |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<Stat.Type,Map<String,Integer>> _stringToCode
protected Map<Stat.Type,IntMap<String>> _codeToString
protected static final int MAX_UPDATE_TRIES
| Constructor Detail |
|---|
@Inject public StatRepository(com.samskivert.depot.PersistenceContext context)
| Method Detail |
|---|
public <T extends Stat> T updateStat(int playerId,
StatModifier<T> modifier)
Stat.Type.newStat().
public ArrayList<Stat> loadStats(int playerId)
public void deleteStats(int playerId)
public void writeModified(int playerId,
Stat[] stats)
public void writeModified(int playerId,
Iterable<Stat> stats)
public int getStringCode(Stat.Type type,
String value)
Stat.AuxDataSource
getStringCode in interface Stat.AuxDataSource
public String getCodeString(Stat.Type type,
int code)
Stat.AuxDataSource
getCodeString in interface Stat.AuxDataSource
public void clearMapping(Stat.Type type,
String value)
public void purgePlayers(Collection<Integer> playerIds)
protected Stat decodeStat(int statCode,
byte[] data,
byte modCount)
protected Stat decodeStat(Stat stat,
byte[] data,
byte modCount)
protected boolean updateStat(int playerId,
Stat stat,
boolean forceWrite)
protected Integer assignStringCode(Stat.Type type,
String value)
getStringCode(com.threerings.stats.data.Stat.Type, java.lang.String).
protected void loadStringCodes(Stat.Type type)
protected void mapStringCode(Stat.Type type,
String value,
int code)
protected void init()
init in class com.samskivert.depot.DepotRepositoryprotected void getManagedRecords(Set<Class<? extends com.samskivert.depot.PersistentRecord>> classes)
getManagedRecords in class com.samskivert.depot.DepotRepository
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||