Interface ISchemaPage
-
- All Known Implementing Classes:
SchemaPage
public interface ISchemaPage
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description shortallocNewSegment(short size)Allocate space for a new segment inside this pagevoiddeleteSegment(short segId)java.util.Queue<IMNode>getChildren(short segId)longgetNextSegAddress(short segId)voidgetPageBuffer(java.nio.ByteBuffer dst)intgetPageIndex()longgetPrevSegAddress(short segId)shortgetSegmentSize(short segId)shortgetSpareSize()booleanhasRecordKeyInSegment(java.lang.String key, short segId)Check if record exists with name or alias.java.lang.Stringinspect()booleanisCapableForSize(short size)booleanisSegmentCapableFor(short segId, short size)IMNoderead(short segIdx, java.lang.String key)voidremoveRecord(short segId, java.lang.String key)voidsetNextSegAddress(short segId, long address)voidsetPrevSegAddress(short segId, long address)voidsyncPageBuffer()While segments are always synchronized with buffer SchemaPage.pageBuffer, header and tail are not.longtransplantSegment(ISchemaPage srcPage, short segId, short newSegSize)Transplant designated segment from srcPage, to spare space of the pagevoidupdate(short segIdx, java.lang.String key, java.nio.ByteBuffer buffer)The record is definitely inside specified segment.longwrite(short segIdx, java.lang.String key, java.nio.ByteBuffer buffer)Insert a content directly into specified segment, without considering preallocate and reallocate segment.
-
-
-
Method Detail
-
write
long write(short segIdx, java.lang.String key, java.nio.ByteBuffer buffer) throws org.apache.iotdb.commons.exception.MetadataExceptionInsert a content directly into specified segment, without considering preallocate and reallocate segment.
Find the right segment instance which MUST exists, cache the segment and insert the record.
If not enough, reallocate inside page first, or throw exception for new page then.Notice that, since
SchemaFile.reEstimateSegSize(int)may increase segment with very small extent, which originates from design ofSchemaFile.estimateSegmentSize(IMNode), a twice relocate will suffice any nodes smaller than 1024 KiB.
This reason works forupdate(short, String, ByteBuffer)as well.- Returns:
- return 0 if write succeed, a positive for next segment address
- Throws:
SchemaPageOverflowException- no next segment, no spare space inside pageorg.apache.iotdb.commons.exception.MetadataException
-
read
IMNode read(short segIdx, java.lang.String key) throws SegmentNotFoundException
- Throws:
SegmentNotFoundException
-
update
void update(short segIdx, java.lang.String key, java.nio.ByteBuffer buffer) throws org.apache.iotdb.commons.exception.MetadataExceptionThe record is definitely inside specified segment. This method compare old and new buffer to decide whether update in place.
If segment not enough, it will reallocate in this page first, and update segment offset list.
If no more space for reallocation, throwSchemaPageOverflowExceptionand return a negative for new page.See write(short, String, ByteBuffer) for the detail reason of a twice try.
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
hasRecordKeyInSegment
boolean hasRecordKeyInSegment(java.lang.String key, short segId) throws SegmentNotFoundExceptionCheck if record exists with name or alias.- Parameters:
key- name or alias of target childsegId- target segment index- Throws:
SegmentNotFoundException
-
getChildren
java.util.Queue<IMNode> getChildren(short segId) throws SegmentNotFoundException
- Throws:
SegmentNotFoundException
-
removeRecord
void removeRecord(short segId, java.lang.String key) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
deleteSegment
void deleteSegment(short segId) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
getPageIndex
int getPageIndex()
-
getSpareSize
short getSpareSize()
-
getSegmentSize
short getSegmentSize(short segId) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
getPageBuffer
void getPageBuffer(java.nio.ByteBuffer dst)
-
isCapableForSize
boolean isCapableForSize(short size)
-
isSegmentCapableFor
boolean isSegmentCapableFor(short segId, short size) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
syncPageBuffer
void syncPageBuffer()
While segments are always synchronized with buffer SchemaPage.pageBuffer, header and tail are not. This method will synchronize them with in mem attributes.
-
allocNewSegment
short allocNewSegment(short size) throws java.io.IOException, SchemaPageOverflowExceptionAllocate space for a new segment inside this page- Parameters:
size- expected segment size- Returns:
- segment index in this page, negative for not enough space
- Throws:
java.io.IOExceptionSchemaPageOverflowException
-
transplantSegment
long transplantSegment(ISchemaPage srcPage, short segId, short newSegSize) throws org.apache.iotdb.commons.exception.MetadataException
Transplant designated segment from srcPage, to spare space of the page- Parameters:
srcPage- source page conveys source segmentsegId- id of the target segmentnewSegSize- size of new segment in this page- Throws:
org.apache.iotdb.commons.exception.MetadataException- if spare not enough, segment not found or inconsistency
-
setNextSegAddress
void setNextSegAddress(short segId, long address) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
setPrevSegAddress
void setPrevSegAddress(short segId, long address) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
getNextSegAddress
long getNextSegAddress(short segId) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
getPrevSegAddress
long getPrevSegAddress(short segId) throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
inspect
java.lang.String inspect() throws SegmentNotFoundException- Throws:
SegmentNotFoundException
-
-