Class OffHeapStorageArea
- java.lang.Object
-
- org.terracotta.offheapstore.paging.OffHeapStorageArea
-
public class OffHeapStorageArea extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceOffHeapStorageArea.Owner
-
Field Summary
Fields Modifier and Type Field Description private Allocatorallocatorprivate floatcompressThresholdprivate static java.nio.ByteBuffer[]EMPTY_BUFFER_ARRAYprivate intinitialPageSizeprivate static longLARGEST_POWER_OF_TWOprivate static org.slf4j.LoggerLOGGERprivate intmaximalPageSizeprivate OffHeapStorageArea.Ownerownerprivate intpageGrowthAreaSizeprivate java.util.Map<java.lang.Integer,Page>pagesprivate PageSourcepageSourceprivate java.util.Randomrandomprivate java.util.Deque<java.util.Collection<Page>>releasedprivate booleanthiefprivate static booleanVALIDATINGprivate booleanvictim
-
Constructor Summary
Constructors Constructor Description OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int pageSize, boolean thief, boolean victim)OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int pageSize, boolean thief, boolean victim, float compressThreshold)OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int initialPageSize, int maximalPageSize, boolean thief, boolean victim)OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int initialPageSize, int maximalPageSize, boolean thief, boolean victim, float compressThreshold)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private longaddressForPage(int index)longallocate(long size)voidclear()private booleancompress()voiddestroy()private booleanexpandData()voidfree(long address)private voidfreePage(Page p)longgetAllocatedMemory()private intgetIndexForPage(Page p)longgetOccupiedMemory()private booleanmoveAddressDown(long target)private booleanmoveAddressDown(long target, int size, long start)private intnextPageSize()private intpageAddressFor(long address)private intpageIndexFor(long address)private intpageSizeFor(int index)java.nio.ByteBufferreadBuffer(long address, int length)Read the given range and return the data as a single read-onlyByteBuffer.java.nio.ByteBuffer[]readBuffers(long address, int length)Read the given range and return the data as an array of read-onlyByteBuffers.bytereadByte(long address)intreadInt(long address)longreadLong(long address)shortreadShort(long address)voidrelease(long address)java.util.Collection<Page>release(java.util.Collection<Page> targets)booleanshrink()java.lang.StringtoString()private voidvalidatePages()voidvalidateStorageArea()voidwriteBuffer(long address, java.nio.ByteBuffer data)voidwriteBuffers(long address, java.nio.ByteBuffer[] data)voidwriteByte(long address, byte value)voidwriteInt(long address, int value)voidwriteLong(long address, long value)voidwriteShort(long address, short value)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
VALIDATING
private static final boolean VALIDATING
-
LARGEST_POWER_OF_TWO
private static final long LARGEST_POWER_OF_TWO
-
EMPTY_BUFFER_ARRAY
private static final java.nio.ByteBuffer[] EMPTY_BUFFER_ARRAY
-
initialPageSize
private final int initialPageSize
-
maximalPageSize
private final int maximalPageSize
-
pageGrowthAreaSize
private final int pageGrowthAreaSize
-
compressThreshold
private final float compressThreshold
-
owner
private final OffHeapStorageArea.Owner owner
-
pageSource
private final PageSource pageSource
-
allocator
private final Allocator allocator
-
random
private final java.util.Random random
-
released
private java.util.Deque<java.util.Collection<Page>> released
-
pages
private final java.util.Map<java.lang.Integer,Page> pages
-
thief
private final boolean thief
-
victim
private final boolean victim
-
-
Constructor Detail
-
OffHeapStorageArea
public OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int pageSize, boolean thief, boolean victim)
-
OffHeapStorageArea
public OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int pageSize, boolean thief, boolean victim, float compressThreshold)
-
OffHeapStorageArea
public OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int initialPageSize, int maximalPageSize, boolean thief, boolean victim)
-
OffHeapStorageArea
public OffHeapStorageArea(PointerSize width, OffHeapStorageArea.Owner owner, PageSource pageSource, int initialPageSize, int maximalPageSize, boolean thief, boolean victim, float compressThreshold)
-
-
Method Detail
-
clear
public void clear()
-
readByte
public byte readByte(long address)
-
readShort
public short readShort(long address)
-
readInt
public int readInt(long address)
-
readLong
public long readLong(long address)
-
readBuffer
public java.nio.ByteBuffer readBuffer(long address, int length)Read the given range and return the data as a single read-onlyByteBuffer.- Parameters:
address- address to read fromlength- number of bytes to read- Returns:
- a read-only buffer
-
readBuffers
public java.nio.ByteBuffer[] readBuffers(long address, int length)Read the given range and return the data as an array of read-onlyByteBuffers.- Parameters:
address- address to read fromlength- number of bytes to read- Returns:
- an array of read-only buffers
-
writeByte
public void writeByte(long address, byte value)
-
writeShort
public void writeShort(long address, short value)
-
writeInt
public void writeInt(long address, int value)
-
writeLong
public void writeLong(long address, long value)
-
writeBuffer
public void writeBuffer(long address, java.nio.ByteBuffer data)
-
writeBuffers
public void writeBuffers(long address, java.nio.ByteBuffer[] data)
-
free
public void free(long address)
-
compress
private boolean compress()
-
destroy
public void destroy()
-
allocate
public long allocate(long size)
-
expandData
private boolean expandData()
-
getAllocatedMemory
public long getAllocatedMemory()
-
getOccupiedMemory
public long getOccupiedMemory()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
pageIndexFor
private int pageIndexFor(long address)
-
addressForPage
private long addressForPage(int index)
-
pageAddressFor
private int pageAddressFor(long address)
-
pageSizeFor
private int pageSizeFor(int index)
-
nextPageSize
private int nextPageSize()
-
validateStorageArea
public void validateStorageArea()
-
release
public void release(long address)
-
freePage
private void freePage(Page p)
-
moveAddressDown
private boolean moveAddressDown(long target)
-
moveAddressDown
private boolean moveAddressDown(long target, int size, long start)
-
shrink
public boolean shrink()
-
getIndexForPage
private int getIndexForPage(Page p)
-
validatePages
private void validatePages()
-
-