You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by vivek <vi...@gmail.com> on 2017/06/22 04:42:07 UTC

Different input format based on files names in driver code

Hi,
I have two different files having different names.I want to input files
depending upon the name of the file and use different input format for both
the files.
Eg

If i have two files  abc_file1 and bcd_file2
In the same input folder And i want to use textinputformat for file1 and
someother format for file2 base on their names(abc and bcd).
Is this possible in same driver code.

Please suggest incase somebody has any idea


Thanks,
Vk

Re: Different input format based on files names in driver code

Posted by Ankit Singhal <an...@gmail.com>.
You can create a list of files for each type and use MultipleInputs[1].

https://hadoop.apache.org/docs/r2.6.3/api/org/apache/hadoop/mapreduce/lib/input/MultipleInputs.html


On Thu, Jun 22, 2017 at 10:30 PM, vivek <vi...@gmail.com> wrote:

> Thanks!
>
>
> On Jun 22, 2017 20:15, "Erik Krogen" <ek...@linkedin.com> wrote:
>
>> You would need to write a custom InputFormat which would return an
>> appropriate RecordReader based on the file format involved in each
>> InputSplit. You can have InputFormat#getSplits load InputSplits for both
>> file types and have InputFormat#createRecordReader() delegate to the two
>> different InputFormats.
>>
>> Erik
>>
>> On Wed, Jun 21, 2017 at 9:42 PM, vivek <vi...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>> I have two different files having different names.I want to input files
>>> depending upon the name of the file and use different input format for both
>>> the files.
>>> Eg
>>>
>>> If i have two files  abc_file1 and bcd_file2
>>> In the same input folder And i want to use textinputformat for file1 and
>>> someother format for file2 base on their names(abc and bcd).
>>> Is this possible in same driver code.
>>>
>>> Please suggest incase somebody has any idea
>>>
>>>
>>> Thanks,
>>> Vk
>>>
>>
>>

Re: Different input format based on files names in driver code

Posted by Ankit Singhal <an...@gmail.com>.
You can create a list of files for each type and use MultipleInputs[1].

https://hadoop.apache.org/docs/r2.6.3/api/org/apache/hadoop/mapreduce/lib/input/MultipleInputs.html


On Thu, Jun 22, 2017 at 10:30 PM, vivek <vi...@gmail.com> wrote:

> Thanks!
>
>
> On Jun 22, 2017 20:15, "Erik Krogen" <ek...@linkedin.com> wrote:
>
>> You would need to write a custom InputFormat which would return an
>> appropriate RecordReader based on the file format involved in each
>> InputSplit. You can have InputFormat#getSplits load InputSplits for both
>> file types and have InputFormat#createRecordReader() delegate to the two
>> different InputFormats.
>>
>> Erik
>>
>> On Wed, Jun 21, 2017 at 9:42 PM, vivek <vi...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>> I have two different files having different names.I want to input files
>>> depending upon the name of the file and use different input format for both
>>> the files.
>>> Eg
>>>
>>> If i have two files  abc_file1 and bcd_file2
>>> In the same input folder And i want to use textinputformat for file1 and
>>> someother format for file2 base on their names(abc and bcd).
>>> Is this possible in same driver code.
>>>
>>> Please suggest incase somebody has any idea
>>>
>>>
>>> Thanks,
>>> Vk
>>>
>>
>>

Re: Different input format based on files names in driver code

Posted by vivek <vi...@gmail.com>.
Thanks!


On Jun 22, 2017 20:15, "Erik Krogen" <ek...@linkedin.com> wrote:

> You would need to write a custom InputFormat which would return an
> appropriate RecordReader based on the file format involved in each
> InputSplit. You can have InputFormat#getSplits load InputSplits for both
> file types and have InputFormat#createRecordReader() delegate to the two
> different InputFormats.
>
> Erik
>
> On Wed, Jun 21, 2017 at 9:42 PM, vivek <vi...@gmail.com> wrote:
>
>>
>> Hi,
>> I have two different files having different names.I want to input files
>> depending upon the name of the file and use different input format for both
>> the files.
>> Eg
>>
>> If i have two files  abc_file1 and bcd_file2
>> In the same input folder And i want to use textinputformat for file1 and
>> someother format for file2 base on their names(abc and bcd).
>> Is this possible in same driver code.
>>
>> Please suggest incase somebody has any idea
>>
>>
>> Thanks,
>> Vk
>>
>
>

Re: Different input format based on files names in driver code

Posted by vivek <vi...@gmail.com>.
Thanks!


On Jun 22, 2017 20:15, "Erik Krogen" <ek...@linkedin.com> wrote:

> You would need to write a custom InputFormat which would return an
> appropriate RecordReader based on the file format involved in each
> InputSplit. You can have InputFormat#getSplits load InputSplits for both
> file types and have InputFormat#createRecordReader() delegate to the two
> different InputFormats.
>
> Erik
>
> On Wed, Jun 21, 2017 at 9:42 PM, vivek <vi...@gmail.com> wrote:
>
>>
>> Hi,
>> I have two different files having different names.I want to input files
>> depending upon the name of the file and use different input format for both
>> the files.
>> Eg
>>
>> If i have two files  abc_file1 and bcd_file2
>> In the same input folder And i want to use textinputformat for file1 and
>> someother format for file2 base on their names(abc and bcd).
>> Is this possible in same driver code.
>>
>> Please suggest incase somebody has any idea
>>
>>
>> Thanks,
>> Vk
>>
>
>

Re: Different input format based on files names in driver code

Posted by Erik Krogen <ek...@linkedin.com.INVALID>.
You would need to write a custom InputFormat which would return an
appropriate RecordReader based on the file format involved in each
InputSplit. You can have InputFormat#getSplits load InputSplits for both
file types and have InputFormat#createRecordReader() delegate to the two
different InputFormats.

Erik

On Wed, Jun 21, 2017 at 9:42 PM, vivek <vi...@gmail.com> wrote:

>
> Hi,
> I have two different files having different names.I want to input files
> depending upon the name of the file and use different input format for both
> the files.
> Eg
>
> If i have two files  abc_file1 and bcd_file2
> In the same input folder And i want to use textinputformat for file1 and
> someother format for file2 base on their names(abc and bcd).
> Is this possible in same driver code.
>
> Please suggest incase somebody has any idea
>
>
> Thanks,
> Vk
>