jive快取

maer2003發表於2004-07-15
jive中的物件大小是怎麼確定的?如DbForum物件的getSize()方法,
是不是按資料庫中對應表的欄位型別位元組數累加,這裡不大懂,誰可以幫我解釋一下嗎?

 public int getSize() {
        // Approximate the size of the object in bytes by calculating the size
        // of each field.
        int size = 0;
        size += CacheSizes.sizeOfObject();              // overhead of object
        size += CacheSizes.sizeOfObject();              // factory
        size += CacheSizes.sizeOfLong();                // id
        size += CacheSizes.sizeOfString(name);          // name
        size += CacheSizes.sizeOfString(description);   // description
        size += CacheSizes.sizeOfDate();                // creation date
        size += CacheSizes.sizeOfDate();                // modified date
        size += CacheSizes.sizeOfMap(properties);       // properties
        size += threadListCache.getMaxSize();           // thread list cache
        size += messageListCache.getMaxSize();          // message list cache
        size += threadCountCache.getMaxSize();          // thread count cache
        size += messageCountCache.getMaxSize();         // message count cache
        size += CacheSizes.sizeOfObject() +
                CacheSizes.sizeOfLong() * 5;            // approx of pop threads
        size += CacheSizes.sizeOfInt() * 4;             // moderation values
        size += CacheSizes.sizeOfObject();              // filter manager
        System.out.println("The Forum's Size is(Form DbForum):"+size);
        return size;
    }
<p class="indent">

相關文章