Implementation:Risingwavelabs Risingwave Deserializer Interface
Metadata
| Property | Value |
|---|---|
| File | java/connector-node/connector-api/src/main/java/com/risingwave/connector/api/sink/Deserializer.java
|
| Language | Java |
| Module | connector-api |
| Package | com.risingwave.connector.api.sink
|
| Classes | Deserializer (interface)
|
| Lines | 24 |
Overview
Deserializer is an interface that defines the contract for deserializing protobuf WriteBatch messages into an iterable sequence of SinkRow objects. This abstraction allows different serialization formats to be supported by providing different Deserializer implementations, while the rest of the sink pipeline can consume rows uniformly.
The returned CloseableIterable<SinkRow> ensures that any resources allocated during deserialization can be properly released after the rows have been consumed.
Code Reference
Source Location
java/connector-node/connector-api/src/main/java/com/risingwave/connector/api/sink/Deserializer.java
Signature
public interface Deserializer {
CloseableIterable<SinkRow> deserialize(
ConnectorServiceProto.SinkWriterStreamRequest.WriteBatch writeBatch);
}
Imports
import com.risingwave.proto.ConnectorServiceProto;
I/O Contract
deserialize
| Parameter | Type | Description |
|---|---|---|
writeBatch |
ConnectorServiceProto.SinkWriterStreamRequest.WriteBatch |
A protobuf message containing a batch of rows to be written to a sink |
| Direction | Type | Description |
|---|---|---|
| Output | CloseableIterable<SinkRow> |
An iterable of deserialized SinkRow objects that can be closed when consumption is complete
|
Contract:
- The implementation must convert each row in the
WriteBatchprotobuf message into aSinkRowinstance - The returned
CloseableIterablemust be closed after use to release any underlying resources - Each
SinkRowin the iterable must have a valid operation type (Op) and column values
Usage Examples
// Typical usage within a sink writer stream handler
Deserializer deserializer = new JsonDeserializer(tableSchema);
// Deserialize a WriteBatch received via gRPC
ConnectorServiceProto.SinkWriterStreamRequest.WriteBatch batch = request.getWrite();
try (CloseableIterable<SinkRow> rows = deserializer.deserialize(batch)) {
for (SinkRow row : rows) {
// Process each row
Data.Op op = row.getOp();
Object value = row.get(0);
}
}
Related Pages
- SinkRow Interface - The row objects produced by deserialization
- SinkWriterV1 Interface - Sink writers that consume deserialized rows
- TableSchema - Provides the schema information needed for deserialization
- SinkWriterStreamObserver OnNext - The gRPC handler that invokes deserialization on incoming write batches