54
54
import org .apache .pinot .common .utils .TarCompressionUtils ;
55
55
import org .apache .pinot .core .data .manager .realtime .RealtimeConsumptionRateManager .ConsumptionRateLimiter ;
56
56
import org .apache .pinot .segment .local .data .manager .SegmentDataManager ;
57
+ import org .apache .pinot .segment .local .dedup .DedupContext ;
57
58
import org .apache .pinot .segment .local .dedup .PartitionDedupMetadataManager ;
58
59
import org .apache .pinot .segment .local .indexsegment .mutable .MutableSegmentImpl ;
59
60
import org .apache .pinot .segment .local .io .writer .impl .DirectMemoryManager ;
63
64
import org .apache .pinot .segment .local .segment .creator .TransformPipeline ;
64
65
import org .apache .pinot .segment .local .segment .index .loader .IndexLoadingConfig ;
65
66
import org .apache .pinot .segment .local .upsert .PartitionUpsertMetadataManager ;
67
+ import org .apache .pinot .segment .local .upsert .UpsertContext ;
66
68
import org .apache .pinot .segment .local .utils .IngestionUtils ;
67
69
import org .apache .pinot .segment .spi .MutableSegment ;
68
70
import org .apache .pinot .segment .spi .V1Constants ;
74
76
import org .apache .pinot .spi .config .instance .InstanceDataManagerConfig ;
75
77
import org .apache .pinot .spi .config .table .ColumnPartitionConfig ;
76
78
import org .apache .pinot .spi .config .table .CompletionConfig ;
77
- import org .apache .pinot .spi .config .table .DedupConfig ;
78
79
import org .apache .pinot .spi .config .table .IndexingConfig ;
79
80
import org .apache .pinot .spi .config .table .SegmentPartitionConfig ;
80
81
import org .apache .pinot .spi .config .table .SegmentZKPropsConfig ;
@@ -761,7 +762,7 @@ public void run() {
761
762
// persisted.
762
763
// Take upsert snapshot before starting consuming events
763
764
if (_partitionUpsertMetadataManager != null ) {
764
- if (_tableConfig . getUpsertMetadataTTL () > 0 ) {
765
+ if (_partitionUpsertMetadataManager . getContext (). getMetadataTTL () > 0 ) {
765
766
// If upsertMetadataTTL is enabled, we will remove expired primary keys from upsertMetadata
766
767
// AFTER taking a snapshot. Taking the snapshot first is crucial to capture the final
767
768
// state of each key before it exits the TTL window. Out-of-TTL segments are skipped in
@@ -779,7 +780,8 @@ public void run() {
779
780
}
780
781
}
781
782
782
- if (_partitionDedupMetadataManager != null && _tableConfig .getDedupMetadataTTL () > 0 ) {
783
+ if (_partitionDedupMetadataManager != null
784
+ && _partitionDedupMetadataManager .getContext ().getMetadataTTL () > 0 ) {
783
785
_partitionDedupMetadataManager .removeExpiredPrimaryKeys ();
784
786
}
785
787
@@ -1662,27 +1664,24 @@ public RealtimeSegmentDataManager(SegmentZKMetadata segmentZKMetadata, TableConf
1662
1664
1663
1665
// Start new realtime segment
1664
1666
String consumerDir = realtimeTableDataManager .getConsumerDir ();
1665
- RealtimeSegmentConfig .Builder realtimeSegmentConfigBuilder =
1666
- new RealtimeSegmentConfig .Builder (indexLoadingConfig ).setTableNameWithType (_tableNameWithType )
1667
- .setSegmentName (_segmentNameStr )
1668
- .setStreamName (streamTopic ).setSchema (_schema ).setTimeColumnName (timeColumnName )
1669
- .setCapacity (_segmentMaxRowCount ).setAvgNumMultiValues (indexLoadingConfig .getRealtimeAvgMultiValueCount ())
1670
- .setSegmentZKMetadata (segmentZKMetadata )
1671
- .setOffHeap (_isOffHeap ).setMemoryManager (_memoryManager )
1672
- .setStatsHistory (realtimeTableDataManager .getStatsHistory ())
1673
- .setAggregateMetrics (indexingConfig .isAggregateMetrics ())
1674
- .setIngestionAggregationConfigs (IngestionConfigUtils .getAggregationConfigs (tableConfig ))
1675
- .setDefaultNullHandlingEnabled (_defaultNullHandlingEnabled )
1676
- .setConsumerDir (consumerDir ).setUpsertMode (tableConfig .getUpsertMode ())
1677
- .setUpsertConsistencyMode (tableConfig .getUpsertConsistencyMode ())
1678
- .setPartitionUpsertMetadataManager (partitionUpsertMetadataManager )
1679
- .setUpsertComparisonColumns (tableConfig .getUpsertComparisonColumns ())
1680
- .setUpsertDeleteRecordColumn (tableConfig .getUpsertDeleteRecordColumn ())
1681
- .setUpsertOutOfOrderRecordColumn (tableConfig .getOutOfOrderRecordColumn ())
1682
- .setUpsertDropOutOfOrderRecord (tableConfig .isDropOutOfOrderRecord ())
1683
- .setPartitionDedupMetadataManager (partitionDedupMetadataManager )
1684
- .setDedupTimeColumn (tableConfig .getDedupTimeColumn ())
1685
- .setFieldConfigList (tableConfig .getFieldConfigList ());
1667
+ RealtimeSegmentConfig .Builder realtimeSegmentConfigBuilder = new RealtimeSegmentConfig .Builder (indexLoadingConfig )
1668
+ .setTableNameWithType (_tableNameWithType )
1669
+ .setSegmentName (_segmentNameStr )
1670
+ .setStreamName (streamTopic )
1671
+ .setSchema (_schema )
1672
+ .setTimeColumnName (timeColumnName )
1673
+ .setCapacity (_segmentMaxRowCount )
1674
+ .setAvgNumMultiValues (indexLoadingConfig .getRealtimeAvgMultiValueCount ())
1675
+ .setSegmentZKMetadata (segmentZKMetadata )
1676
+ .setOffHeap (_isOffHeap )
1677
+ .setMemoryManager (_memoryManager )
1678
+ .setStatsHistory (realtimeTableDataManager .getStatsHistory ())
1679
+ .setAggregateMetrics (indexingConfig .isAggregateMetrics ())
1680
+ .setIngestionAggregationConfigs (IngestionConfigUtils .getAggregationConfigs (tableConfig ))
1681
+ .setDefaultNullHandlingEnabled (_defaultNullHandlingEnabled )
1682
+ .setPartitionUpsertMetadataManager (partitionUpsertMetadataManager )
1683
+ .setPartitionDedupMetadataManager (partitionDedupMetadataManager )
1684
+ .setConsumerDir (consumerDir );
1686
1685
1687
1686
// Create message decoder
1688
1687
Set <String > fieldsToRead = IngestionUtils .getFieldsForRecordExtractor (_tableConfig , _schema );
@@ -1761,8 +1760,7 @@ public RealtimeSegmentDataManager(SegmentZKMetadata segmentZKMetadata, TableConf
1761
1760
}
1762
1761
}
1763
1762
1764
- @ VisibleForTesting
1765
- ParallelSegmentConsumptionPolicy getParallelConsumptionPolicy () {
1763
+ private ParallelSegmentConsumptionPolicy getParallelConsumptionPolicy () {
1766
1764
IngestionConfig ingestionConfig = _tableConfig .getIngestionConfig ();
1767
1765
ParallelSegmentConsumptionPolicy parallelSegmentConsumptionPolicy = null ;
1768
1766
boolean pauseless = false ;
@@ -1782,19 +1780,18 @@ ParallelSegmentConsumptionPolicy getParallelConsumptionPolicy() {
1782
1780
// - For pauseless tables, allow consumption during build, but disallow consumption during download
1783
1781
// - For non-pauseless tables, disallow consumption during build and download
1784
1782
// TODO: Revisit the non-pauseless handling
1785
- if (_realtimeTableDataManager . isDedupEnabled () ) {
1786
- DedupConfig dedupConfig = _tableConfig . getDedupConfig ();
1787
- assert dedupConfig != null ;
1788
- if ( dedupConfig . isAllowDedupConsumptionDuringCommit () ) {
1783
+ if (_partitionUpsertMetadataManager != null ) {
1784
+ UpsertContext upsertContext = _partitionUpsertMetadataManager . getContext ();
1785
+ if ( upsertContext . isAllowPartialUpsertConsumptionDuringCommit ()
1786
+ || upsertContext . getUpsertMode () != UpsertConfig . Mode . PARTIAL ) {
1789
1787
return ParallelSegmentConsumptionPolicy .ALLOW_ALWAYS ;
1790
1788
}
1791
1789
return pauseless ? ParallelSegmentConsumptionPolicy .ALLOW_DURING_BUILD_ONLY
1792
1790
: ParallelSegmentConsumptionPolicy .DISALLOW_ALWAYS ;
1793
1791
}
1794
- if (_realtimeTableDataManager .isPartialUpsertEnabled ()) {
1795
- UpsertConfig upsertConfig = _tableConfig .getUpsertConfig ();
1796
- assert upsertConfig != null ;
1797
- if (upsertConfig .isAllowPartialUpsertConsumptionDuringCommit ()) {
1792
+ if (_partitionDedupMetadataManager != null ) {
1793
+ DedupContext dedupContext = _partitionDedupMetadataManager .getContext ();
1794
+ if (dedupContext .isAllowDedupConsumptionDuringCommit ()) {
1798
1795
return ParallelSegmentConsumptionPolicy .ALLOW_ALWAYS ;
1799
1796
}
1800
1797
return pauseless ? ParallelSegmentConsumptionPolicy .ALLOW_DURING_BUILD_ONLY
0 commit comments