T
- record typepublic class InMemoryPartition<T> extends Object
CompactingHashTable
Modifier and Type | Field and Description |
---|---|
protected int |
nextOverflowBucket |
protected int |
numOverflowSegments |
protected MemorySegment[] |
overflowSegments |
Constructor and Description |
---|
InMemoryPartition(TypeSerializer<T> serializer,
int partitionNumber,
ListMemorySegmentSource memSource,
int pageSize,
int pageSizeInBits)
Creates a new partition, in memory, with one buffer.
|
Modifier and Type | Method and Description |
---|---|
void |
allocateSegments(int numberOfSegments)
attempts to allocate specified number of segments and should only be used by compaction
partition fails silently if not enough segments are available since next compaction could
still succeed
|
long |
appendRecord(T record)
Inserts the given object into the current buffer.
|
void |
clearAllMemory(List<MemorySegment> target)
releases all of the partition's segments (pages and overflow buckets)
|
int |
getBlockCount() |
int |
getPartitionNumber()
Gets the partition number of this partition.
|
long |
getRecordCount()
number of records in partition including garbage
|
boolean |
isCompacted() |
void |
overwriteRecordAt(long pointer,
T record)
Deprecated.
Don't use this, overwrites record and causes inconsistency or data loss for
overwriting everything but records of the exact same size
|
void |
pushDownPages() |
T |
readRecordAt(long pointer) |
T |
readRecordAt(long pointer,
T reuse) |
ArrayList<MemorySegment> |
resetOverflowBuckets()
resets overflow bucket counters and returns freed memory and should only be used for resizing
|
void |
resetRecordCounter()
sets record counter to zero and should only be used on compaction partition
|
void |
resetRWViews()
resets read and write views and should only be used on compaction partition
|
void |
setIsCompacted(boolean compacted)
sets compaction status (should only be set
true directly after compaction and
false when garbage was created) |
void |
setPartitionNumber(int number)
overwrites partition number and should only be used on compaction partition
|
String |
toString() |
protected MemorySegment[] overflowSegments
protected int numOverflowSegments
protected int nextOverflowBucket
public InMemoryPartition(TypeSerializer<T> serializer, int partitionNumber, ListMemorySegmentSource memSource, int pageSize, int pageSizeInBits)
serializer
- Serializer for T.partitionNumber
- The number of the partition.memSource
- memory poolpageSize
- segment size in bytespageSizeInBits
- public int getPartitionNumber()
public void setPartitionNumber(int number)
number
- new partitionpublic int getBlockCount()
public long getRecordCount()
public void resetRecordCounter()
public void resetRWViews()
public void pushDownPages()
public ArrayList<MemorySegment> resetOverflowBuckets()
public boolean isCompacted()
public void setIsCompacted(boolean compacted)
true
directly after compaction and
false
when garbage was created)compacted
- compaction statuspublic final long appendRecord(T record) throws IOException
record
- The object to be written to the partition.IOException
- Thrown when the write failed.public T readRecordAt(long pointer, T reuse) throws IOException
IOException
public T readRecordAt(long pointer) throws IOException
IOException
@Deprecated public void overwriteRecordAt(long pointer, T record) throws IOException
pointer
- pointer to start of recordrecord
- record to overwrite old one withIOException
public void clearAllMemory(List<MemorySegment> target)
target
- memory pool to release segments topublic void allocateSegments(int numberOfSegments)
numberOfSegments
- allocation countCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.