Skip to content

Commit b0b03ff

Browse files
committed
done
1 parent 809d55f commit b0b03ff

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

fdb-extensions/src/main/java/com/apple/foundationdb/linear/ColumnMajorRealMatrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public double[][] getColumnMajorData() {
137137
@Nonnull
138138
@Override
139139
public RowMajorRealMatrix quickTranspose() {
140-
return new RowMajorRealMatrix(data);
140+
return new RowMajorRealMatrix(getColumnMajorData());
141141
}
142142

143143
@Nonnull

fdb-extensions/src/main/java/com/apple/foundationdb/linear/RowMajorRealMatrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public double[][] getColumnMajorData() {
137137
@Nonnull
138138
@Override
139139
public ColumnMajorRealMatrix quickTranspose() {
140-
return new ColumnMajorRealMatrix(data);
140+
return new ColumnMajorRealMatrix(getRowMajorData());
141141
}
142142

143143
@Nonnull

fdb-extensions/src/test/java/com/apple/foundationdb/async/hnsw/DataRecordsTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,33 @@ void testEntryNodeReference(final long randomSeed) {
9090
@RandomSeedSource({0x0fdbL, 0x5ca1eL, 123456L, 78910L, 1123581321345589L})
9191
void testNodeReference(final long randomSeed) {
9292
assertHashCodeEqualsToString(randomSeed, DataRecordsTest::nodeReference);
93+
final NodeReference nodeReference = nodeReference(new Random(randomSeed));
94+
Assertions.assertThat(nodeReference.isNodeReferenceWithVector()).isFalse();
95+
Assertions.assertThatThrownBy(nodeReference::asNodeReferenceWithVector).isInstanceOf(IllegalStateException.class);
9396
}
9497

9598
@ParameterizedTest
9699
@RandomSeedSource({0x0fdbL, 0x5ca1eL, 123456L, 78910L, 1123581321345589L})
97100
void testNodeReferenceWithVector(final long randomSeed) {
98101
assertHashCodeEqualsToString(randomSeed, DataRecordsTest::nodeReferenceWithVector);
102+
final NodeReferenceWithVector nodeReference = nodeReferenceWithVector(new Random(randomSeed));
103+
Assertions.assertThat(nodeReference.isNodeReferenceWithVector()).isTrue();
104+
Assertions.assertThat(nodeReference.asNodeReferenceWithVector()).isInstanceOf(NodeReferenceWithVector.class);
99105
}
100106

101107
@ParameterizedTest
102108
@RandomSeedSource({0x0fdbL, 0x5ca1eL, 123456L, 78910L, 1123581321345589L})
103109
void testNodeReferenceWithDistance(final long randomSeed) {
104110
assertHashCodeEqualsToString(randomSeed, DataRecordsTest::nodeReferenceWithDistance);
111+
final NodeReferenceWithDistance nodeReference = nodeReferenceWithDistance(new Random(randomSeed));
112+
Assertions.assertThat(nodeReference.isNodeReferenceWithVector()).isTrue();
113+
Assertions.assertThat(nodeReference.asNodeReferenceWithVector()).isInstanceOf(NodeReferenceWithDistance.class);
114+
}
115+
116+
@ParameterizedTest
117+
@RandomSeedSource({0x0fdbL, 0x5ca1eL, 123456L, 78910L, 1123581321345589L})
118+
void testResultEntry(final long randomSeed) {
119+
assertHashCodeEqualsToString(randomSeed, DataRecordsTest::resultEntry);
105120
}
106121

107122
private static <T> void assertHashCodeEqualsToString(final long randomSeed, final Function<Random, T> createFunction) {
@@ -118,6 +133,11 @@ private static <T> void assertHashCodeEqualsToString(final long randomSeed, fina
118133
Assertions.assertThat(t1.toString()).isNotEqualTo(t2.toString());
119134
}
120135

136+
@Nonnull
137+
private static ResultEntry resultEntry(@Nonnull final Random random) {
138+
return new ResultEntry(primaryKey(random), rawVector(random), random.nextDouble(), random.nextInt(100));
139+
}
140+
121141
@Nonnull
122142
private static CompactNode compactNode(@Nonnull final Random random) {
123143
return CompactNode.factory()

0 commit comments

Comments
 (0)