Skip to content

Commit

Permalink
VectorDescriptorReader now uses a LinkedHashMaps to maintain insertio…
Browse files Browse the repository at this point in the history
…n order of entries.
  • Loading branch information
ppanopticon committed Feb 1, 2025
1 parent d00cbf4 commit 9359f3b
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.vitrivr.engine.database.pgvector.descriptor.model.PgBitVector
import org.vitrivr.engine.database.pgvector.descriptor.model.PgVector
import java.sql.ResultSet
import java.util.*
import kotlin.collections.LinkedHashMap

/**
* An abstract implementation of a [DescriptorReader] for Cottontail DB.
Expand Down Expand Up @@ -116,7 +117,7 @@ class VectorDescriptorReader(field: Schema.Field<*, VectorDescriptor<*, *>>, con
* @return [Sequence] of [VectorDescriptor]s.
*/
private fun queryAndJoinProximity(query: ProximityQuery<*>): Sequence<Retrieved> {
val fetched = mutableMapOf<RetrievableId, MutableList<Pair<VectorDescriptor<*,*>,Float>>>()
val fetched = LinkedHashMap<RetrievableId, MutableList<Pair<VectorDescriptor<*,*>,Float>>>()
val statement = "SELECT $DESCRIPTOR_ID_COLUMN_NAME, $RETRIEVABLE_ID_COLUMN_NAME, $VECTOR_ATTRIBUTE_NAME, $VECTOR_ATTRIBUTE_NAME ${query.distance.toSql()} ? AS $DISTANCE_COLUMN_NAME FROM \"${tableName.lowercase()}\" ORDER BY $VECTOR_ATTRIBUTE_NAME ${query.distance.toSql()} ? ${query.order} LIMIT ${query.k}"
this@VectorDescriptorReader.connection.jdbc.prepareStatement(statement).use { stmt ->
stmt.setValue(1, query.value)
Expand Down

0 comments on commit 9359f3b

Please sign in to comment.