2727import org .apache .pinot .segment .local .indexsegment .immutable .ImmutableSegmentImpl ;
2828import org .apache .pinot .segment .local .utils .HashUtils ;
2929import org .apache .pinot .segment .local .utils .RecordInfo ;
30- import org .apache .pinot .segment .local .utils .tablestate .TableState ;
30+ import org .apache .pinot .segment .local .utils .tablestate .TableStateUtils ;
3131import org .apache .pinot .segment .spi .IndexSegment ;
3232import org .apache .pinot .spi .config .table .HashFunction ;
3333import org .apache .pinot .spi .data .readers .PrimaryKey ;
@@ -51,8 +51,8 @@ public class PartitionDedupMetadataManagerTest {
5151
5252 @ BeforeClass
5353 public void init () {
54- MockedStatic mocked = mockStatic (TableState .class );
55- mocked .when (() -> TableState .isAllSegmentsLoaded (any (), any ())).thenReturn (true );
54+ MockedStatic mocked = mockStatic (TableStateUtils .class );
55+ mocked .when (() -> TableStateUtils .isAllSegmentsLoaded (any (), any ())).thenReturn (true );
5656 }
5757
5858 @ Test
@@ -61,38 +61,38 @@ public void verifyAddRemoveSegment() {
6161 PartitionDedupMetadataManager partitionDedupMetadataManager =
6262 new PartitionDedupMetadataManager (mock (HelixManager .class ), REALTIME_TABLE_NAME , null , 0 ,
6363 mock (ServerMetrics .class ), hashFunction );
64- Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeySet ;
64+ Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeyToSegmentMap ;
6565
6666 // Add the first segment
67- List <RecordInfo > recordInfoList1 = new ArrayList <>();
68- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 0 , null ));
69- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 1 , null ));
70- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (2 ), 2 , null ));
71- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 3 , null ));
72- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 4 , null ));
73- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 5 , null ));
67+ List <PrimaryKey > pkList1 = new ArrayList <>();
68+ pkList1 .add (getPrimaryKey (0 ));
69+ pkList1 .add (getPrimaryKey (1 ));
70+ pkList1 .add (getPrimaryKey (2 ));
71+ pkList1 .add (getPrimaryKey (0 ));
72+ pkList1 .add (getPrimaryKey (1 ));
73+ pkList1 .add (getPrimaryKey (0 ));
7474 ImmutableSegmentImpl segment1 = mockSegment (1 );
7575 MockedStatic mocked = mockStatic (PartitionDedupMetadataManager .class );
76- mocked .when (() -> PartitionDedupMetadataManager .getRecordInfoIterator (any (), any ()))
77- .thenReturn (recordInfoList1 .iterator ());
76+ mocked .when (() -> PartitionDedupMetadataManager .getPrimaryKeyIterator (any (), any ()))
77+ .thenReturn (pkList1 .iterator ());
7878
7979 partitionDedupMetadataManager .addSegment (segment1 );
8080 checkRecordLocation (recordLocationMap , 0 , segment1 , hashFunction );
8181 checkRecordLocation (recordLocationMap , 1 , segment1 , hashFunction );
8282 checkRecordLocation (recordLocationMap , 2 , segment1 , hashFunction );
8383
84- recordInfoList1 = new ArrayList <>();
85- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 0 , null ));
86- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 1 , null ));
87- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (2 ), 2 , null ));
88- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 3 , null ));
89- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 4 , null ));
90- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 5 , null ));
84+ pkList1 = new ArrayList <>();
85+ pkList1 .add (getPrimaryKey (0 ));
86+ pkList1 .add (getPrimaryKey (1 ));
87+ pkList1 .add (getPrimaryKey (2 ));
88+ pkList1 .add (getPrimaryKey (0 ));
89+ pkList1 .add (getPrimaryKey (1 ));
90+ pkList1 .add (getPrimaryKey (0 ));
9191
9292 mocked .close ();
9393 mocked = mockStatic (PartitionDedupMetadataManager .class );
94- mocked .when (() -> PartitionDedupMetadataManager .getRecordInfoIterator (any (), any ()))
95- .thenReturn (recordInfoList1 .iterator ());
94+ mocked .when (() -> PartitionDedupMetadataManager .getPrimaryKeyIterator (any (), any ()))
95+ .thenReturn (pkList1 .iterator ());
9696
9797 partitionDedupMetadataManager .removeSegment (segment1 );
9898 Assert .assertEquals (recordLocationMap .size (), 0 );
@@ -105,37 +105,37 @@ public void verifyReloadSegment() {
105105 PartitionDedupMetadataManager partitionDedupMetadataManager =
106106 new PartitionDedupMetadataManager (mock (HelixManager .class ), REALTIME_TABLE_NAME , null , 0 ,
107107 mock (ServerMetrics .class ), hashFunction );
108- Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeySet ;
108+ Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeyToSegmentMap ;
109109
110110 // Add the first segment
111- List <RecordInfo > recordInfoList1 = new ArrayList <>();
112- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 0 , null ));
113- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 1 , null ));
114- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (2 ), 2 , null ));
115- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 3 , null ));
116- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 4 , null ));
117- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 5 , null ));
111+ List <PrimaryKey > pkList1 = new ArrayList <>();
112+ pkList1 .add (getPrimaryKey (0 ));
113+ pkList1 .add (getPrimaryKey (1 ));
114+ pkList1 .add (getPrimaryKey (2 ));
115+ pkList1 .add (getPrimaryKey (0 ));
116+ pkList1 .add (getPrimaryKey (1 ));
117+ pkList1 .add (getPrimaryKey (0 ));
118118 ImmutableSegmentImpl segment1 = mockSegment (1 );
119119 MockedStatic mocked = mockStatic (PartitionDedupMetadataManager .class );
120- mocked .when (() -> PartitionDedupMetadataManager .getRecordInfoIterator (any (), any ()))
121- .thenReturn (recordInfoList1 .iterator ());
120+ mocked .when (() -> PartitionDedupMetadataManager .getPrimaryKeyIterator (any (), any ()))
121+ .thenReturn (pkList1 .iterator ());
122122
123123 partitionDedupMetadataManager .addSegment (segment1 );
124124
125125 // Remove another segment with same PK rows
126- recordInfoList1 = new ArrayList <>();
127- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 0 , null ));
128- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 1 , null ));
129- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (2 ), 2 , null ));
130- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 3 , null ));
131- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 4 , null ));
132- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 5 , null ));
126+ pkList1 = new ArrayList <>();
127+ pkList1 .add (getPrimaryKey (0 ));
128+ pkList1 .add (getPrimaryKey (1 ));
129+ pkList1 .add (getPrimaryKey (2 ));
130+ pkList1 .add (getPrimaryKey (0 ));
131+ pkList1 .add (getPrimaryKey (1 ));
132+ pkList1 .add (getPrimaryKey (0 ));
133133 ImmutableSegmentImpl segment2 = mockSegment (1 );
134134
135135 mocked .close ();
136136 mocked = mockStatic (PartitionDedupMetadataManager .class );
137- mocked .when (() -> PartitionDedupMetadataManager .getRecordInfoIterator (any (), any ()))
138- .thenReturn (recordInfoList1 .iterator ());
137+ mocked .when (() -> PartitionDedupMetadataManager .getPrimaryKeyIterator (any (), any ()))
138+ .thenReturn (pkList1 .iterator ());
139139
140140 partitionDedupMetadataManager .removeSegment (segment2 );
141141 Assert .assertEquals (recordLocationMap .size (), 3 );
@@ -153,38 +153,38 @@ public void verifyAddRow() {
153153 PartitionDedupMetadataManager partitionDedupMetadataManager =
154154 new PartitionDedupMetadataManager (mock (HelixManager .class ), REALTIME_TABLE_NAME , null , 0 ,
155155 mock (ServerMetrics .class ), hashFunction );
156- Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeySet ;
156+ Map <Object , IndexSegment > recordLocationMap = partitionDedupMetadataManager ._primaryKeyToSegmentMap ;
157157
158158 // Add the first segment
159- List <RecordInfo > recordInfoList1 = new ArrayList <>();
160- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 0 , null ));
161- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 1 , null ));
162- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (2 ), 2 , null ));
163- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 3 , null ));
164- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (1 ), 4 , null ));
165- recordInfoList1 .add (new RecordInfo ( getPrimaryKey (0 ), 5 , null ));
159+ List <PrimaryKey > pkList1 = new ArrayList <>();
160+ pkList1 .add (getPrimaryKey (0 ));
161+ pkList1 .add (getPrimaryKey (1 ));
162+ pkList1 .add (getPrimaryKey (2 ));
163+ pkList1 .add (getPrimaryKey (0 ));
164+ pkList1 .add (getPrimaryKey (1 ));
165+ pkList1 .add (getPrimaryKey (0 ));
166166 ImmutableSegmentImpl segment1 = mockSegment (1 );
167167 MockedStatic mocked = mockStatic (PartitionDedupMetadataManager .class );
168- mocked .when (() -> PartitionDedupMetadataManager .getRecordInfoIterator (any (), any ()))
169- .thenReturn (recordInfoList1 .iterator ());
168+ mocked .when (() -> PartitionDedupMetadataManager .getPrimaryKeyIterator (any (), any ()))
169+ .thenReturn (pkList1 .iterator ());
170170 partitionDedupMetadataManager .addSegment (segment1 );
171171 mocked .close ();
172172
173173 // Same PK exists
174174 RecordInfo recordInfo = mock (RecordInfo .class );
175175 when (recordInfo .getPrimaryKey ()).thenReturn (getPrimaryKey (0 ));
176176 ImmutableSegmentImpl segment2 = mockSegment (2 );
177- Assert .assertTrue (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo , segment2 ));
177+ Assert .assertTrue (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo . getPrimaryKey () , segment2 ));
178178 checkRecordLocation (recordLocationMap , 0 , segment1 , hashFunction );
179179
180180 // New PK
181181 when (recordInfo .getPrimaryKey ()).thenReturn (getPrimaryKey (3 ));
182- Assert .assertFalse (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo , segment2 ));
182+ Assert .assertFalse (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo . getPrimaryKey () , segment2 ));
183183 checkRecordLocation (recordLocationMap , 3 , segment2 , hashFunction );
184184
185185 // Same PK as the one recently ingested
186186 when (recordInfo .getPrimaryKey ()).thenReturn (getPrimaryKey (3 ));
187- Assert .assertTrue (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo , segment2 ));
187+ Assert .assertTrue (partitionDedupMetadataManager .checkRecordPresentOrUpdate (recordInfo . getPrimaryKey () , segment2 ));
188188 }
189189
190190 private static ImmutableSegmentImpl mockSegment (int sequenceNumber ) {
0 commit comments