Stephen0421 commented on code in PR #9148: URL: https://github.com/apache/paimon/pull/9148#discussion_r3773750771
########## paimon-python/pypaimon/read/reader/blob_view_read_support.py: ########## @@ -0,0 +1,53 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Helpers for eager blob-view/descriptor inline conversion on read.""" + +from typing import List + +from pypaimon.common.options.core_options import CoreOptions +from pypaimon.read.reader.iface.record_reader import RecordReader +from pypaimon.schema.data_types import DataField, PyarrowFieldParser + + +def needs_blob_inline_convert(table) -> bool: + return ( + (CoreOptions.blob_view_fields(table.options) + and CoreOptions.blob_view_resolve_enabled(table.options)) + or (not CoreOptions.blob_as_descriptor(table.options) + and CoreOptions.blob_descriptor_fields(table.options)) + ) + + +def wrap_record_reader_with_blob_inline_convert( + reader: RecordReader, + split_read, + read_fields: List[DataField], +) -> RecordReader: + from pypaimon.read.reader.auth_masking_reader import ( + BatchToRecordReaderAdapter, RecordReaderToBatchAdapter) + from pypaimon.read.reader.blob_descriptor_convert_reader import BlobInlineConvertReader + + schema = PyarrowFieldParser.from_paimon_schema(read_fields) + batch_reader = RecordReaderToBatchAdapter(reader, schema) + batch_reader = BlobInlineConvertReader( + batch_reader, + split_read.table, + prescan_reader_factory=lambda names: split_read._create_blob_view_prescan_reader(names), + blob_parallelism=split_read._blob_parallelism, + ) + return BatchToRecordReaderAdapter(batch_reader) Review Comment: Thanks. `BatchToRecordReaderAdapter` now copies `file_io`, BLOB/descriptor/vector indices, and the view lookup into every `OffsetRow`. `wrap_record_reader_with_blob_inline_convert` also sets that metadata on the batch adapter. Added wrap + adapter roundtrip coverage, including merge `to_iterator() + get_blob()`. -- 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]
