The schema is written inside an avro file. Thats why you don't need to provide it. You really need the schema to decode avro data. Either by providing a schema from somewhere and using a generic datum reader or by generating a "hardcoded" decoder that knows the schema from compile time.
regards svante 2015-03-25 11:10 GMT+01:00 Alexander Zenger <a.zen...@cetec.cc>: > Hi, > > > -----Ursprüngliche Nachricht----- > > Von: Rendy Bambang Junior [mailto:rendy.b.jun...@gmail.com] > > Gesendet: Mittwoch, 25. März 2015 10:08 > > An: user@avro.apache.org > > Betreff: Deserialize Avro Object Without Schema > > > > It should be possible right? Since the schema itself is embedded in the > data. > > > yes and it is working for me. Altough I'm reading data from a file, and I > create a > DataFileReader from the GenericDatumReader which then reads the > deserialized data. > On a quick look, I didn't find a FileReader for streams. > Here is my example: > > DatumReader<GenericRecord> datumReader = new > GenericDatumReader<GenericRecord>(); > DataFileReader<GenericRecord> dataFileReader = null; > try { > dataFileReader = new DataFileReader(DATA_FILE, datumReader); > } catch (IOException exp) { > System.out.println("Could not read file " + DATA_FILE.getName()); > System.exit(1); > } > > GenericRecord person = null; > try { > person = dataFileReader.next(person); > } catch (IOException exp) { > System.out.println("Could not read user from file " + > DATA_FILE.getName()); > System.exit(1); > } > > System.out.println("Id: " + person.get("id")); > System.out.println("Name: " + person.get("name")); > System.out.println("Email: " + person.get("email")); > > -- > Regards > Alexander Zenger > > >