Merge branch 'cassandra-5.0' into trunk

This commit is contained in:
Ariel Weisberg 2025-03-14 14:05:19 -04:00
commit bac5548fbc
2 changed files with 13 additions and 2 deletions

View File

@ -179,7 +179,7 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
public static final Comparator<SSTableReader> maxTimestampAscending = Comparator.comparingLong(SSTableReader::getMaxTimestamp);
public static final Comparator<SSTableReader> maxTimestampDescending = maxTimestampAscending.reversed();
private static final TimeUUID.Generator.Factory<UniqueIdentifier> UNIQUE_IDENTIFIER_FACTORY = new TimeUUID.Generator.Factory<UniqueIdentifier>()
public static final TimeUUID.Generator.Factory<UniqueIdentifier> UNIQUE_IDENTIFIER_FACTORY = new TimeUUID.Generator.Factory<UniqueIdentifier>()
{
@Override
public UniqueIdentifier atUnixMicrosWithLsb(long unixMicros, long clockSeqAndNode)
@ -197,6 +197,7 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
super(unixMicros, clockSeqAndNode);
}
}
public final UniqueIdentifier instanceId = TimeUUID.Generator.nextTimeUUID(UNIQUE_IDENTIFIER_FACTORY);
public static final Comparator<SSTableReader> firstKeyComparator = (o1, o2) -> o1.getFirst().compareTo(o2.getFirst());
@ -1868,11 +1869,17 @@ public abstract class SSTableReader extends SSTable implements UnfilteredSource,
boolean isOffline,
IVerifier.Options options);
public UniqueIdentifier instanceId()
{
return instanceId;
}
@Override
public int compareTo(SSTableReader other)
{
// Used in IntervalTree with the expecation that compareTo uniquely identifies an SSTableReader
return instanceId.compareTo(other.instanceId);
// Use accessor for instanceId for mocks
return instanceId().compareTo(other.instanceId());
}
/**

View File

@ -66,12 +66,14 @@ import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.Interval;
import org.apache.cassandra.utils.Overlaps;
import org.apache.cassandra.utils.Pair;
import org.apache.cassandra.utils.TimeUUID;
import org.apache.cassandra.utils.concurrent.Transactional;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.apache.cassandra.io.sstable.format.SSTableReader.UNIQUE_IDENTIFIER_FACTORY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -1053,6 +1055,8 @@ public class UnifiedCompactionStrategyTest
when(ret.getFirst()).thenReturn(first);
when(ret.getLast()).thenReturn(last);
when(ret.getInterval()).thenReturn(new Interval<>(first, last, ret));
when(ret.instanceId()).thenReturn(TimeUUID.Generator.nextTimeUUID(UNIQUE_IDENTIFIER_FACTORY));
when(ret.compareTo(any())).thenCallRealMethod();
when(ret.isMarkedSuspect()).thenReturn(false);
when(ret.isRepaired()).thenReturn(false);
when(ret.getRepairedAt()).thenReturn(repairedAt);