[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
GitHub user twalthr opened a pull request:

    https://github.com/apache/incubator-flink/pull/32

    The Hadoop Compatibility has been refactored and extended to support the new Java API.

    Final PR of FLINK-777. Implements FLINK-611.
   
    Tested for Hadoop 1 and 2. Has been tested on cluster.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/twalthr/incubator-flink HadoopCompatibilityJAPIReady

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-flink/pull/32.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #32
   
----
commit 18da5d0edfa95337b69d02fc8f87b709d3f98c16
Author: twalthr <[hidden email]>
Date:   2014-05-07T00:54:29Z

    The Hadoop Compatibility has been refactored and extended to support the new Java API.

----


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/32#discussion_r14036891
 
    --- Diff: stratosphere-addons/hadoop-compatibility/src/main/java/eu/stratosphere/hadoopcompatibility/mapred/HadoopInputFormat.java ---
    @@ -0,0 +1,287 @@
    +/***********************************************************************************************************************
    + * Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
    + *
    + * Licensed 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 eu.stratosphere.hadoopcompatibility.mapred;
    +
    +import java.io.IOException;
    +import java.io.ObjectInputStream;
    +import java.io.ObjectOutputStream;
    +import java.util.ArrayList;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.io.Writable;
    +import org.apache.hadoop.mapred.FileInputFormat;
    +import org.apache.hadoop.mapred.JobConf;
    +import org.apache.hadoop.mapred.RecordReader;
    +import org.apache.hadoop.util.ReflectionUtils;
    +
    +import eu.stratosphere.api.common.io.FileInputFormat.FileBaseStatistics;
    +import eu.stratosphere.api.common.io.InputFormat;
    +import eu.stratosphere.api.common.io.statistics.BaseStatistics;
    +import eu.stratosphere.api.java.tuple.Tuple2;
    +import eu.stratosphere.api.java.typeutils.ResultTypeQueryable;
    +import eu.stratosphere.api.java.typeutils.TupleTypeInfo;
    +import eu.stratosphere.api.java.typeutils.WritableTypeInfo;
    +import eu.stratosphere.configuration.Configuration;
    +import eu.stratosphere.core.fs.FileStatus;
    +import eu.stratosphere.core.fs.FileSystem;
    +import eu.stratosphere.core.fs.Path;
    +import eu.stratosphere.hadoopcompatibility.mapred.utils.HadoopUtils;
    +import eu.stratosphere.hadoopcompatibility.mapred.wrapper.HadoopDummyReporter;
    +import eu.stratosphere.hadoopcompatibility.mapred.wrapper.HadoopInputSplit;
    +import eu.stratosphere.types.TypeInformation;
    +
    +public class HadoopInputFormat<K extends Writable, V extends Writable> implements InputFormat<Tuple2<K,V>, HadoopInputSplit>, ResultTypeQueryable<Tuple2<K,V>> {
    +
    + private static final long serialVersionUID = 1L;
    +
    + private static final Log LOG = LogFactory.getLog(HadoopInputFormat.class);
    +
    + private org.apache.hadoop.mapred.InputFormat<K, V> mapredInputFormat;
    + private Class<K> keyClass;
    + private Class<V> valueClass;
    + private JobConf jobConf;
    +
    + public transient K key;
    + public transient V value;
    +
    + public RecordReader<K, V> recordReader;
    --- End diff --
   
    we should mark the `recordReader` as transient as well. Even though we do custom serialization, it is helpful as a flag when reading the code (similar to key and value, the transient flag has actually no meaning here, since we do custom ser)


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
In reply to this post by zentol
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/32#discussion_r14036963
 
    --- Diff: stratosphere-addons/hadoop-compatibility/src/main/java/eu/stratosphere/hadoopcompatibility/mapred/HadoopInputFormat.java ---
    @@ -0,0 +1,287 @@
    +/***********************************************************************************************************************
    + * Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
    + *
    + * Licensed 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 eu.stratosphere.hadoopcompatibility.mapred;
    +
    +import java.io.IOException;
    +import java.io.ObjectInputStream;
    +import java.io.ObjectOutputStream;
    +import java.util.ArrayList;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.io.Writable;
    +import org.apache.hadoop.mapred.FileInputFormat;
    +import org.apache.hadoop.mapred.JobConf;
    +import org.apache.hadoop.mapred.RecordReader;
    +import org.apache.hadoop.util.ReflectionUtils;
    +
    +import eu.stratosphere.api.common.io.FileInputFormat.FileBaseStatistics;
    +import eu.stratosphere.api.common.io.InputFormat;
    +import eu.stratosphere.api.common.io.statistics.BaseStatistics;
    +import eu.stratosphere.api.java.tuple.Tuple2;
    +import eu.stratosphere.api.java.typeutils.ResultTypeQueryable;
    +import eu.stratosphere.api.java.typeutils.TupleTypeInfo;
    +import eu.stratosphere.api.java.typeutils.WritableTypeInfo;
    +import eu.stratosphere.configuration.Configuration;
    +import eu.stratosphere.core.fs.FileStatus;
    +import eu.stratosphere.core.fs.FileSystem;
    +import eu.stratosphere.core.fs.Path;
    +import eu.stratosphere.hadoopcompatibility.mapred.utils.HadoopUtils;
    +import eu.stratosphere.hadoopcompatibility.mapred.wrapper.HadoopDummyReporter;
    +import eu.stratosphere.hadoopcompatibility.mapred.wrapper.HadoopInputSplit;
    +import eu.stratosphere.types.TypeInformation;
    +
    +public class HadoopInputFormat<K extends Writable, V extends Writable> implements InputFormat<Tuple2<K,V>, HadoopInputSplit>, ResultTypeQueryable<Tuple2<K,V>> {
    +
    + private static final long serialVersionUID = 1L;
    +
    + private static final Log LOG = LogFactory.getLog(HadoopInputFormat.class);
    +
    + private org.apache.hadoop.mapred.InputFormat<K, V> mapredInputFormat;
    + private Class<K> keyClass;
    + private Class<V> valueClass;
    + private JobConf jobConf;
    +
    + public transient K key;
    + public transient V value;
    +
    + public RecordReader<K, V> recordReader;
    + private transient boolean fetched = false;
    + private transient boolean hasNext;
    +
    + public HadoopInputFormat() {
    + super();
    + }
    +
    + public HadoopInputFormat(org.apache.hadoop.mapred.InputFormat<K,V> mapredInputFormat, Class<K> key, Class<V> value, JobConf job) {
    + super();
    + this.mapredInputFormat = mapredInputFormat;
    + this.keyClass = key;
    + this.valueClass = value;
    + HadoopUtils.mergeHadoopConf(job);
    + this.jobConf = job;
    + }
    +
    + public void setJobConf(JobConf job) {
    + this.jobConf = job;
    + }
    +
    + public org.apache.hadoop.mapred.InputFormat<K,V> getHadoopInputFormat() {
    + return mapredInputFormat;
    + }
    +
    + public void setHadoopInputFormat(org.apache.hadoop.mapred.InputFormat<K,V> mapredInputFormat) {
    + this.mapredInputFormat = mapredInputFormat;
    + }
    +
    + public JobConf getJobConf() {
    + return jobConf;
    + }
    +
    + // --------------------------------------------------------------------------------------------
    + //  InputFormat
    + // --------------------------------------------------------------------------------------------
    +
    + @Override
    + public void configure(Configuration parameters) {
    + // nothing to do
    + }
    +
    + @Override
    + public BaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
    + // only gather base statistics for FileInputFormats
    + if(!(mapredInputFormat instanceof FileInputFormat)) {
    + return null;
    + }
    +
    + final FileBaseStatistics cachedFileStats = (cachedStats != null && cachedStats instanceof FileBaseStatistics) ?
    + (FileBaseStatistics) cachedStats : null;
    +
    + try {
    + final org.apache.hadoop.fs.Path[] paths = FileInputFormat.getInputPaths(this.jobConf);
    +
    + return getFileStats(cachedFileStats, paths, new ArrayList<FileStatus>(1));
    + } catch (IOException ioex) {
    + if (LOG.isWarnEnabled()) {
    + LOG.warn("Could not determine statistics due to an io error: "
    + + ioex.getMessage());
    + }
    + }
    + catch (Throwable t) {
    + if (LOG.isErrorEnabled()) {
    + LOG.error("Unexpected problen while getting the file statistics: "
    --- End diff --
   
    typo "problen".
    Also, the `catch` statement probably needs to move up to the closing bracket.


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
In reply to this post by zentol
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/32#discussion_r14037351
 
    --- Diff: stratosphere-addons/hadoop-compatibility/src/main/java/eu/stratosphere/hadoopcompatibility/mapreduce/HadoopInputFormat.java ---
    @@ -0,0 +1,337 @@
    +/***********************************************************************************************************************
    + * Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
    + *
    + * Licensed 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 eu.stratosphere.hadoopcompatibility.mapreduce;
    +
    +import java.io.IOException;
    +import java.io.ObjectInputStream;
    +import java.io.ObjectOutputStream;
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.io.Writable;
    +import org.apache.hadoop.mapreduce.Job;
    +import org.apache.hadoop.mapreduce.JobContext;
    +import org.apache.hadoop.mapreduce.JobID;
    +import org.apache.hadoop.mapreduce.RecordReader;
    +import org.apache.hadoop.mapreduce.TaskAttemptContext;
    +import org.apache.hadoop.mapreduce.TaskAttemptID;
    +import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    +
    +import eu.stratosphere.api.common.io.FileInputFormat.FileBaseStatistics;
    +import eu.stratosphere.api.common.io.InputFormat;
    +import eu.stratosphere.api.common.io.statistics.BaseStatistics;
    +import eu.stratosphere.api.java.tuple.Tuple2;
    +import eu.stratosphere.api.java.typeutils.ResultTypeQueryable;
    +import eu.stratosphere.api.java.typeutils.TupleTypeInfo;
    +import eu.stratosphere.api.java.typeutils.WritableTypeInfo;
    +import eu.stratosphere.configuration.Configuration;
    +import eu.stratosphere.core.fs.FileStatus;
    +import eu.stratosphere.core.fs.FileSystem;
    +import eu.stratosphere.core.fs.Path;
    +import eu.stratosphere.hadoopcompatibility.mapreduce.utils.HadoopUtils;
    +import eu.stratosphere.hadoopcompatibility.mapreduce.wrapper.HadoopInputSplit;
    +import eu.stratosphere.types.TypeInformation;
    +
    +public class HadoopInputFormat<K extends Writable, V extends Writable> implements InputFormat<Tuple2<K,V>, HadoopInputSplit>, ResultTypeQueryable<Tuple2<K,V>> {
    +
    + private static final long serialVersionUID = 1L;
    +
    + private static final Log LOG = LogFactory.getLog(HadoopInputFormat.class);
    +
    + private org.apache.hadoop.mapreduce.InputFormat<K, V> mapreduceInputFormat;
    + private Class<K> keyClass;
    + private Class<V> valueClass;
    + private org.apache.hadoop.conf.Configuration configuration;
    +
    + public transient RecordReader<K, V> recordReader;
    + private boolean fetched = false;
    + private boolean hasNext;
    +
    + public HadoopInputFormat() {
    + super();
    + }
    +
    + public HadoopInputFormat(org.apache.hadoop.mapreduce.InputFormat<K,V> mapreduceInputFormat, Class<K> key, Class<V> value, Job job) {
    + super();
    + this.mapreduceInputFormat = mapreduceInputFormat;
    + this.keyClass = key;
    + this.valueClass = value;
    + this.configuration = job.getConfiguration();
    + HadoopUtils.mergeHadoopConf(configuration);
    + }
    +
    + public void setConfiguration(org.apache.hadoop.conf.Configuration configuration) {
    + this.configuration = configuration;
    + }
    +
    + public org.apache.hadoop.mapreduce.InputFormat<K,V> getHadoopInputFormat() {
    + return this.mapreduceInputFormat;
    + }
    +
    + public void setHadoopInputFormat(org.apache.hadoop.mapreduce.InputFormat<K,V> mapreduceInputFormat) {
    + this.mapreduceInputFormat = mapreduceInputFormat;
    + }
    +
    + public org.apache.hadoop.conf.Configuration getConfiguration() {
    + return this.configuration;
    + }
    +
    + // --------------------------------------------------------------------------------------------
    + //  InputFormat
    + // --------------------------------------------------------------------------------------------
    +
    + @Override
    + public void configure(Configuration parameters) {
    + // nothing to do
    + }
    +
    + @Override
    + public BaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
    + // only gather base statistics for FileInputFormats
    + if(!(mapreduceInputFormat instanceof FileInputFormat)) {
    + return null;
    + }
    +
    + JobContext jobContext = null;
    + try {
    + jobContext = HadoopUtils.instantiateJobContext(configuration, null);
    + }
    + catch (Exception e) {
    + throw new RuntimeException(e);
    + }
    +
    + final FileBaseStatistics cachedFileStats = (cachedStats != null && cachedStats instanceof FileBaseStatistics) ?
    + (FileBaseStatistics) cachedStats : null;
    +
    + try {
    + final org.apache.hadoop.fs.Path[] paths = FileInputFormat.getInputPaths(jobContext);
    +
    + return getFileStats(cachedFileStats, paths, new ArrayList<FileStatus>(1));
    + } catch (IOException ioex) {
    + if (LOG.isWarnEnabled()) {
    + LOG.warn("Could not determine statistics due to an io error: "
    + + ioex.getMessage());
    + }
    + }
    + catch (Throwable t) {
    + if (LOG.isErrorEnabled()) {
    --- End diff --
   
    copy pasted typo


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
In reply to this post by zentol
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/incubator-flink/pull/32#discussion_r14037477
 
    --- Diff: stratosphere-addons/hadoop-compatibility/src/main/java/eu/stratosphere/hadoopcompatibility/mapreduce/example/WordCount.java ---
    @@ -0,0 +1,114 @@
    +/***********************************************************************************************************************
    --- End diff --
   
    Is it necessary to have two examples for both the "mapred" and "mapreduce" variant?


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-flink pull request: The Hadoop Compatibility has been re...

zentol
In reply to this post by zentol
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-flink/pull/32


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---