JingsongLi commented on code in PR #9753:
URL: https://github.com/apache/paimon/pull/9753#discussion_r3996200052
##########
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:
[P2] Preserve split-read parallelism in the shared scan
`_new_arrow_batch_reader` iterates splits serially and does not apply
`read.parallelism`. The previous `_read_raw_search` used `TableRead.to_arrow`,
which honors that option and automatically parallelizes multiple splits. Thus
batches with one or a few queries on remote multi-split tables become slower
even when users configured parallel reads. Through `execute_batch_local()` on a
real four-partition Parquet table with `read.parallelism=4` and 150 ms injected
split-open latency, one query changed from 160 ms / 4 concurrent opens to 626
ms / 1; two queries changed from 321 ms to 634 ms, with identical IDs and
scores. Please preserve bounded split concurrency (and merge per-query Top-K
state) while sharing the scan, with a multi-split regression that checks
concurrency and result equivalence. The acknowledged serial-reader tradeoff
currently discards an effective read configuration in this public API.
--
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]