You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by "David B. Martin" <da...@gmail.com> on 2012/02/28 00:41:31 UTC
When on HDFS, how do I detect schema of input paths?
I've been getting my feet wet writing pseduo-distributed code. In
that environment:
_____
File file = new File(input);
DatumReader<GenericRecord> reader = new
GenericDatumReader<GenericRecord>();
DataFileReader<GenericRecord> dataFileReader = new
DataFileReader<GenericRecord>(file, reader);
Schema s = dataFileReader.getSchema();
_____
Saying something like this works just fine. Now I have the schema of
my input and am ready for real action.
But on the HDFS, I have to work in terms of Path instances instead of
File instances. Right? I can't figure out how to perform the above
operation when my inputs are of type org.apache.hadoop.fs.Path and
not java.io.File.
Dave
Re: When on HDFS, how do I detect schema of input paths?
Posted by "David B. Martin" <da...@gmail.com>.
It looks like this will do the trick...
_____
FileSystem fs = etc.
FSDataInputStream dataInputStream = fs.open(firstInputPath);
DatumReader<GenericRecord> reader = new
GenericDatumReader<GenericRecord>();
DataFileStream<GenericRecord> dataFileStream = new
DataFileStream<GenericRecord>(dataInputStream, reader);
Schema s = dataFileStream.getSchema();
_____
On Mon, Feb 27, 2012 at 3:41 PM, David B. Martin <da...@gmail.com> wrote:
> I've been getting my feet wet writing pseduo-distributed code. In
> that environment:
>
> _____
>
> File file = new File(input);
> DatumReader<GenericRecord> reader = new
> GenericDatumReader<GenericRecord>();
> DataFileReader<GenericRecord> dataFileReader = new
> DataFileReader<GenericRecord>(file, reader);
>
> Schema s = dataFileReader.getSchema();
> _____
>
> Saying something like this works just fine. Now I have the schema of
> my input and am ready for real action.
>
> But on the HDFS, I have to work in terms of Path instances instead of
> File instances. Right? I can't figure out how to perform the above
> operation when my inputs are of type org.apache.hadoop.fs.Path and
> not java.io.File.
>
> Dave