Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9097#discussion_r42200659
  
    --- Diff: 
sql/hive/src/main/java/org/apache/spark/sql/hive/mapred/CombineSplitRecordReader.java
 ---
    @@ -0,0 +1,128 @@
    +/*
    + * 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.spark.sql.hive.mapred;
    +
    +import java.io.IOException;
    +
    +import org.apache.hadoop.classification.InterfaceAudience;
    +import org.apache.hadoop.classification.InterfaceStability;
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.hadoop.mapred.InputFormat;
    +import org.apache.hadoop.mapred.JobConf;
    +import org.apache.hadoop.mapred.RecordReader;
    +import org.apache.hadoop.mapred.Reporter;
    +
    +/**
    + * A generic RecordReader that can hand out different recordReaders
    + * for each split in a {@link 
org.apache.spark.sql.hive.mapred.CombineSplit}.
    + */
    +@InterfaceAudience.Public
    +@InterfaceStability.Stable
    +public class CombineSplitRecordReader<K, V> implements RecordReader<K, V> {
    +  protected CombineSplit split;
    +  protected JobConf jc;
    +  protected FileSystem fs;
    +
    +  protected int idx;
    +  protected long progress;
    +  protected RecordReader<K, V> curReader;
    +
    +  @Override
    +  public boolean next(K key, V value) throws IOException {
    +    while ((curReader == null) || !curReader.next(key, value)) {
    +      if (!initNextRecordReader()) {
    +        return false;
    +      }
    +    }
    +    return true;
    +  }
    +
    +  public K createKey() {
    +    return curReader.createKey();
    +  }
    +
    +  public V createValue() {
    +    return curReader.createValue();
    +  }
    +
    +  /**
    +   * return the amount of data processed
    +   */
    +  public long getPos() throws IOException {
    +    return progress;
    +  }
    +
    +  public void close() throws IOException {
    +    if (curReader != null) {
    +      curReader.close();
    +      curReader = null;
    +    }
    +  }
    +
    +  /**
    +   * return progress based on the amount of data processed so far.
    +   */
    +  public float getProgress() throws IOException {
    +    return Math.min(1.0f,  progress/(float)(split.getLength()));
    +  }
    +  private InputFormat<K, V> inputFormat;
    --- End diff --
    
    Move this ahead? Put all of the class members together?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to