From: <tho...@us...> - 2011-02-08 14:57:39
|
Revision: 4182 http://bigdata.svn.sourceforge.net/bigdata/?rev=4182&view=rev Author: thompsonbry Date: 2011-02-08 14:57:32 +0000 (Tue, 08 Feb 2011) Log Message: ----------- BT/MC lint dialog Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/AllocationContext.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/IMemoryManager.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/ISectorManager.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManager.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/SectorAllocator.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/rwstore/sector/TestMemoryManager.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManagerResourceError.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/AllocationContext.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/AllocationContext.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/AllocationContext.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -28,40 +28,49 @@ import java.util.HashSet; /** - * The AllocationContext is used to maintain a handle on allocations made - * within some specific environment (context). + * The {@link AllocationContext} is used to maintain a handle on allocations + * made within some specific environment (context). * * In this way, clearing a context will return all allocations to the more * general pool. * - * There are two obvious implementaiton strategies: - * 1) Retaining set of addresses allocated - * 2) Retaining a copy of the allocated bits + * There are two obvious implementation strategies: + * <ol> + * <li>Retaining set of addresses allocated</li> + * <li>Retaining a copy of the allocated bits</li> + * </ol> * - * If it was not for the BLOB implementations which require length - * data to manage the freeing of an allocation, it would be efficient to - * maintain copies of the allocation bits. This remoains an option for the - * future but requires a relatively complex callback protocol. + * If it was not for the BLOB implementations which require length data to + * manage the freeing of an allocation, it would be efficient to maintain copies + * of the allocation bits. This remains an option for the future but requires a + * relatively complex callback protocol. * * For this reason, the initial implementation maintains a set of allocated * addresses. * * @author Martyn Cutcher - * */ public class AllocationContext implements IMemoryManager { - final IMemoryManager m_parent; + private final IMemoryManager m_parent; - SectorAllocation m_head = null; + private HashSet<Long> m_addresses = new HashSet<Long>(); - HashSet<Long> m_addresses = new HashSet<Long>(); - - public AllocationContext(IMemoryManager parent) { + public AllocationContext(final IMemoryManager parent) { + + if(parent == null) + throw new IllegalArgumentException(); + m_parent = parent; + } + synchronized public long allocate(final ByteBuffer data) { + + if (data == null) + throw new IllegalArgumentException(); + final long addr = m_parent.allocate(data); // getSectorAllocation(addr).allocate(addr); @@ -70,10 +79,7 @@ return addr; } - /** - * The main reason for the AllocationContext is to be - * able to atomically release the associated allocations - */ + synchronized public void clear() { for (Long addr : m_addresses) { m_parent.free(addr); @@ -82,6 +88,7 @@ m_addresses.clear(); } + synchronized public void free(final long addr) { // getSectorAllocation(addr).free(addr); m_addresses.remove(Long.valueOf(addr)); @@ -89,62 +96,80 @@ m_parent.free(addr); } - public ByteBuffer[] get(long addr) { + synchronized + public ByteBuffer[] get(final long addr) { return m_parent.get(addr); } - public AllocationContext createAllocationContext() { + public IMemoryManager createAllocationContext() { return new AllocationContext(this); } - - private int segmentID(final long addr) { - final int rwaddr = MemoryManager.getAllocationAddress(addr); - - return SectorAllocator.getSectorIndex(rwaddr); - } - - private int segmentOffset(final long addr) { - final int rwaddr = MemoryManager.getAllocationAddress(addr); - - return SectorAllocator.getSectorOffset(rwaddr); - } - - SectorAllocation getSectorAllocation(final long addr) { - final int index = segmentID(addr); - if (m_head == null) { - m_head = new SectorAllocation(index); - } - SectorAllocation sa = m_head; - while (sa.m_index != index) { - if (sa.m_next == null) { - sa.m_next = new SectorAllocation(index); - } - sa = sa.m_next; - } - - return sa; - } - - class SectorAllocation { - final int m_index; - final int[] m_bits = new int[SectorAllocator.NUM_ENTRIES]; - SectorAllocation m_next = null; - - SectorAllocation(final int index) { - m_index = index; - } - public void allocate(long addr) { - assert !SectorAllocator.tstBit(m_bits, segmentOffset(addr)); - - SectorAllocator.setBit(m_bits, segmentOffset(addr)); - } +// private SectorAllocation m_head = null; +// +// /** +// * Return the index of {@link SectorAllocator} for the given address. +// * +// * @param addr +// * The given address. +// * @return The index of the {@link SectorAllocator} containing that address. +// */ +// private int segmentID(final long addr) { +// final int rwaddr = MemoryManager.getAllocationAddress(addr); +// +// return SectorAllocator.getSectorIndex(rwaddr); +// } +// +// /** +// * Return the bit offset into the bit map of {@link SectorAllocator} for the +// * given address. +// * +// * @param addr +// * The given address. +// * @return +// */ +// private int segmentOffset(final long addr) { +// final int rwaddr = MemoryManager.getAllocationAddress(addr); +// +// return SectorAllocator.getSectorOffset(rwaddr); +// } +// +// SectorAllocation getSectorAllocation(final long addr) { +// final int index = segmentID(addr); +// if (m_head == null) { +// m_head = new SectorAllocation(index); +// } +// SectorAllocation sa = m_head; +// while (sa.m_index != index) { +// if (sa.m_next == null) { +// sa.m_next = new SectorAllocation(index); +// } +// sa = sa.m_next; +// } +// +// return sa; +// } +// +// class SectorAllocation { +// final int m_index; +// final int[] m_bits = new int[SectorAllocator.NUM_ENTRIES]; +// SectorAllocation m_next = null; +// +// SectorAllocation(final int index) { +// m_index = index; +// } +// +// public void allocate(long addr) { +// assert !SectorAllocator.tstBit(m_bits, segmentOffset(addr)); +// +// SectorAllocator.setBit(m_bits, segmentOffset(addr)); +// } +// +// public void free(long addr) { +// assert SectorAllocator.tstBit(m_bits, segmentOffset(addr)); +// +// SectorAllocator.clrBit(m_bits, segmentOffset(addr)); +// } +// } - public void free(long addr) { - assert SectorAllocator.tstBit(m_bits, segmentOffset(addr)); - - SectorAllocator.clrBit(m_bits, segmentOffset(addr)); - } - } - } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/IMemoryManager.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/IMemoryManager.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/IMemoryManager.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -26,18 +26,33 @@ import java.nio.ByteBuffer; +/** + * Abstraction for managing data in {@link ByteBuffer}s. Typically those buffers + * will be allocated on the native process heap. + * + * @author martyncutcher + */ public interface IMemoryManager { + /** * Allocates space on the backing resource and copies the provided data. * - * @param data - will be copied to the backing resource + * @param data + * The data will be copied to the backing resource + * * @return the address to be passed to the get method to retrieve the data + * + * @throws IllegalArgumentException + * if the argument is <code>null</code>. + * + * FIXME Replace with allocate(int nbytes):ByteBuffer[] so the + * caller can do zero copy NIO. */ public long allocate(ByteBuffer data); - + /** - * The ByteBuffer[] return enables the handling of blobs that span more - * than a single slot, without the need to create an intermediate ByteBuffer. + * The ByteBuffer[] return enables the handling of blobs that span more than + * a single slot, without the need to create an intermediate ByteBuffer. * * This will support transfers directly to other direct ByteBuffers, for * example for network IO. @@ -45,13 +60,18 @@ * Using ByteBuffer:put the returned array can be efficiently copied to * another ByteBuffer: * + * <pre> * ByteBuffer mybb; * ByteBuffer[] bufs = get(addr); * for (ByteBuffer b : bufs) { - * mybb.put(b); + * mybb.put(b); * } + * </pre> * - * @param addr previouslt returned by allocate + * @param addr + * An address previously returned by + * {@link #allocate(ByteBuffer)}. + * * @return array of ByteBuffers */ public ByteBuffer[] get(long addr); @@ -67,9 +87,11 @@ * Clears all current allocations */ public void clear(); - + /** - * Clears all current allocations + * Create a child allocation context within which the caller may make and + * release allocations. */ - public AllocationContext createAllocationContext(); + public IMemoryManager createAllocationContext(); + } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/ISectorManager.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/ISectorManager.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/ISectorManager.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -25,55 +25,60 @@ package com.bigdata.rwstore.sector; /** - * The SectorManager defines the contract required to manage a set of - * SectorAllocators. + * The {@link ISectorManager} defines the contract required to manage a set of + * {@link SectorAllocator}s. * - * The SectorManager is passed to the SectorAllocator constructors and they - * will callback to manage their free list availability, and to trim the - * allocated storage if required. + * The {@link ISectorManager} is passed to the {@link SectorAllocator} + * constructors and they will callback to manage their free list availability, + * and to trim the allocated storage if required. * * @author Martyn Cutcher - * */ public interface ISectorManager { /** - * This request is made when the sectorAllocator no longer has a full set - * of block allocations available. + * This request is made when the sectorAllocator no longer has a full set of + * block allocations available. * * The allocator will issue this callback to help the SectorManager manage * an effective freelist of available allocators. * - * @param sectorAllocator to be removed + * @param sectorAllocator + * to be removed */ void removeFromFreeList(SectorAllocator sectorAllocator); /** - * When suficient alocations have been freed for recycling that a threshold - * of availability of reached for all block sizes, then the allocator - * calls back to the SectorManager to signal it is available to be returned - * to the free list. + * When sufficient allocations have been freed for recycling that a + * threshold of availability of reached for all block sizes, then the + * allocator calls back to the SectorManager to signal it is available to be + * returned to the free list. * - * @param sectorAllocator to be added + * @param sectorAllocator + * to be added */ void addToFreeList(SectorAllocator sectorAllocator); - + /** * When a sector is first created, it will remain at the head of the free * list until one of two conditions has been reached: + * <ol> * - * 1) The allocation has been saturated - * 2) The bit space has been filled + * <li>The allocation has been saturated.</li> + * <li>The bit space has been filled. + * <li> + * </ol> * - * In the case of (2), then it is possible that significant allocation - * space cannot be utilised - which will happen if the average allocation - * is less than 1K. In this situation, the sector can be trimmed and the - * space made available to the next sector. + * In the case of (2), then it is possible that significant allocation space + * cannot be utilized - which will happen if the average allocation is less + * than 1K. In this situation, the sector can be trimmed and the space made + * available to the next sector. * * trimSector will only be called in this condition - on the first occasion * that the allocator is removed from the freeList. * - * @param trim - the amount by which the sector allocation can be reduced + * @param trim + * - the amount by which the sector allocation can be reduced */ void trimSector(long trim, SectorAllocator sector); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManager.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManager.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManager.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -31,49 +31,50 @@ import org.apache.log4j.Logger; import com.bigdata.io.DirectBufferPool; -import com.bigdata.io.IByteArraySlice; /** - * The MemoryManager manages an off-heap Direct Buffer. It uses the new - * SectorAllocator to allocate slots within the address range. + * The MemoryManager manages an off-heap Direct {@link ByteBuffer}. It uses the + * new SectorAllocator to allocate slots within the address range. * - * The interface is designed to support efficient transfer between NIO - * buffers. + * The interface is designed to support efficient transfer between NIO buffers. * * The most complex aspect of the implementation is the BLOB representation, - * requiring a mapping across multiple allocation slots. This is managed - * using recursive calls in the main three methods: allocate, free and get. + * requiring a mapping across multiple allocation slots. This is managed using + * recursive calls in the main three methods: allocate, free and get. * * @author Martyn Cutcher - * */ public class MemoryManager implements IMemoryManager, ISectorManager { - protected static final Logger log = Logger + private static final Logger log = Logger .getLogger(MemoryManager.class); - final ByteBuffer m_resource; + private final ByteBuffer m_resource; final private ReentrantLock m_allocationLock = new ReentrantLock(); int m_allocation = 0; - final int m_sectorSize; - final int m_maxResource; + private final int m_sectorSize; + private final int m_maxResource; - final ArrayList<SectorAllocator> m_sectors = new ArrayList<SectorAllocator>(); - final ArrayList<SectorAllocator> m_free = new ArrayList<SectorAllocator>(); + private final ArrayList<SectorAllocator> m_sectors = new ArrayList<SectorAllocator>(); + private final ArrayList<SectorAllocator> m_free = new ArrayList<SectorAllocator>(); public MemoryManager(final int maxResource, final int sectorSize) { +// m_resource = DirectBufferPool.INSTANCE.acquire(); m_resource = ByteBuffer.allocateDirect(maxResource); m_sectorSize = sectorSize; m_maxResource = maxResource; } - - public class MemoryManagerResourceError extends RuntimeException { - protected MemoryManagerResourceError() {} + + protected void finalize() throws Throwable { + // release to pool. + DirectBufferPool.INSTANCE.release(m_resource); } public long allocate(final ByteBuffer data) { + if (data == null) + throw new IllegalArgumentException(); m_allocationLock.lock(); try { final int size = data.remaining(); @@ -142,28 +143,9 @@ } } - /** - * The ByteBuffer[] return enables the handling of blobs that span more - * than a single slot, without the need to create an intermediate ByteBuffer. - * - * This will support transfers directly to other direct ByteBuffers, for - * example for network IO. - * - * Using ByteBuffer:put the returned array can be efficiently copied to - * another ByteBuffer: - * - * ByteBuffer mybb; - * ByteBuffer[] bufs = get(addr); - * for (ByteBuffer b : bufs) { - * mybb.put(b); - * } - * - * @param addr - * @return - */ public ByteBuffer[] get(final long addr) { - int rwaddr = getAllocationAddress(addr); - int size = getAllocationSize(addr); + final int rwaddr = getAllocationAddress(addr); + final int size = getAllocationSize(addr); if (size <= SectorAllocator.BLOB_SIZE) { return new ByteBuffer[] { getBuffer(rwaddr, size) }; @@ -219,7 +201,7 @@ return ret; } - private SectorAllocator getSector(int rwaddr) { + private SectorAllocator getSector(final int rwaddr) { final int index = SectorAllocator.getSectorIndex(rwaddr); if (index >= m_sectors.size()) throw new IllegalStateException("Address: " + rwaddr + " yields index: " + index + " >= sector:size(): " + m_sectors.size()); @@ -231,7 +213,7 @@ return (int) (addr >> 32L); } - static int getAllocationSize(long addr) { + static int getAllocationSize(final long addr) { return (int) (addr & 0xFFFFL); } @@ -281,20 +263,25 @@ } public void clear() { - m_sectors.clear(); - m_free.clear(); - m_allocation = 0; + m_allocationLock.lock(); + try { + m_sectors.clear(); + m_free.clear(); + m_allocation = 0; + } finally { + m_allocationLock.unlock(); + } } - public void releaseResources() throws InterruptedException { - DirectBufferPool.INSTANCE.release(m_resource); - } +// public void releaseResources() throws InterruptedException { +// DirectBufferPool.INSTANCE.release(m_resource); +// } public void addToFreeList(final SectorAllocator sector) { m_free.add(sector); } - public void removeFromFreeList(SectorAllocator sector) { + public void removeFromFreeList(final SectorAllocator sector) { assert m_free.get(0) == sector; m_free.remove(sector); @@ -306,7 +293,7 @@ m_allocation -= trim; } - public AllocationContext createAllocationContext() { + public IMemoryManager createAllocationContext() { return new AllocationContext(this); } Added: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManagerResourceError.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManagerResourceError.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/MemoryManagerResourceError.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -0,0 +1,13 @@ +/** + * + */ +package com.bigdata.rwstore.sector; + +public class MemoryManagerResourceError extends RuntimeException { + /** + * + */ + private static final long serialVersionUID = 1L; + + protected MemoryManagerResourceError() {} +} \ No newline at end of file Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/SectorAllocator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/SectorAllocator.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/rwstore/sector/SectorAllocator.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -31,23 +31,22 @@ import org.apache.log4j.Logger; -import com.bigdata.io.DirectBufferPool; import com.bigdata.rwstore.FixedOutputStream; import com.bigdata.rwstore.IWriteCacheManager; /** * The SectorAllocator is designed as an alternative the the standard RWStore * FixedAllocators. - * + * <p> * The idea of the SectorAllocator is to efficiently contain within a single * region as dense a usage as possible. Since a SectorAllocator is able to * allocate a full range of slot sizes, it should be able to service several - * thousand allocations and maximise disk locality on write. - * + * thousand allocations and maximize disk locality on write. + * <p> * Furthermore, it presents an option to be synced with the backing store - * similarly to a MappedFile, in which case a single write for the entire * sector could be made for update. - * + * <p> * What we do not want is to run out of bits and to leave significant unused * space in the sector. This could happen if we primarily allocated small * slots - say on average 512 bytes. In this case, the maximum 1636 entries @@ -63,20 +62,19 @@ * sectors. Implying a maximum addressable store file of 64M * 64K, * = 4TB of full sectors. If the average sector only requires 32M, then the * total store would be reduced appropriately. - * + * <p> * The maximum theoretical storage is yielded by MAX_INT * AVG_SLOT_SIZE, so * 2GB * 2K (avg) would equate to the optimal maximum addressable allocations * and file size. An AVG of > 2K yields fewer allocations and an AVG of < 2K * a reduced file size. * * TODO: add parameterisation of META_SIZE for exploitation by MemoryManager. - * TODO: cache block starts in m_addresses to simplify/optimise bit2Offset * * @author Martyn Cutcher - * */ public class SectorAllocator { - protected static final Logger log = Logger + + private static final Logger log = Logger .getLogger(SectorAllocator.class); static final int getBitMask(int bits) { @@ -86,28 +84,29 @@ return ret; } - static final int SECTOR_INDEX_BITS = 16; - static final int SECTOR_OFFSET_BITS = 32-SECTOR_INDEX_BITS; - static final int SECTOR_OFFSET_MASK = getBitMask(SECTOR_OFFSET_BITS); + + private static final int SECTOR_INDEX_BITS = 16; + private static final int SECTOR_OFFSET_BITS = 32-SECTOR_INDEX_BITS; + private static final int SECTOR_OFFSET_MASK = getBitMask(SECTOR_OFFSET_BITS); - static final int META_SIZE = 8192; // 8K + private static final int META_SIZE = 8192; // 8K - final static int SECTOR_SIZE = 64 * 1024 * 1024; // 10M - final static int NUM_ENTRIES = (META_SIZE - 12) / (4 + 1); // 8K - index - address / (4 + 1) bits plus tag - final int[] BIT_MASKS = {0x1, 0x3, 0x7, 0xF, 0xFF, 0xFFFF, 0xFFFFFFFF}; +// private final static int SECTOR_SIZE = 64 * 1024 * 1024; // 10M + private final static int NUM_ENTRIES = (META_SIZE - 12) / (4 + 1); // 8K - index - address / (4 + 1) bits plus tag +// private final int[] BIT_MASKS = {0x1, 0x3, 0x7, 0xF, 0xFF, 0xFFFF, 0xFFFFFFFF}; final static int BLOB_SIZE = 4096; - final static int BLOB_CHAIN_OFFSET = BLOB_SIZE - 4; - final static int[] ALLOC_SIZES = {64, 128, 256, 512, 1024, 2048, BLOB_SIZE}; - final static int[] ALLOC_BITS = {32, 32, 32, 32, 32, 32, 32}; - int m_index; - long m_sectorAddress; - int m_maxSectorSize; - byte[] m_tags = new byte[NUM_ENTRIES]; - int[] m_bits = new int[NUM_ENTRIES]; // 128 - sectorAddress(1) - m_tags(4) +// private final static int BLOB_CHAIN_OFFSET = BLOB_SIZE - 4; + private final static int[] ALLOC_SIZES = {64, 128, 256, 512, 1024, 2048, BLOB_SIZE}; + private final static int[] ALLOC_BITS = {32, 32, 32, 32, 32, 32, 32}; + private int m_index; + private long m_sectorAddress; + private int m_maxSectorSize; + private final byte[] m_tags = new byte[NUM_ENTRIES]; + private final int[] m_bits = new int[NUM_ENTRIES]; // 128 - sectorAddress(1) - m_tags(4) - int[] m_transientbits = new int[NUM_ENTRIES]; - int[] m_commitbits = new int[NUM_ENTRIES]; - int[] m_addresses = new int[NUM_ENTRIES]; + private int[] m_transientbits = new int[NUM_ENTRIES]; + private int[] m_commitbits = new int[NUM_ENTRIES]; + private final int[] m_addresses = new int[NUM_ENTRIES]; // maintain count against each alloc size, this provides ready access to be // able to check the minimum number of bits for all tag sizes. No @@ -118,17 +117,18 @@ // only the total number of bits, but the average number of bits for the // tag, dividing the numebr of free bits by the total (number of blocks) // for each tag. - int[] m_free = new int[ALLOC_SIZES.length]; - int[] m_total = new int[ALLOC_SIZES.length]; - int[] m_allocations = new int[ALLOC_SIZES.length]; - int[] m_recycles = new int[ALLOC_SIZES.length]; + final private int[] m_free = new int[ALLOC_SIZES.length]; + final private int[] m_total = new int[ALLOC_SIZES.length]; + final private int[] m_allocations = new int[ALLOC_SIZES.length]; + final private int[] m_recycles = new int[ALLOC_SIZES.length]; - final ISectorManager m_store; - boolean m_onFreeList = false; - private long m_diskAddr; + private final ISectorManager m_store; private final IWriteCacheManager m_writes; - public SectorAllocator(ISectorManager store, IWriteCacheManager writes) { + private boolean m_onFreeList = false; + private long m_diskAddr; + + public SectorAllocator(final ISectorManager store, final IWriteCacheManager writes) { m_store = store; m_writes = writes; } @@ -217,7 +217,7 @@ int allocated = 0; for (int i = 0; i < m_tags.length; i++) { if (m_tags[i] == -1) { - int block = this.ALLOC_SIZES[tag] * 32; + int block = SectorAllocator.ALLOC_SIZES[tag] * 32; if ((allocated + block) <= m_maxSectorSize) { m_tags[i] = tag; m_free[tag] += 32; @@ -553,15 +553,15 @@ m_store.addToFreeList(this); } - public static int getSectorIndex(int rwaddr) { + public static int getSectorIndex(final int rwaddr) { return (-rwaddr) >> SECTOR_OFFSET_BITS; } - public static int getSectorOffset(int rwaddr) { + public static int getSectorOffset(final int rwaddr) { return (-rwaddr) & SECTOR_OFFSET_MASK; } - public static int getBlobBlockCount(int size) { + public static int getBlobBlockCount(final int size) { final int nblocks = (size + BLOB_SIZE - 1) / BLOB_SIZE; return nblocks; Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/rwstore/sector/TestMemoryManager.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/rwstore/sector/TestMemoryManager.java 2011-02-07 20:30:43 UTC (rev 4181) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/rwstore/sector/TestMemoryManager.java 2011-02-08 14:57:32 UTC (rev 4182) @@ -10,7 +10,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import com.bigdata.rwstore.sector.MemoryManager.MemoryManagerResourceError; import com.bigdata.util.concurrent.DaemonThreadFactory; import junit.framework.TestCase; @@ -84,7 +83,7 @@ public void testAllocationContexts() { installMemoryManager(); - AllocationContext context = manager.createAllocationContext(); + final IMemoryManager context = manager.createAllocationContext(); for (int i = 0; i < 500; i++) { doStressAllocations(context, false, 5000, 5 + r.nextInt(3000)); context.clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |