Package com.linkedin.davinci.consumer
Class VeniceChangelogConsumerDaVinciRecordTransformerImpl.DaVinciRecordTransformerChangelogConsumer
java.lang.Object
com.linkedin.davinci.client.DaVinciRecordTransformer<K,V,V>
com.linkedin.davinci.consumer.VeniceChangelogConsumerDaVinciRecordTransformerImpl.DaVinciRecordTransformerChangelogConsumer
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
- VeniceChangelogConsumerDaVinciRecordTransformerImpl<K,
V>
public class VeniceChangelogConsumerDaVinciRecordTransformerImpl.DaVinciRecordTransformerChangelogConsumer
extends DaVinciRecordTransformer<K,V,V>
-
Constructor Summary
ConstructorsConstructorDescriptionDaVinciRecordTransformerChangelogConsumer(String storeName, int storeVersion, org.apache.avro.Schema keySchema, org.apache.avro.Schema inputValueSchema, org.apache.avro.Schema outputValueSchema, DaVinciRecordTransformerConfig recordTransformerConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddControlMessageToBuffer(int partitionId, PubSubPosition offset, ControlMessage controlMessage) Add ControlMessage to the buffer.voidaddMessageToBuffer(K key, V value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Add ChangeCapturePubSubMessage to the buffer based on record metadata.voidclose()voidonControlMessage(int partitionId, PubSubPosition offset, ControlMessage controlMessage) If includeControlMessages is FALSE, or the client is NOT version specific, this method is a no-op.voidonHeartbeat(int partitionId, long heartbeatTimestamp) Receive heartbeat timestamp for a partition and update latest seen time.voidonStartVersionIngestion(int partitionId, boolean isCurrentVersion) Callback invoked before consuming records forDaVinciRecordTransformer.storeVersion.voidonVersionSwap(int currentVersion, int futureVersion, int partitionId) voidprocessDelete(Lazy<K> key, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Optional callback for delete events (for example, remove from an external system).voidprocessPut(Lazy<K> key, Lazy<V> value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Callback for put/update events (for example, write to an external system).transform(Lazy<K> key, Lazy<V> value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Callback to transform records before they are stored.Methods inherited from class com.linkedin.davinci.client.DaVinciRecordTransformer
getAlwaysBootstrapFromVersionTopic, getClassHash, getInputValueSchema, getKeySchema, getOutputValueSchema, getRecordTransformerUtility, getStoreName, getStoreRecordsInDaVinci, getStoreVersion, onEndVersionIngestion, onRecovery, prependSchemaIdToHeader, prependSchemaIdToHeader, transformAndProcessPut, useUniformInputValueSchema
-
Constructor Details
-
DaVinciRecordTransformerChangelogConsumer
public DaVinciRecordTransformerChangelogConsumer(String storeName, int storeVersion, org.apache.avro.Schema keySchema, org.apache.avro.Schema inputValueSchema, org.apache.avro.Schema outputValueSchema, DaVinciRecordTransformerConfig recordTransformerConfig)
-
-
Method Details
-
onStartVersionIngestion
public void onStartVersionIngestion(int partitionId, boolean isCurrentVersion) Description copied from class:DaVinciRecordTransformerCallback invoked before consuming records forDaVinciRecordTransformer.storeVersion. Use this to open connections, create tables, or initialize resources. By default, it's a no-op.- Overrides:
onStartVersionIngestionin classDaVinciRecordTransformer<K,V, V> - Parameters:
partitionId- what partition is being subscribedisCurrentVersion- whether the version being started is the current serving version; if not it's a future version
-
transform
public DaVinciRecordTransformerResult<V> transform(Lazy<K> key, Lazy<V> value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Description copied from class:DaVinciRecordTransformerCallback to transform records before they are stored. This can be useful for tasks such as filtering out unused fields to save storage space. Result types: - SKIP: drop the record - UNCHANGED: keep the original value; useful when only callbacks/notifications are needed - TRANSFORMED: record has been transformed and should be persisted to disk- Specified by:
transformin classDaVinciRecordTransformer<K,V, V> - Parameters:
key- the key of the record to be transformedvalue- the value of the record to be transformedpartitionId- what partition the record came fromrecordMetadata- returnsDaVinciRecordTransformerRecordMetadataif enabled inDaVinciRecordTransformerConfig, null otherwise- Returns:
DaVinciRecordTransformerResult
-
addMessageToBuffer
public void addMessageToBuffer(K key, V value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Add ChangeCapturePubSubMessage to the buffer based on record metadata. -
addControlMessageToBuffer
public void addControlMessageToBuffer(int partitionId, PubSubPosition offset, ControlMessage controlMessage) Add ControlMessage to the buffer. Key and Value are both null. Details for control message are in controlMessage param. -
processPut
public void processPut(Lazy<K> key, Lazy<V> value, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Description copied from class:DaVinciRecordTransformerCallback for put/update events (for example, write to an external system). Invoked afterDaVinciRecordTransformer.transform(Lazy, Lazy, int, DaVinciRecordTransformerRecordMetadata)when the result is UNCHANGED or TRANSFORMED. Also invoked during startup/recovery when Da Vinci replays records persisted on disk to rehydrate external systems.- Specified by:
processPutin classDaVinciRecordTransformer<K,V, V> - Parameters:
key- the key of the record to be putvalue- the value of the record to be put, either the original value or the transformed valuepartitionId- what partition the record came fromrecordMetadata- returnsDaVinciRecordTransformerRecordMetadataif enabled inDaVinciRecordTransformerConfig, null otherwise.
-
processDelete
public void processDelete(Lazy<K> key, int partitionId, DaVinciRecordTransformerRecordMetadata recordMetadata) Description copied from class:DaVinciRecordTransformerOptional callback for delete events (for example, remove from an external system). By default, this is a no-op.- Overrides:
processDeletein classDaVinciRecordTransformer<K,V, V> - Parameters:
key- the key of the record to be deletedpartitionId- what partition the record is being deleted fromrecordMetadata- returnsDaVinciRecordTransformerRecordMetadataif enabled inDaVinciRecordTransformerConfig, null otherwise.
-
onControlMessage
If includeControlMessages is FALSE, or the client is NOT version specific, this method is a no-op. If includeControlMessages is true, AND the client is version specific, it adds the control message to the buffer. -
onVersionSwap
public void onVersionSwap(int currentVersion, int futureVersion, int partitionId) -
onHeartbeat
public void onHeartbeat(int partitionId, long heartbeatTimestamp) Receive heartbeat timestamp for a partition and update latest seen time. -
close
- Throws:
IOException
-