@Override public long length() throws IOException { return in.length(); }
@Override public long length() throws IOException { return in.length(); }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
/** 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 long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }
@Override public long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }
expect(inputSplit.getPath()).andReturn(new Path("/path/to/an/avro/file")).anyTimes(); expect(inputSplit.getStart()).andReturn(0L).anyTimes(); expect(inputSplit.getLength()).andReturn(avroFileInput.length()).anyTimes();
expect(inputSplit.getPath()).andReturn(new Path("/path/to/an/avro/file")).anyTimes(); expect(inputSplit.getStart()).andReturn(0L).anyTimes(); expect(inputSplit.getLength()).andReturn(avroFileInput.length()).anyTimes();
@Override public long length() throws IOException { return in.length(); }
@Override public long length() throws IOException { return in.length(); }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
@Override public int available() throws IOException { long remaining = (in.length() - in.tell()); return (remaining > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) remaining; } }
@Override public long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }
@Override public long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }
@Override public long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }
@Override public long skip(long skip) throws IOException { long position = in.tell(); long length = in.length(); long remaining = length - position; if (remaining > skip) { in.seek(skip); return in.tell() - position; } else { in.seek(remaining); return in.tell() - position; } }