From 8f12cff519b3e629fbfdcfd5202dd74f025a237d Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Wed, 16 Jul 2008 20:27:17 +0000 Subject: [PATCH] per mdb, IntSetStat will store a maximum of 255 entries git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@659 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/java/com/threerings/stats/data/IntSetStat.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/stats/data/IntSetStat.java b/src/java/com/threerings/stats/data/IntSetStat.java index 808db5e9..dd2b3f61 100644 --- a/src/java/com/threerings/stats/data/IntSetStat.java +++ b/src/java/com/threerings/stats/data/IntSetStat.java @@ -13,19 +13,21 @@ import com.threerings.io.ObjectOutputStream; public class IntSetStat extends Stat { /** - * Constructs a new IntSetStat that will store up to Integer.MAX_VALUE ints. + * Constructs a new IntSetStat that will store up to 255 ints. */ public IntSetStat () { - _maxSize = Integer.MAX_VALUE; + _maxSize = MAX_MAX_SIZE; } /** * Constructs a new IntSetStat that will store up to maxSize ints. + * + * @param the maximum number of ints to store in the IntSetStat. Must be <= 255. */ public IntSetStat (int maxSize) { - _maxSize = maxSize; + _maxSize = Math.min(maxSize, MAX_MAX_SIZE); } /** @@ -58,7 +60,7 @@ public class IntSetStat extends Stat public void persistTo (ObjectOutputStream out, AuxDataSource aux) throws IOException { - out.writeInt(_maxSize); + out.writeByte(_maxSize - 128); out.writeInt(_intSet.size()); for (int key : _intSet) { out.writeInt(key); @@ -69,7 +71,7 @@ public class IntSetStat extends Stat public void unpersistFrom (ObjectInputStream in, AuxDataSource aux) throws IOException, ClassNotFoundException { - _maxSize = in.readInt(); + _maxSize = in.readByte() + 128; int numValues = in.readInt(); _intSet = new HashSet(numValues); for (int ii = 0; ii < numValues; ii++) { @@ -87,4 +89,6 @@ public class IntSetStat extends Stat protected int _maxSize; protected HashSet _intSet = new HashSet(); + protected static final int MAX_MAX_SIZE = 255; + }