Skip to content

Commit

Permalink
Introduced minor optimization during execution of LSH based queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppanopticon committed May 6, 2020
1 parent 5e06565 commit d139ced
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ class SuperBitLSHIndex<T : VectorValue<*>>(name: Name, parent: Entity, columns:
val bucket: Int = lsh.hash(query).last()
val tupleIds = this.map[bucket]
if (tupleIds != null) {
tx.readMany(tupleIds = tupleIds.toList()).forEach {
val value = it[predicate.column]
tupleIds.forEach {
val record = tx.read(it)
val value = record[predicate.column]
if (value is VectorValue<*>) {
if (predicate.weights != null) {
knn.add(ComparablePair(it.tupleId, predicate.distance(query, value, predicate.weights[i])))
knn.add(ComparablePair(it, predicate.distance(query, value, predicate.weights[i])))
} else {
knn.add(ComparablePair(it.tupleId, predicate.distance(query, value)))
knn.add(ComparablePair(it, predicate.distance(query, value)))
}
}
}
Expand Down

0 comments on commit d139ced

Please sign in to comment.