Interface ISegment
-
- All Known Implementing Classes:
Segment
public interface ISegmentThis interface interacts with segment bytebuffer.
-
-
Field Summary
Fields Modifier and Type Field Description static intSEG_HEADER_SIZE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddelete()voidextendsTo(java.nio.ByteBuffer newBuffer)This method will write info into a buffer equal or larger to existed one.java.util.Queue<IMNode>getAllRecords()longgetNextSegAddress()longgetPrevSegAddress()IMNodegetRecordAsIMNode(java.lang.String key)get a MNode by its name or aliasshortgetSpareSize()booleanhasRecordAlias(java.lang.String alias)booleanhasRecordKey(java.lang.String key)intinsertRecord(java.lang.String key, java.nio.ByteBuffer buffer)check whether enough space, notice that pairLength including 3 parts: [var length] key string itself, [int, 4 bytes] length of key string, [short, 2 bytes] key addressjava.lang.Stringinspect()intremoveRecord(java.lang.String key)voidsetNextSegAddress(long nextSegAddress)voidsetPrevSegAddress(long prevSegAddress)shortsize()voidsyncBuffer()Records are always sync with buffer, but header and key-address list are not.java.lang.StringtoString()intupdateRecord(java.lang.String key, java.nio.ByteBuffer buffer)
-
-
-
Field Detail
-
SEG_HEADER_SIZE
static final int SEG_HEADER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
insertRecord
int insertRecord(java.lang.String key, java.nio.ByteBuffer buffer) throws RecordDuplicatedExceptioncheck whether enough space, notice that pairLength including 3 parts: [var length] key string itself, [int, 4 bytes] length of key string, [short, 2 bytes] key address- Returns:
- -1 for segment overflow, otherwise for spare space
- Throws:
RecordDuplicatedException
-
updateRecord
int updateRecord(java.lang.String key, java.nio.ByteBuffer buffer) throws SegmentOverflowException, RecordDuplicatedException- Parameters:
key- name of the record, not the aliasbuffer- content of the updated record- Returns:
- index of keyAddressList, -1 for not found, exception for space run out
- Throws:
SegmentOverflowException- if segment runs out of memoryRecordDuplicatedException
-
removeRecord
int removeRecord(java.lang.String key)
-
getRecordAsIMNode
IMNode getRecordAsIMNode(java.lang.String key) throws org.apache.iotdb.commons.exception.MetadataException
get a MNode by its name or alias- Parameters:
key- name or alias of the target node- Returns:
- node instance
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
hasRecordKey
boolean hasRecordKey(java.lang.String key)
-
hasRecordAlias
boolean hasRecordAlias(java.lang.String alias)
-
getAllRecords
java.util.Queue<IMNode> getAllRecords() throws org.apache.iotdb.commons.exception.MetadataException
- Throws:
org.apache.iotdb.commons.exception.MetadataException
-
syncBuffer
void syncBuffer()
Records are always sync with buffer, but header and key-address list are not. This method sync these values to the buffer.
-
size
short size()
-
getSpareSize
short getSpareSize()
-
delete
void delete()
-
getPrevSegAddress
long getPrevSegAddress()
-
getNextSegAddress
long getNextSegAddress()
-
setPrevSegAddress
void setPrevSegAddress(long prevSegAddress)
-
setNextSegAddress
void setNextSegAddress(long nextSegAddress)
-
extendsTo
void extendsTo(java.nio.ByteBuffer newBuffer)
This method will write info into a buffer equal or larger to existed one. There is no need to call sync before this method, since it will flush header and key-offset list directly.- Parameters:
newBuffer- target buffer
-
toString
java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
inspect
java.lang.String inspect()
-
-