|
31 | 31 | import com.linkedin.davinci.store.cache.backend.ObjectCacheBackend;
|
32 | 32 | import com.linkedin.davinci.store.record.ValueRecord;
|
33 | 33 | import com.linkedin.davinci.store.view.ChangeCaptureViewWriter;
|
| 34 | +import com.linkedin.davinci.store.view.MaterializedViewWriter; |
34 | 35 | import com.linkedin.davinci.store.view.VeniceViewWriter;
|
35 | 36 | import com.linkedin.davinci.validation.KafkaDataIntegrityValidator;
|
36 | 37 | import com.linkedin.davinci.validation.PartitionTracker;
|
@@ -203,6 +204,7 @@ public class LeaderFollowerStoreIngestionTask extends StoreIngestionTask {
|
203 | 204 |
|
204 | 205 | protected final Map<String, VeniceViewWriter> viewWriters;
|
205 | 206 | protected final boolean hasChangeCaptureView;
|
| 207 | + protected final boolean hasComplexVenicePartitionerMaterializedView; |
206 | 208 |
|
207 | 209 | protected final AvroStoreDeserializerCache<GenericRecord> storeDeserializerCache;
|
208 | 210 |
|
@@ -337,16 +339,22 @@ public LeaderFollowerStoreIngestionTask(
|
337 | 339 | version.getNumber(),
|
338 | 340 | schemaRepository.getKeySchema(store.getName()).getSchema());
|
339 | 341 | boolean tmpValueForHasChangeCaptureViewWriter = false;
|
| 342 | + boolean tmpValueForHasComplexVenicePartitioner = false; |
340 | 343 | for (Map.Entry<String, VeniceViewWriter> viewWriter: viewWriters.entrySet()) {
|
341 | 344 | if (viewWriter.getValue() instanceof ChangeCaptureViewWriter) {
|
342 | 345 | tmpValueForHasChangeCaptureViewWriter = true;
|
343 |
| - break; |
| 346 | + } else if (viewWriter.getValue() instanceof MaterializedViewWriter) { |
| 347 | + if (((MaterializedViewWriter) viewWriter.getValue()).isComplexVenicePartitioner()) { |
| 348 | + tmpValueForHasComplexVenicePartitioner = true; |
| 349 | + } |
344 | 350 | }
|
345 | 351 | }
|
346 | 352 | hasChangeCaptureView = tmpValueForHasChangeCaptureViewWriter;
|
| 353 | + hasComplexVenicePartitionerMaterializedView = tmpValueForHasComplexVenicePartitioner; |
347 | 354 | } else {
|
348 | 355 | viewWriters = Collections.emptyMap();
|
349 | 356 | hasChangeCaptureView = false;
|
| 357 | + hasComplexVenicePartitionerMaterializedView = false; |
350 | 358 | }
|
351 | 359 | this.storeDeserializerCache = new AvroStoreDeserializerCache(
|
352 | 360 | builder.getSchemaRepo(),
|
@@ -3297,7 +3305,7 @@ private PubSubMessageProcessedResult processMessage(
|
3297 | 3305 | update.updateValue,
|
3298 | 3306 | update.updateSchemaId,
|
3299 | 3307 | readerUpdateProtocolVersion);
|
3300 |
| - updatedValueBytes = writeComputeResult.getUpdatedValueBytes(); |
| 3308 | + updatedValueBytes = compressor.get().compress(writeComputeResult.getUpdatedValueBytes()); |
3301 | 3309 | hostLevelIngestionStats
|
3302 | 3310 | .recordWriteComputeUpdateLatency(LatencyUtils.getElapsedTimeFromNSToMS(writeComputeStartTimeInNS));
|
3303 | 3311 | } catch (Exception e) {
|
@@ -3342,24 +3350,29 @@ private PubSubMessageProcessedResult processMessage(
|
3342 | 3350 | Lazy.of(writeComputeResult::getUpdatedValue)));
|
3343 | 3351 | }
|
3344 | 3352 | case DELETE:
|
| 3353 | + Lazy<GenericRecord> oldValueProvider; |
| 3354 | + if (hasComplexVenicePartitionerMaterializedView) { |
| 3355 | + // Best-effort to provide the old value for delete operation in case needed by a ComplexVeniceWriter to |
| 3356 | + // generate deletes for materialized view topic partition(s). We need to do a non-lazy lookup before, so we |
| 3357 | + // have a chance of getting the old value before the transient record cache is updated to null as part of |
| 3358 | + // processing the DELETE. |
| 3359 | + int oldValueReaderSchemaId = schemaRepository.getSupersetSchema(storeName).getId(); |
| 3360 | + GenericRecord oldValue = readStoredValueRecord( |
| 3361 | + partitionConsumptionState, |
| 3362 | + keyBytes, |
| 3363 | + oldValueReaderSchemaId, |
| 3364 | + consumerRecord.getTopicPartition(), |
| 3365 | + new ChunkedValueManifestContainer()); |
| 3366 | + oldValueProvider = Lazy.of(() -> oldValue); |
| 3367 | + } else { |
| 3368 | + oldValueProvider = Lazy.of(() -> null); |
| 3369 | + } |
3345 | 3370 | /**
|
3346 | 3371 | * For WC enabled stores update the transient record map with the latest {key,null} for similar reason as mentioned in PUT above.
|
3347 | 3372 | */
|
3348 | 3373 | if (isWriteComputationEnabled && partitionConsumptionState.isEndOfPushReceived()) {
|
3349 | 3374 | partitionConsumptionState.setTransientRecord(kafkaClusterId, consumerRecord.getOffset(), keyBytes, -1, null);
|
3350 | 3375 | }
|
3351 |
| - // Best-effort to provide the old value for delete operation in case needed by a ComplexVeniceWriter to generate |
3352 |
| - // deletes for materialized view topic partition(s). |
3353 |
| - Lazy<GenericRecord> oldValueProvider = Lazy.of(() -> { |
3354 |
| - ChunkedValueManifestContainer oldValueManifestContainer = new ChunkedValueManifestContainer(); |
3355 |
| - int oldValueReaderSchemaId = schemaRepository.getSupersetSchema(storeName).getId(); |
3356 |
| - return readStoredValueRecord( |
3357 |
| - partitionConsumptionState, |
3358 |
| - keyBytes, |
3359 |
| - oldValueReaderSchemaId, |
3360 |
| - consumerRecord.getTopicPartition(), |
3361 |
| - oldValueManifestContainer); |
3362 |
| - }); |
3363 | 3376 | return new PubSubMessageProcessedResult(new WriteComputeResultWrapper(null, null, false, oldValueProvider));
|
3364 | 3377 |
|
3365 | 3378 | default:
|
|
0 commit comments