Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public class TopKProcessor
private final ReadCommand command;
private final IndexContext indexContext;
private final RowFilter.Expression expression;
private final VectorFloat<?> queryVector;
private final ColumnMetadata scoreColumn;
// Lazily compute this value, if needed.
private VectorFloat<?> queryVector = null;

private final int limit;

Expand All @@ -109,10 +110,6 @@ public TopKProcessor(ReadCommand command)

this.indexContext = indexAndExpression.left;
this.expression = indexAndExpression.right;
if (expression.operator() == Operator.ANN && !(Ordering.Ann.useSyntheticScore() && expression.column().isRegular()))
this.queryVector = vts.createFloatVector(TypeUtil.decomposeVector(indexContext, expression.getIndexValue().duplicate()));
else
this.queryVector = null;
this.limit = command.limits().count();
this.scoreColumn = ColumnMetadata.syntheticScoreColumn(expression.column(), FloatType.instance);
}
Expand Down Expand Up @@ -329,6 +326,8 @@ private float getScoreForRow(DecoratedKey key, Row row)
ByteBuffer value = indexContext.getValueOf(key, row, FBUtilities.nowInSeconds());
if (value != null)
{
if (queryVector == null)
queryVector = vts.createFloatVector(TypeUtil.decomposeVector(indexContext, expression.getIndexValue().duplicate()));
var vector = vts.createFloatVector(TypeUtil.decomposeVector(indexContext, value));
return indexContext.getIndexWriterConfig().getSimilarityFunction().compare(vector, queryVector);
}
Expand Down
Loading