-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ralph Gasser
committed
May 6, 2024
1 parent
cc23f28
commit 41c0d71
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/index/deg/InMemoryDEGTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.vitrivr.cottontail.dbms.index.deg | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.vitrivr.cottontail.core.database.TupleId | ||
import org.vitrivr.cottontail.core.queries.functions.math.distance.binary.EuclideanDistance | ||
import org.vitrivr.cottontail.core.types.Types | ||
import org.vitrivr.cottontail.core.values.FloatVectorValue | ||
import org.vitrivr.cottontail.core.values.generators.FloatVectorValueGenerator | ||
import org.vitrivr.cottontail.dbms.index.diskann.graph.InMemoryDynamicExplorationGraph | ||
import org.vitrivr.cottontail.test.TestConstants | ||
import java.util.* | ||
|
||
class InMemoryDEGTest { | ||
|
||
private val random = SplittableRandom() | ||
|
||
|
||
@Test | ||
public fun testWithFloatVector() { | ||
val size = random.nextInt(256) | ||
val type = Types.FloatVector(size) | ||
val distance = EuclideanDistance.FloatVector(type) | ||
val list = LinkedList<FloatVectorValue>() | ||
val graph = InMemoryDynamicExplorationGraph<TupleId, FloatVectorValue>(30) { v1, v2 -> distance.invoke(v1, v2).value.toFloat() } | ||
|
||
/* Build graph. */ | ||
repeat(TestConstants.TEST_COLLECTION_SIZE) { it -> | ||
val next = FloatVectorValueGenerator.random(size, this.random) | ||
list.add(next) | ||
graph.index(it.toLong(), next) | ||
} | ||
|
||
println("Done") | ||
} | ||
} |