Class PartitionBuffer<T>
- java.lang.Object
-
- com.snowflake.kafka.connector.internal.PartitionBuffer<T>
-
- Type Parameters:
T- Return type ofgetData()
- Direct Known Subclasses:
TopicPartitionChannel.StreamingBuffer
public abstract class PartitionBuffer<T> extends Object
Abstract class which holds buffered data per partition including its start offset, end offset, size.The getData() method returns the data specific to the implementation.
Buffer stores the converted records to Json format.
Long lived buffer would mean the data in partition would stay across two put APIs since the buffer thresholds were not met.
Please check respective implementation class for more details.
-
-
Constructor Summary
Constructors Constructor Description PartitionBuffer()Public constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longgetBufferSizeBytes()abstract TgetData()Return the data that was buffered because buffer threshold might have been reachedlonggetFirstOffset()longgetLastOffset()intgetNumOfRecords()abstract List<org.apache.kafka.connect.sink.SinkRecord>getSinkRecords()TODO:SNOW-552576 Avoid extra memory in buffer.abstract voidinsert(org.apache.kafka.connect.sink.SinkRecord record)Inserts the row into Buffer.booleanisEmpty()voidsetBufferSizeBytes(long bufferSizeBytes)voidsetFirstOffset(long firstOffset)voidsetLastOffset(long lastOffset)voidsetNumOfRecords(int numOfRecords)StringtoString()
-
-
-
Method Detail
-
getNumOfRecords
public int getNumOfRecords()
- Returns:
- Number of records in this buffer
-
getBufferSizeBytes
public long getBufferSizeBytes()
- Returns:
- Buffer size in bytes
-
getFirstOffset
public long getFirstOffset()
- Returns:
- First offset number in this buffer
-
getLastOffset
public long getLastOffset()
- Returns:
- Last offset number in this buffer
-
setNumOfRecords
public void setNumOfRecords(int numOfRecords)
- Parameters:
numOfRecords- Updates number of records (Usually by 1)
-
setBufferSizeBytes
public void setBufferSizeBytes(long bufferSizeBytes)
- Parameters:
bufferSizeBytes- Updates sum of size of records present in this buffer (Bytes)
-
setFirstOffset
public void setFirstOffset(long firstOffset)
- Parameters:
firstOffset- First offset no to set in this buffer
-
setLastOffset
public void setLastOffset(long lastOffset)
- Parameters:
lastOffset- Last offset no to set in this buffer
-
isEmpty
public boolean isEmpty()
- Returns:
- true if buffer is empty
-
insert
public abstract void insert(org.apache.kafka.connect.sink.SinkRecord record)
Inserts the row into Buffer.- Parameters:
record- the record which kafka sends to KC. We also convert the record to a format which is understood by Snowflake Table
-
getData
public abstract T getData()
Return the data that was buffered because buffer threshold might have been reached- Returns:
- respective data type implemented by the class.
-
getSinkRecords
public abstract List<org.apache.kafka.connect.sink.SinkRecord> getSinkRecords()
TODO:SNOW-552576 Avoid extra memory in buffer.- Returns:
- the sinkrecords corresponding to this buffer
-
-