Bump our Depot dependency up to 1.2-SNAPSHOT and convert ourselves to the new

type-safeness. Also jump to Narya 1.4-SNAPSHOT as well. Once the type-safe
Depot revamp settles down, we'll push out a release version of Depot, Narya and
Nenya and get back off the snapshot horse.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@1038 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2010-12-15 00:44:24 +00:00
parent cd7280414a
commit 1cb7b7dae5
7 changed files with 43 additions and 48 deletions
+2 -2
View File
@@ -64,7 +64,7 @@
<dependency> <dependency>
<groupId>com.threerings</groupId> <groupId>com.threerings</groupId>
<artifactId>narya</artifactId> <artifactId>narya</artifactId>
<version>1.3-SNAPSHOT</version> <version>1.4-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -90,7 +90,7 @@
<dependency> <dependency>
<groupId>com.samskivert</groupId> <groupId>com.samskivert</groupId>
<artifactId>depot</artifactId> <artifactId>depot</artifactId>
<version>1.0</version> <version>1.2-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
@@ -36,9 +36,9 @@ public class PercentileRecord extends PersistentRecord
{ {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
public static final Class<PercentileRecord> _R = PercentileRecord.class; public static final Class<PercentileRecord> _R = PercentileRecord.class;
public static final ColumnExp GAME_ID = colexp(_R, "gameId"); public static final ColumnExp<Integer> GAME_ID = colexp(_R, "gameId");
public static final ColumnExp GAME_MODE = colexp(_R, "gameMode"); public static final ColumnExp<Integer> GAME_MODE = colexp(_R, "gameMode");
public static final ColumnExp DATA = colexp(_R, "data"); public static final ColumnExp<byte[]> DATA = colexp(_R, "data");
// AUTO-GENERATED: FIELDS END // AUTO-GENERATED: FIELDS END
/** Increment this value to reflect changes to this object's schema. */ /** Increment this value to reflect changes to this object's schema. */
@@ -37,11 +37,11 @@ public class RatingRecord extends PersistentRecord
{ {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
public static final Class<RatingRecord> _R = RatingRecord.class; public static final Class<RatingRecord> _R = RatingRecord.class;
public static final ColumnExp GAME_ID = colexp(_R, "gameId"); public static final ColumnExp<Integer> GAME_ID = colexp(_R, "gameId");
public static final ColumnExp PLAYER_ID = colexp(_R, "playerId"); public static final ColumnExp<Integer> PLAYER_ID = colexp(_R, "playerId");
public static final ColumnExp RATING = colexp(_R, "rating"); public static final ColumnExp<Integer> RATING = colexp(_R, "rating");
public static final ColumnExp EXPERIENCE = colexp(_R, "experience"); public static final ColumnExp<Integer> EXPERIENCE = colexp(_R, "experience");
public static final ColumnExp LAST_UPDATED = colexp(_R, "lastUpdated"); public static final ColumnExp<Timestamp> LAST_UPDATED = colexp(_R, "lastUpdated");
// AUTO-GENERATED: FIELDS END // AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 4; public static final int SCHEMA_VERSION = 4;
@@ -23,7 +23,6 @@ package com.threerings.parlor.rating.server.persist;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -37,14 +36,12 @@ import com.google.inject.Singleton;
import com.samskivert.util.IntMap; import com.samskivert.util.IntMap;
import com.samskivert.util.IntMaps; import com.samskivert.util.IntMaps;
import com.samskivert.depot.DepotRepository; import com.samskivert.depot.DepotRepository;
import com.samskivert.depot.Ops;
import com.samskivert.depot.PersistenceContext; import com.samskivert.depot.PersistenceContext;
import com.samskivert.depot.PersistentRecord; import com.samskivert.depot.PersistentRecord;
import com.samskivert.depot.clause.Limit; import com.samskivert.depot.Query;
import com.samskivert.depot.clause.OrderBy; import com.samskivert.depot.clause.OrderBy;
import com.samskivert.depot.clause.QueryClause;
import com.samskivert.depot.clause.Where;
import com.samskivert.depot.expression.SQLExpression; import com.samskivert.depot.expression.SQLExpression;
import com.threerings.parlor.rating.util.Percentiler; import com.threerings.parlor.rating.util.Percentiler;
@@ -82,9 +79,8 @@ public class RatingRepository extends DepotRepository
if (players.length == 0) { if (players.length == 0) {
return Collections.emptyList(); return Collections.emptyList();
} }
return findAll(RatingRecord.class, return from(RatingRecord.class).where(
new Where(Ops.and(RatingRecord.GAME_ID.eq(gameId), RatingRecord.GAME_ID.eq(gameId), RatingRecord.PLAYER_ID.in(players)).select();
RatingRecord.PLAYER_ID.in(players))));
} }
/** /**
@@ -97,19 +93,18 @@ public class RatingRepository extends DepotRepository
*/ */
public List<RatingRecord> getRatings (int playerId, long since, int count) public List<RatingRecord> getRatings (int playerId, long since, int count)
{ {
ArrayList<QueryClause> clauses = Lists.newArrayList(); Query<RatingRecord> query = from(RatingRecord.class);
if (since > 0L) { if (since > 0L) {
Timestamp when = new Timestamp(System.currentTimeMillis() - since); Timestamp when = new Timestamp(System.currentTimeMillis() - since);
clauses.add(new Where(Ops.and(RatingRecord.PLAYER_ID.eq(playerId), query = query.where(RatingRecord.PLAYER_ID.eq(playerId),
RatingRecord.LAST_UPDATED.greaterThan(when)))); RatingRecord.LAST_UPDATED.greaterThan(when));
} else { } else {
clauses.add(new Where(RatingRecord.PLAYER_ID, playerId)); query = query.where(RatingRecord.PLAYER_ID, playerId);
} }
if (count > 0) { if (count > 0) {
clauses.add(new Limit(0, count)); query = query.limit(count);
} }
clauses.add(OrderBy.descending(RatingRecord.LAST_UPDATED)); return query.descending(RatingRecord.LAST_UPDATED).select();
return findAll(RatingRecord.class, clauses);
} }
/** /**
@@ -124,7 +119,7 @@ public class RatingRepository extends DepotRepository
public List<RatingRecord> getTopRatings ( public List<RatingRecord> getTopRatings (
int gameId, int limit, long since, Set<Integer> playerIds) int gameId, int limit, long since, Set<Integer> playerIds)
{ {
List<SQLExpression> where = Lists.newArrayList(); List<SQLExpression<?>> where = Lists.newArrayList();
where.add(RatingRecord.GAME_ID.eq(gameId)); where.add(RatingRecord.GAME_ID.eq(gameId));
if (since > 0L) { if (since > 0L) {
where.add(RatingRecord.LAST_UPDATED.greaterThan( where.add(RatingRecord.LAST_UPDATED.greaterThan(
@@ -135,9 +130,9 @@ public class RatingRepository extends DepotRepository
} }
OrderBy ob = new OrderBy( OrderBy ob = new OrderBy(
new SQLExpression[] { RatingRecord.RATING, RatingRecord.LAST_UPDATED }, new SQLExpression<?>[] { RatingRecord.RATING, RatingRecord.LAST_UPDATED },
new OrderBy.Order[] { OrderBy.Order.DESC, OrderBy.Order.DESC }); new OrderBy.Order[] { OrderBy.Order.DESC, OrderBy.Order.DESC });
return findAll(RatingRecord.class, new Where(Ops.and(where)), new Limit(0, limit), ob); return from(RatingRecord.class).where(where).limit(limit).orderBy(ob).select();
} }
/** /**
@@ -175,8 +170,8 @@ public class RatingRepository extends DepotRepository
public Map<Integer, Percentiler> loadPercentiles (int gameId) public Map<Integer, Percentiler> loadPercentiles (int gameId)
{ {
Map<Integer, Percentiler> tilers = Maps.newHashMap(); Map<Integer, Percentiler> tilers = Maps.newHashMap();
for (PercentileRecord record : findAll( for (PercentileRecord record : from(PercentileRecord.class).
PercentileRecord.class, new Where(PercentileRecord.GAME_ID, gameId))) { where(PercentileRecord.GAME_ID, gameId).select()) {
tilers.put(record.gameMode, new Percentiler(record.data)); tilers.put(record.gameMode, new Percentiler(record.data));
} }
return tilers; return tilers;
@@ -207,8 +202,8 @@ public class RatingRepository extends DepotRepository
*/ */
public void purgeGame (int gameId) public void purgeGame (int gameId)
{ {
deleteAll(RatingRecord.class, new Where(RatingRecord.GAME_ID, gameId), null); from(RatingRecord.class).where(RatingRecord.GAME_ID, gameId).delete(null);
deleteAll(PercentileRecord.class, new Where(PercentileRecord.GAME_ID, gameId), null); from(PercentileRecord.class).where(PercentileRecord.GAME_ID, gameId).delete(null);
} }
/** /**
@@ -216,7 +211,7 @@ public class RatingRepository extends DepotRepository
*/ */
public void purgePlayers (Collection<Integer> playerIds) public void purgePlayers (Collection<Integer> playerIds)
{ {
deleteAll(RatingRecord.class, new Where(RatingRecord.PLAYER_ID.in(playerIds)), null); from(RatingRecord.class).where(RatingRecord.PLAYER_ID.in(playerIds)).delete(null);
} }
/** /**
@@ -249,7 +244,7 @@ public class RatingRepository extends DepotRepository
// Without distinct, I must load all ratings and throw out all but the first. They're not // Without distinct, I must load all ratings and throw out all but the first. They're not
// that big, but still. // that big, but still.
List<SQLExpression> conditions = Lists.newArrayList(); List<SQLExpression<?>> conditions = Lists.newArrayList();
conditions.add(RatingRecord.PLAYER_ID.in(playerIds)); conditions.add(RatingRecord.PLAYER_ID.in(playerIds));
if (gameIds != null) { if (gameIds != null) {
conditions.add(RatingRecord.GAME_ID.in(gameIds)); conditions.add(RatingRecord.GAME_ID.in(gameIds));
@@ -259,8 +254,8 @@ public class RatingRepository extends DepotRepository
RatingRecord.GAME_ID.lessThan(0) : RatingRecord.GAME_ID.greaterThan(0)); RatingRecord.GAME_ID.lessThan(0) : RatingRecord.GAME_ID.greaterThan(0));
} }
IntMap<RatingRecord> ratings = IntMaps.newHashIntMap(); IntMap<RatingRecord> ratings = IntMaps.newHashIntMap();
for (RatingRecord record : findAll(RatingRecord.class, new Where(Ops.and(conditions)), for (RatingRecord record : from(RatingRecord.class).where(conditions).
OrderBy.descending(RatingRecord.LAST_UPDATED))) { descending(RatingRecord.LAST_UPDATED).select()) {
if (ratings.containsKey(record.playerId)) { if (ratings.containsKey(record.playerId)) {
continue; continue;
} }
@@ -32,7 +32,7 @@ public class MaxStatCodeRecord extends PersistentRecord {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
public static final Class<MaxStatCodeRecord> _R = MaxStatCodeRecord.class; public static final Class<MaxStatCodeRecord> _R = MaxStatCodeRecord.class;
public static final ColumnExp MAX_CODE = colexp(_R, "maxCode"); public static final ColumnExp<Integer> MAX_CODE = colexp(_R, "maxCode");
// AUTO-GENERATED: FIELDS END // AUTO-GENERATED: FIELDS END
@Column @Column
@@ -33,10 +33,10 @@ public class StatRecord extends PersistentRecord
{ {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
public static final Class<StatRecord> _R = StatRecord.class; public static final Class<StatRecord> _R = StatRecord.class;
public static final ColumnExp PLAYER_ID = colexp(_R, "playerId"); public static final ColumnExp<Integer> PLAYER_ID = colexp(_R, "playerId");
public static final ColumnExp STAT_CODE = colexp(_R, "statCode"); public static final ColumnExp<Integer> STAT_CODE = colexp(_R, "statCode");
public static final ColumnExp STAT_DATA = colexp(_R, "statData"); public static final ColumnExp<byte[]> STAT_DATA = colexp(_R, "statData");
public static final ColumnExp MOD_COUNT = colexp(_R, "modCount"); public static final ColumnExp<Byte> MOD_COUNT = colexp(_R, "modCount");
// AUTO-GENERATED: FIELDS END // AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 4; public static final int SCHEMA_VERSION = 4;
@@ -37,23 +37,23 @@ public class StringCodeRecord extends PersistentRecord
{ {
// AUTO-GENERATED: FIELDS START // AUTO-GENERATED: FIELDS START
public static final Class<StringCodeRecord> _R = StringCodeRecord.class; public static final Class<StringCodeRecord> _R = StringCodeRecord.class;
public static final ColumnExp STAT_CODE = colexp(_R, "statCode"); public static final ColumnExp<Integer> STAT_CODE = colexp(_R, "statCode");
public static final ColumnExp VALUE = colexp(_R, "value"); public static final ColumnExp<String> VALUE = colexp(_R, "value");
public static final ColumnExp CODE = colexp(_R, "code"); public static final ColumnExp<Integer> CODE = colexp(_R, "code");
// AUTO-GENERATED: FIELDS END // AUTO-GENERATED: FIELDS END
public static final int SCHEMA_VERSION = 2; public static final int SCHEMA_VERSION = 2;
/** Defines the statCodeValue unique index. */ /** Defines the statCodeValue unique index. */
public static ColumnExp[] statCodeValue () public static ColumnExp<?>[] statCodeValue ()
{ {
return new ColumnExp[] { STAT_CODE, VALUE }; return new ColumnExp<?>[] { STAT_CODE, VALUE };
} }
/** Defines the statCodeCode unique index. */ /** Defines the statCodeCode unique index. */
public static ColumnExp[] statCodeCode () public static ColumnExp<?>[] statCodeCode ()
{ {
return new ColumnExp[] { STAT_CODE, CODE }; return new ColumnExp<?>[] { STAT_CODE, CODE };
} }
/** The code of the stat. */ /** The code of the stat. */