Mercurial > hg > blitz_stable
view examples/entrysizer/TestSizer.java @ 28:bc579f24eaf5
Added tag Version 2.1 for changeset 511648fa4d64
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Mon, 04 Jan 2010 13:01:11 +0000 |
parents | 3dc0c5604566 |
children |
line wrap: on
line source
package entrysizer; import net.jini.core.entry.Entry; import org.dancres.blitz.mangler.EntrySizer; /** This class demonstrates how to use the Blitz EntrySizer which can be used to give an approximate size for an Entry once it's marshalled and ready for storage in the Blitz backend. This is useful for sizing heap, caches and disk storage (for a persistent or time-barrier-persistent Blitz). */ public class TestSizer { public static void main(String args[]) { try { /* Create an EntrySizer instance (EntrySizer is stateless) */ EntrySizer mySizer = new EntrySizer(); /* Create some example Entry's */ Entry[] myEntrys = new Entry[] {new DummyEntry("a"), new DummyEntry("abcdefgh"), new DummyEntry(null)}; /* For each example, get a size estimate from the Sizer. */ for (int i = 0; i < myEntrys.length; i++) { System.out.println("Size of: " + myEntrys[i] + " = " + mySizer.computeSize(myEntrys[i])); } } catch (Exception anE) { System.err.println("Whoops, didn't work"); anE.printStackTrace(System.err); } } }