@@ -14,64 +14,6 @@ internal sealed unsafe partial class MigrateSession : IDisposable
14
14
{
15
15
internal sealed class MigrationKeyIterationFunctions
16
16
{
17
- internal struct MainStoreMigrateSlots : IScanIteratorFunctions < SpanByte , SpanByte >
18
- {
19
- readonly MigrateSession session ;
20
- readonly HashSet < int > slots ;
21
-
22
- internal MainStoreMigrateSlots ( MigrateSession session , HashSet < int > slots )
23
- {
24
- this . session = session ;
25
- this . slots = slots ;
26
- }
27
-
28
- public bool SingleReader ( ref SpanByte key , ref SpanByte value , RecordMetadata recordMetadata , long numberOfRecords , out CursorRecordResult cursorRecordResult )
29
- {
30
- cursorRecordResult = CursorRecordResult . Accept ; // default; not used here
31
- var s = HashSlotUtils . HashSlot ( ref key ) ;
32
-
33
- if ( slots . Contains ( s ) && ! ClusterSession . Expired ( ref value ) && ! session . WriteOrSendMainStoreKeyValuePair ( ref key , ref value ) )
34
- return false ;
35
- return true ;
36
- }
37
- public bool ConcurrentReader ( ref SpanByte key , ref SpanByte value , RecordMetadata recordMetadata , long numberOfRecords , out CursorRecordResult cursorRecordResult )
38
- => SingleReader ( ref key , ref value , recordMetadata , numberOfRecords , out cursorRecordResult ) ;
39
- public bool OnStart ( long beginAddress , long endAddress ) => true ;
40
- public void OnStop ( bool completed , long numberOfRecords ) { }
41
- public void OnException ( Exception exception , long numberOfRecords ) { }
42
- }
43
-
44
- internal struct ObjectStoreMigrateSlots : IScanIteratorFunctions < byte [ ] , IGarnetObject >
45
- {
46
- readonly MigrateSession session ;
47
- readonly HashSet < int > slots ;
48
-
49
- internal ObjectStoreMigrateSlots ( MigrateSession session , HashSet < int > slots )
50
- {
51
- this . session = session ;
52
- this . slots = slots ;
53
- }
54
-
55
- public bool SingleReader ( ref byte [ ] key , ref IGarnetObject value , RecordMetadata recordMetadata , long numberOfRecords , out CursorRecordResult cursorRecordResult )
56
- {
57
- cursorRecordResult = CursorRecordResult . Accept ; // default; not used here
58
- var slot = HashSlotUtils . HashSlot ( key ) ;
59
-
60
- if ( slots . Contains ( slot ) && ! ClusterSession . Expired ( ref value ) )
61
- {
62
- byte [ ] objectData = GarnetObjectSerializer . Serialize ( value ) ;
63
- if ( ! session . WriteOrSendObjectStoreKeyValuePair ( key , objectData , value . Expiration ) )
64
- return false ;
65
- }
66
- return true ;
67
- }
68
- public bool ConcurrentReader ( ref byte [ ] key , ref IGarnetObject value , RecordMetadata recordMetadata , long numberOfRecords , out CursorRecordResult cursorRecordResult )
69
- => SingleReader ( ref key , ref value , recordMetadata , numberOfRecords , out cursorRecordResult ) ;
70
- public bool OnStart ( long beginAddress , long endAddress ) => true ;
71
- public void OnStop ( bool completed , long numberOfRecords ) { }
72
- public void OnException ( Exception exception , long numberOfRecords ) { }
73
- }
74
-
75
17
internal unsafe struct MainStoreGetKeysInSlots : IScanIteratorFunctions < SpanByte , SpanByte >
76
18
{
77
19
MigrationScanIterator iterator ;
@@ -148,7 +90,6 @@ public void OnStop(bool completed, long numberOfRecords) { }
148
90
public void OnException ( Exception exception , long numberOfRecords ) { }
149
91
}
150
92
151
-
152
93
internal struct MigrationScanIterator
153
94
{
154
95
readonly MigrateSession session ;
@@ -198,8 +139,9 @@ public void AdvanceIterator()
198
139
/// <returns></returns>
199
140
public bool Consume ( ref Span < byte > key )
200
141
{
201
- // Check if key is within the current processing window
202
- if ( currentOffset < offset )
142
+ // Check if key is within the current processing window only if _copyOption is set
143
+ // in order to skip keys that have been send over to target node but not deleted locally
144
+ if ( session . _copyOption && currentOffset < offset )
203
145
{
204
146
currentOffset ++ ;
205
147
return true ;
0 commit comments