TheR1sing3un commented on code in PR #9753:
URL: https://github.com/apache/paimon/pull/9753#discussion_r3998236561
##########
paimon-python/pypaimon/table/source/vector_search_read.py:
##########
@@ -588,13 +592,43 @@ def _read_batch(self, splits, snapshot):
raw_pre_filter = self._raw_pre_filter(raw_splits, snapshot)
raw_ranges = _raw_row_ranges(raw_splits)
raw_index_type = _raw_search_index_type(raw_splits)
- results = []
- for i in range(n):
- raw = self._read_raw_search(
- raw_ranges, raw_pre_filter, self._query_vectors[i],
raw_index_type,
- snapshot=snapshot)
- results.append(indexed_results[i].or_(raw).top_k(self._limit))
- return results
+ raw_results = self._read_raw_batch_search(
+ raw_ranges, raw_pre_filter, raw_index_type, snapshot)
+ return [
+ indexed.or_(raw).top_k(self._limit)
+ for indexed, raw in zip(indexed_results, raw_results)
+ ]
+
+ def _read_raw_batch_search(self, raw_row_ranges, pre_filter,
+ index_type=None, snapshot=None):
+ """Scan raw rows once, keeping a separate top-k heap for each query."""
+ from pypaimon.read.table_read import _ClosableArrowBatchReader
+
+ heaps = [[] for _ in self._query_vectors]
+ raw_row_ranges = _filtered_raw_row_ranges(raw_row_ranges, pre_filter)
+ if not raw_row_ranges or not heaps:
+ return [_scored_result(heap) for heap in heaps]
+
+ table_read, splits = self._plan_raw_read(raw_row_ranges, True,
snapshot)
+ reader, batches = table_read._new_arrow_batch_reader(splits)
Review Comment:
fix~
--
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]