Re: [freenet-dev] [freenet-cvs] r19857 - branches/saltedhash…

Top Page
Delete this message
Reply to this message
Author: Daniel Cheng
Date:  
To: Discussion of development issues
Subject: Re: [freenet-dev] [freenet-cvs] r19857 - branches/saltedhashstore/freenet/src/freenet/store
On Sat, May 10, 2008 at 6:39 AM, Matthew Toseland
<toad@???> wrote:
> On Friday 09 May 2008 03:09, j16sdiz@??? wrote:
>>
>> /**
>> - * Sample to take at a time
>> + * Scan all entries and try to move them
>> */
>> - private static final double SAMPLE_RATE = 0.05; // 5%
>> + private void moveOldEntry0(boolean queueItem) {
>> + newEntries = 0;
>> + oldEntries = 0;
>> + freeEntries = 0;
>> + resolvedEntries = 0;
>> + droppedEntries = 0;
>>
>> + List oldItems = null;
>> + if (queueItem) {
>> + oldItems = new ArrayList();
>> + }
>> +
>> + long maxOffset = maxOldItemOffset;
>> + maxOldItemOffset = 0;
>> + for (long offset = 0; offset <= maxOffset; offset++) {
>> + if (logDEBUG && offset % 1024 == 0) {
>> + Logger.debug(this, "Resize progress: newEntries=" + newEntries + ",
> oldEntries=" + oldEntries
>> + + ", freeEntries=" + freeEntries + ", resolvedEntries=" +
> resolvedEntries
>> + + ", droppedEntries=" + droppedEntries);
>> + }
>> +
>> + if (shutdown)
>> + return;
>> +
>> + if (!lockEntry(offset)) //lock
>> + continue;
>> + try {
>> + Entry entry = readEntry(offset, null);

[....]
>> + } else { // if (entry.getStoreSize() == prevStoreSize)
>> + // old store size entries, try to move them
>> + oldEntries++;
>> + maxOldItemOffset = offset;
>> +
>> + entry.setStoreSize(storeSize);
>> + long newOffset = entry.getOffset();

[....]
>> + } else if (queueItem) {
>> + // break tie by moveing old item to queue
>> + if (oldItems.size() * entryTotalLength < RESIZE_MEMORY) {
>> + oldItems.add(newOffsetEntry);
>> + if (newOffset > offset) {
>> + oldEntries++; // newOffset wasn't counted count it
>> + }
>> +
>> + writeEntry(entry);
>> + freeOffset(offset);
>> + resolvedEntries++;
>
> Where are we writing it to here? It looks like we write it to the old
> location, and then delete it?
>


"entry" need to migrate to newOffset, but newOffset is already
occupied by "newOffsetEntry", which also need migration. If
"queueItem" is true, we put "newOffsetEntry" to a queue and write
"entry" to "newOffset"