wangzhigang1999 opened a new issue, #11378:
URL: https://github.com/apache/paimon/issues/11378

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   ### Motivation
   
   Query preparation is spread across the batch reader and the scoring 
routines, which makes it hard to tell how often a query is converted. When 
PyPaimon scans raw vectors or reranks index candidates, it scores the stored 
rows in blocks. The rows change from one block to the next, but the query 
vector and distance metric stay the same. The Python reader currently converts 
the query to a NumPy array again for each block. For cosine similarity, it also 
computes the query norm again.
   
   A small example is a 1,025-row scan with two-dimensional vectors. With two 
query vectors, the batch reader requests eight query-array conversions across 
the two scoring blocks. Preparing the two queries once would reduce that to two 
conversions for the same Top-K results.
   
   ### Solution
   
   Keep the scalar and NumPy scoring routines together in one module. Let the 
reader prepare the query after it resolves the metric. Reuse its float64 array 
and, for cosine similarity, its norm throughout that read. A Ray worker can do 
the same within its scoring task. A subsequent read should prepare the query 
again so that reusing a reader picks up changes to the input.
   
   ### Anything else?
   
   Tested locally against `3a8e01f35d` with single-query and batch-query exact 
search.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to