All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netease.arctic.hive.io.reader.AdaptHiveGenericArcticDataReader Maven / Gradle / Ivy

The newest version!
/*
 * 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 com.netease.arctic.hive.io.reader;

import com.netease.arctic.data.DataTreeNode;
import com.netease.arctic.iceberg.optimize.InternalRecordWrapper;
import com.netease.arctic.io.ArcticFileIO;
import com.netease.arctic.io.reader.AbstractArcticDataReader;
import com.netease.arctic.table.PrimaryKeySpec;
import com.netease.arctic.utils.map.StructLikeCollections;
import com.netease.arctic.shade.org.apache.iceberg.Schema;
import com.netease.arctic.shade.org.apache.iceberg.StructLike;
import com.netease.arctic.shade.org.apache.iceberg.data.Record;
import com.netease.arctic.shade.org.apache.iceberg.data.parquet.AdaptHiveGenericParquetReaders;
import com.netease.arctic.shade.org.apache.iceberg.parquet.ParquetValueReader;
import com.netease.arctic.shade.org.apache.iceberg.types.Type;
import com.netease.arctic.shade.org.apache.parquet.schema.MessageType;

import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;

/**
 * Implementation of {@link AbstractArcticDataReader} with record type {@link Record}.
 */
public class AdaptHiveGenericArcticDataReader extends AbstractAdaptHiveArcticDataReader {

  public AdaptHiveGenericArcticDataReader(
      ArcticFileIO fileIO,
      Schema tableSchema,
      Schema projectedSchema,
      PrimaryKeySpec primaryKeySpec,
      String nameMapping,
      boolean caseSensitive,
      BiFunction convertConstant,
      Set sourceNodes,
      boolean reuseContainer,
      StructLikeCollections structLikeCollections) {
    super(fileIO, tableSchema, projectedSchema, primaryKeySpec, nameMapping, caseSensitive, convertConstant,
        sourceNodes, reuseContainer, structLikeCollections);
  }

  public AdaptHiveGenericArcticDataReader(
      ArcticFileIO fileIO,
      Schema tableSchema,
      Schema projectedSchema,
      PrimaryKeySpec primaryKeySpec,
      String nameMapping,
      boolean caseSensitive,
      BiFunction convertConstant) {
    super(fileIO, tableSchema, projectedSchema, primaryKeySpec, nameMapping, caseSensitive, convertConstant, false);
  }

  public AdaptHiveGenericArcticDataReader(
      ArcticFileIO fileIO,
      Schema tableSchema,
      Schema projectedSchema,
      PrimaryKeySpec primaryKeySpec,
      String nameMapping,
      boolean caseSensitive,
      BiFunction convertConstant,
      Set sourceNodes, boolean reuseContainer) {
    super(fileIO, tableSchema, projectedSchema, primaryKeySpec,
        nameMapping, caseSensitive, convertConstant, sourceNodes, reuseContainer);
  }

  @Override
  protected Function> getNewReaderFunction(
      Schema projectSchema,
      Map idToConstant) {
    return fileSchema -> AdaptHiveGenericParquetReaders.buildReader(projectSchema, fileSchema, idToConstant);
  }

  @Override
  protected Function> toStructLikeFunction() {
    return schema -> record -> new InternalRecordWrapper(schema.asStruct()).wrap(record);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy