suxiaogang223 commented on code in PR #52598: URL: https://github.com/apache/doris/pull/52598#discussion_r2177605038
########## fe/be-java-extensions/paimon-scanner/src/main/java/org/apache/doris/paimon/PaimonSysTableJniScanner.java: ########## @@ -0,0 +1,195 @@ +// 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. + +package org.apache.doris.paimon; + +import org.apache.doris.common.jni.JniScanner; +import org.apache.doris.common.jni.vec.ColumnType; +import org.apache.doris.common.security.authentication.PreExecutionAuthenticator; +import org.apache.doris.common.security.authentication.PreExecutionAuthenticatorCache; + +import org.apache.paimon.data.InternalRow; +import org.apache.paimon.reader.RecordReader; +import org.apache.paimon.table.Table; +import org.apache.paimon.table.source.ReadBuilder; +import org.apache.paimon.table.source.Split; +import org.apache.paimon.types.DataType; +import org.apache.paimon.types.TimestampType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +/** + * JniScanner to read Paimon SysTables + */ +public class PaimonSysTableJniScanner extends JniScanner { + private static final Logger LOG = LoggerFactory.getLogger(PaimonSysTableJniScanner.class); + @Deprecated + private static final String HADOOP_OPTION_PREFIX = "hadoop."; + + private final Map<String, String> params; + @Deprecated + private final Map<String, String> hadoopOptionParams; + + private final ClassLoader classLoader; + private final Split paimonSplit; + private final Table table; + private RecordReader<InternalRow> reader; + private final PaimonColumnValue columnValue = new PaimonColumnValue(); + private List<DataType> paimonDataTypeList; + private final List<String> paimonAllFieldNames; + private final PreExecutionAuthenticator preExecutionAuthenticator; + private RecordReader.RecordIterator<InternalRow> recordIterator = null; + + public PaimonSysTableJniScanner(int batchSize, Map<String, String> params) { + this.classLoader = this.getClass().getClassLoader(); + if (LOG.isDebugEnabled()) { + LOG.debug("params:{}", params); + } + this.params = params; + String[] requiredFields = params.get("required_fields").split(","); + String[] requiredTypes = params.get("required_types").split("#"); + ColumnType[] columnTypes = new ColumnType[requiredTypes.length]; + for (int i = 0; i < requiredTypes.length; i++) { + columnTypes[i] = ColumnType.parseType(requiredFields[i], requiredTypes[i]); + } + initTableInfo(columnTypes, requiredFields, batchSize); + this.paimonSplit = PaimonUtils.deserialize(params.get("serialized_split")); + this.table = PaimonUtils.deserialize(params.get("serialized_table")); Review Comment: Try not to serialize the table object and send it over, as this will cause too much network overhead when there are many splits. Refer to PaimonJniReader for how to get the table in be jni reader ```java private void initTable() { if (params.containsKey("serialized_table")) { table = PaimonUtils.deserialize(params.get("serialized_table")); } else { // get PaimonTable from cache PaimonTableCacheKey key = new PaimonTableCacheKey(ctlId, dbId, tblId, paimonOptionParams, hadoopOptionParams, dbName, tblName); TableExt tableExt = PaimonTableCache.getTable(key); if (tableExt.getCreateTime() < lastUpdateTime) { LOG.warn("invalidate cache table:{}, localTime:{}, remoteTime:{}", key, tableExt.getCreateTime(), lastUpdateTime); PaimonTableCache.invalidateTableCache(key); tableExt = PaimonTableCache.getTable(key); } this.table = tableExt.getTable(); } paimonAllFieldNames = PaimonUtils.getFieldNames(this.table.rowType()); if (LOG.isDebugEnabled()) { LOG.debug("paimonAllFieldNames:{}", paimonAllFieldNames); } } ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
