Skip to content

Commit

Permalink
Got ByteComparable in there
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBorczuk committed Mar 31, 2022
1 parent 17b74dc commit 055f559
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
54 changes: 54 additions & 0 deletions persistence-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@
</parent>
<groupId>io.stargate.db</groupId>
<artifactId>persistence-test</artifactId>
<properties>
<dse.version>6.8.21</dse.version>
</properties>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>artifactory-snapshots</id>
<url>https://repo.datastax.com/datastax-snapshots-local</url>
</repository>
<repository>
<id>artifactory-releases</id>
<url>https://repo.datastax.com/datastax-releases-local</url>
</repository>
</repositories>
<dependencies>
<!-- Stargate component dependencies -->
<dependency>
Expand Down Expand Up @@ -57,5 +74,42 @@
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>

<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-core</artifactId>
<version>${dse.version}</version>
<exclusions>
<exclusion>
<groupId>org.gridkit.jvmtool</groupId>
<artifactId>sjk-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.cryptsoft</groupId>
<artifactId>kmip</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.logging</groupId>
<artifactId>cassandra-log4j-appender</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
</exclusion>
<!-- See https://github.com/stargate/stargate/issues/1200 -->
<exclusion>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
19 changes: 13 additions & 6 deletions persistence-test/src/main/java/io/stargate/it/PersistenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.jcip.annotations.NotThreadSafe;
import org.apache.cassandra.utils.ByteComparable;
import org.assertj.core.api.Assertions;
import org.javatuples.Pair;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -1984,12 +1985,18 @@ public void testRowDecoratorComparableBytes() throws ExecutionException, Interru
RowDecorator dec1 = rs1.makeRowDecorator();
List<Row> rows = rs1.rows();
if (backend.isDse()) {
List<ByteBuffer> allComparableBytes =
rows.stream().map(dec1::getComparableBytes).collect(Collectors.toList());
Collections.sort(allComparableBytes);
for (int idx = 0; idx < allComparableBytes.size(); idx++) {
ByteBuffer cb1 = allComparableBytes.get(idx);
ByteBuffer cb2 = dec1.getComparableBytes(rows.get(idx));
List<String> allComparableByteStrings =
rows.stream()
.map(dec1::getComparableBytes)
.map(ByteComparable::fixedLength)
.map(x -> x.byteComparableAsString(ByteComparable.Version.DSE68))
.collect(Collectors.toList());
Collections.sort(allComparableByteStrings);
for (int idx = 0; idx < allComparableByteStrings.size(); idx++) {
String cb1 = allComparableByteStrings.get(idx);
String cb2 =
ByteComparable.fixedLength(dec1.getComparableBytes(rows.get(idx)))
.byteComparableAsString(ByteComparable.Version.DSE68);
assertThat(cb1.compareTo(cb2)).isEqualTo(0);
}
}
Expand Down

0 comments on commit 055f559

Please sign in to comment.