-
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.
Adds first working example of (in-memory) DEG with simple unit test
- Loading branch information
1 parent
41c0d71
commit bf0af0a
Showing
15 changed files
with
469 additions
and
104 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
...db-core/src/main/kotlin/org/vitrivr/cottontail/utilities/math/ranking/RankingUtilities.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,29 @@ | ||
package org.vitrivr.cottontail.utilities.math.ranking | ||
|
||
/** | ||
* | ||
* @author Ralph Gasser | ||
* @version 1.0.0 | ||
*/ | ||
object RankingUtilities { | ||
/** | ||
* Calculates the recall at k for a given [List] of retrieved and relevant items. Comparison is based on object equality. | ||
* | ||
* @param retrieved [List] of retrieved items. | ||
* @param relevant [List] of relevant items. | ||
* @param k The number of items to consider. | ||
*/ | ||
fun <V> recallAtK(retrieved: List<V>, relevant: List<V>, k: Int): Float { | ||
require(k > 0) { "Parameter k must be greater than 0." } | ||
require(retrieved.size >= k) { "Number of retrieved items must be greater than k." } | ||
require(relevant.size >= k) { "Number of relevant items must be greater than k." } | ||
var score = 0.0f | ||
for (i in 0 until k) { | ||
if (relevant.contains(retrieved[i])) { | ||
score += 1.0f | ||
} | ||
} | ||
return score/k | ||
} | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
...kotlin/org/vitrivr/cottontail/dbms/index/diskann/graph/InMemoryDynamicExplorationGraph.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
19 changes: 19 additions & 0 deletions
19
...tlin/org/vitrivr/cottontail/dbms/index/diskann/graph/PersistentDynamicExplorationGraph.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,19 @@ | ||
package org.vitrivr.cottontail.dbms.index.diskann.graph | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap | ||
import org.vitrivr.cottontail.utilities.graph.undirected.WeightedUndirectedInMemoryGraph | ||
|
||
/** | ||
* | ||
* @author Ralph Gasser | ||
* @version 1.0.0 | ||
*/ | ||
class PersistentDynamicExplorationGraph<I: Comparable<I>,V>(degree: Int, private val df: (V, V) -> Float): AbstractDynamicExplorationGraph<I,V>(degree, WeightedUndirectedInMemoryGraph(degree)) { | ||
private val vectors = Object2ObjectOpenHashMap<I,V>() | ||
override fun size(): Long = this.graph.size() | ||
override fun distance(a: V, b: V): Float = this.df(a, b) | ||
override fun loadVector(identifier: I): V = this.vectors[identifier] ?: throw NoSuchElementException("Could not find vector for identifier $identifier") | ||
override fun storeVector(identifier: I, vector: V) { | ||
this.vectors[identifier] = vector | ||
} | ||
} |
Oops, something went wrong.