@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
/** Open a reader for a file. */ public static <D> FileReader<D> openReader(SeekableInput in, DatumReader<D> reader) throws IOException { if (in.length() < MAGIC.length) throw new IOException("Not an Avro data file"); // read magic header byte[] magic = new byte[MAGIC.length]; in.seek(0); for (int c = 0; c < magic.length; c = in.read(magic, c, magic.length-c)) {} in.seek(0); if (Arrays.equals(MAGIC, magic)) // current format return new DataFileReader<D>(in, reader); if (Arrays.equals(DataFileReader12.MAGIC, magic)) // 1.2 format return new DataFileReader12<D>(in, reader); throw new IOException("Not an Avro data file"); }
/** Open a reader for a file. */ public static <D> FileReader<D> openReader(SeekableInput in, DatumReader<D> reader) throws IOException { if (in.length() < MAGIC.length) throw new InvalidAvroMagicException("Not an Avro data file"); // read magic header byte[] magic = new byte[MAGIC.length]; in.seek(0); for (int c = 0; c < magic.length; c = in.read(magic, c, magic.length-c)) {} in.seek(0); if (Arrays.equals(MAGIC, magic)) // current format return new DataFileReader<>(in, reader); if (Arrays.equals(DataFileReader12.MAGIC, magic)) // 1.2 format return new DataFileReader12<>(in, reader); throw new InvalidAvroMagicException("Not an Avro data file"); }
@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
@Override public void seek(long p) throws IOException { if (p < 0) throw new IOException("Illegal seek: " + p); in.seek(p); }
/** Open a reader for a file. */ public static <D> FileReader<D> openReader(SeekableInput in, DatumReader<D> reader) throws IOException { if (in.length() < MAGIC.length) throw new IOException("Not an Avro data file"); // read magic header byte[] magic = new byte[MAGIC.length]; in.seek(0); for (int c = 0; c < magic.length; c = in.read(magic, c, magic.length-c)) {} in.seek(0); if (Arrays.equals(MAGIC, magic)) // current format return new DataFileReader<D>(in, reader); if (Arrays.equals(DataFileReader12.MAGIC, magic)) // 1.2 format return new DataFileReader12<D>(in, reader); throw new IOException("Not an Avro data file"); }
/** Open a reader for a file. */ public static <D> FileReader<D> openReader(SeekableInput in, DatumReader<D> reader) throws IOException { if (in.length() < MAGIC.length) throw new IOException("Not an Avro data file"); // read magic header byte[] magic = new byte[MAGIC.length]; in.seek(0); for (int c = 0; c < magic.length; c = in.read(magic, c, magic.length-c)) {} in.seek(0); if (Arrays.equals(MAGIC, magic)) // current format return new DataFileReader<D>(in, reader); if (Arrays.equals(DataFileReader12.MAGIC, magic)) // 1.2 format return new DataFileReader12<D>(in, reader); throw new IOException("Not an Avro data file"); }