public class FixedAllocator extends Object implements Allocator
Modifier and Type | Method and Description |
---|---|
void |
abortAllocationContext(IAllocationContext context,
RWWriteCacheService writeCacheService)
Unwinds the allocations made within the context and clears the write
cache of any associated data
|
void |
addAddresses(ArrayList addrs) |
boolean |
addressInRange(int addr) |
void |
addToRegionMap(HashMap<Integer,FixedAllocator> map) |
int |
alloc(RWStore store,
int size,
IAllocationContext context)
The introduction of IAllocationContexts has added some complexity to
the older concept of a free list.
|
void |
appendShortStats(StringBuilder str,
RWStore.AllocationStats[] stats) |
static int |
calcBitSize(boolean optDensity,
int alloc,
int minReserve,
int modAllocation)
This determines the size of the reservation required in terms of
the number of ints each holding bits for 32 slots.
|
boolean |
canImmediatelyFree(int addr,
int size,
IAllocationContext context)
If the context is this allocators context AND it is not in the commit bits
then we can immediately free.
|
int |
compareTo(Object o) |
void |
computeDigest(Object snapshot,
MessageDigest digest)
Add the committed allocated slot contents to the digest
FIXME: First version is correct rather than optimal, need to
consider if there is any benefit to
|
boolean |
equals(Object o) |
boolean |
free(int addr,
int size) |
boolean |
free(int addr,
int size,
boolean overideSession)
Need to check if address to be freed was 'live' for any shadowed allocator to
determine if we need to adjust the 'savedLive' data.
|
int |
getAllocatedBlocks() |
long |
getAllocatedSlots()
Computes the amount of storage allocated using the freeBits count.
|
protected AllocBlock |
getBlockFromLocalOffset(int offset) |
int |
getBlockSize() |
int |
getDiskAddr()
Return the bit in metabits for the last persisted version of this
allocator.
|
long |
getFileStorage() |
int |
getIndex() |
long |
getPhysicalAddress(int offset) |
long |
getPhysicalAddress(int offset,
boolean nocheck)
Return the byte offset on the file corresponding to a bit index into this
FixedAllocator . |
int |
getPhysicalSize(int offset) |
int |
getRawStartAddr()
returns the raw start address
|
int |
getSlotSize() |
long |
getStartAddr() |
String |
getStats(AtomicLong counter) |
String |
getSummaryStats() |
protected int |
grabAllocation(RWStore store,
int blockSize) |
boolean |
hasFree() |
boolean |
isAllocated(int offset) |
boolean |
isCommitted(int offset) |
void |
postCommit()
Update the historical commit bits only once confirmed
|
void |
read(DataInputStream str) |
int |
removeFreedWrites(FixedAllocator xfa,
ConcurrentWeakValueCache<Long,ICommitter> externalCache) |
void |
setAllocationContext(IAllocationContext context) |
void |
setBucketStats(StorageStats.Bucket b) |
void |
setDiskAddr(int addr)
Set the bit in metabits for this allocator.
|
void |
setFreeList(ArrayList list) |
void |
setFreeList(ArrayList list,
boolean force)
The force parameter is set to true when the allocator is being moved from one
free list to another.
|
void |
setIndex(int index) |
boolean |
verify(int addr) |
boolean |
verifyAllocatedAddress(long addr)
Determines if the provided physical address is within an allocated slot
|
byte[] |
write()
write called on commit, so this is the point when "transient frees" - the
freeing of previously committed memory can be made available since we
are creating a new commit point - the condition being that m_freeBits
was zero and m_freeTransients not.
|
public long getStartAddr()
getStartAddr
in interface Allocator
public int compareTo(Object o)
compareTo
in interface Comparable
public int getDiskAddr()
RWStore.metaBit2Addr(int)
.getDiskAddr
in interface Allocator
public void setDiskAddr(int addr)
setDiskAddr
in interface Allocator
addr
- A bit obtained from RWStore.metaAlloc()
.public long getPhysicalAddress(int offset, boolean nocheck)
FixedAllocator
.
The tweak of 3 to the offset is to ensure 1, that no address is zero and 2 to enable the values 1 & 2 to be special cased (this aspect is now historical).
offset
- The bit index into the FixedAllocator
.public int getPhysicalSize(int offset)
getPhysicalSize
in interface Allocator
public int getBlockSize()
getBlockSize
in interface Allocator
public void setFreeList(ArrayList list)
setFreeList
in interface Allocator
public void setFreeList(ArrayList list, boolean force)
public void setAllocationContext(IAllocationContext context)
public void abortAllocationContext(IAllocationContext context, RWWriteCacheService writeCacheService)
writeCacheService
- public byte[] write()
public void read(DataInputStream str)
public static int calcBitSize(boolean optDensity, int alloc, int minReserve, int modAllocation)
alloc
- the slot size to be managedminReserve
- the minimum reservation in bytespublic String getStats(AtomicLong counter)
public String getSummaryStats()
public boolean addressInRange(int addr)
addressInRange
in interface Allocator
public boolean free(int addr, int size, boolean overideSession)
public int alloc(RWStore store, int size, IAllocationContext context)
In addition to the standard free allocation search we want to add a "density" restriction for small slots to encourage the aggregation of writes (by increasing the likelihood of sibling slot allocation).
There is some "Do What I mean" complexity here, with difficulty in determining a good rule to identify an initial allocation point. There is a danger of significantly reducing the allocation efficiency of short transactions if we too naively check committed bit density. We should only do this when identifying the initial allocation, and when the allocIndex is incremented.
protected int grabAllocation(RWStore store, int blockSize)
public void addAddresses(ArrayList addrs)
addAddresses
in interface Allocator
public int getRawStartAddr()
getRawStartAddr
in interface Allocator
public void appendShortStats(StringBuilder str, RWStore.AllocationStats[] stats)
appendShortStats
in interface Allocator
public int getAllocatedBlocks()
public long getFileStorage()
public long getAllocatedSlots()
public boolean isAllocated(int offset)
isAllocated
in interface Allocator
public boolean isCommitted(int offset)
protected final AllocBlock getBlockFromLocalOffset(int offset)
public boolean canImmediatelyFree(int addr, int size, IAllocationContext context)
canImmediatelyFree
in interface Allocator
public void setBucketStats(StorageStats.Bucket b)
public long getPhysicalAddress(int offset)
getPhysicalAddress
in interface Allocator
public int getSlotSize()
public void computeDigest(Object snapshot, MessageDigest digest)
snapshot
- digest
- public void postCommit()
public int removeFreedWrites(FixedAllocator xfa, ConcurrentWeakValueCache<Long,ICommitter> externalCache)
public boolean verifyAllocatedAddress(long addr)
addr
- public void addToRegionMap(HashMap<Integer,FixedAllocator> map)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.