this.in = new DataFileReader.SeekableInputStream(sin); in.read(magic); if (!Arrays.equals(MAGIC, magic)) throw new IOException("Not a data file."); long length = in.length(); in.seek(length-4); int footerSize=(in.read()<<24)+(in.read()<<16)+(in.read()<<8)+in.read(); seek(length-footerSize); long l = vin.readMapStart();
blockStart = sin.tell();
blockStart = sin.tell();
blockStart = sin.tell();
this.in = new DataFileReader.SeekableInputStream(sin); in.read(magic); if (!Arrays.equals(MAGIC, magic)) throw new IOException("Not a data file."); long length = in.length(); in.seek(length-4); int footerSize=(in.read()<<24)+(in.read()<<16)+(in.read()<<8)+in.read(); seek(length-footerSize); long l = vin.readMapStart();
this.in = new DataFileReader.SeekableInputStream(sin); in.read(magic); if (!Arrays.equals(MAGIC, magic)) throw new IOException("Not a data file."); long length = in.length(); in.seek(length-4); int footerSize=(in.read()<<24)+(in.read()<<16)+(in.read()<<8)+in.read(); seek(length-footerSize); long l = vin.readMapStart();
blockStart = sin.tell();
blockStart = sin.tell();
/** Move to the next synchronization point after a position. */ @Override public synchronized void sync(long position) throws IOException { if (in.tell()+SYNC_SIZE >= in.length()) { seek(in.length()); return; } in.seek(position); vin.readFixed(syncBuffer); for (int i = 0; in.tell() < in.length(); i++) { int j = 0; for (; j < sync.length; j++) { if (sync[j] != syncBuffer[(i+j)%sync.length]) break; } if (j == sync.length) { // position before sync seek(in.tell() - SYNC_SIZE); return; } syncBuffer[i%sync.length] = (byte)in.read(); } seek(in.length()); }
/** Move to the next synchronization point after a position. */ @Override public synchronized void sync(long position) throws IOException { if (in.tell()+SYNC_SIZE >= in.length()) { seek(in.length()); return; } in.seek(position); vin.readFixed(syncBuffer); for (int i = 0; in.tell() < in.length(); i++) { int j = 0; for (; j < sync.length; j++) { if (sync[j] != syncBuffer[(i+j)%sync.length]) break; } if (j == sync.length) { // position before sync seek(in.tell() - SYNC_SIZE); return; } syncBuffer[i%sync.length] = (byte)in.read(); } seek(in.length()); }
@Override public long tell() throws IOException { return sin.tell(); }
@Override public long tell() throws IOException { return sin.tell(); }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }
/** Return the current position in the input. */ @Override public long tell() throws IOException { return in.tell(); }
/** Return the next datum in the file. */ @Override public synchronized D next(D reuse) throws IOException { while (blockCount == 0) { // at start of block if (in.tell() == in.length()) // at eof return null; skipSync(); // skip a sync blockCount = vin.readLong(); // read blockCount if (blockCount == FOOTER_BLOCK) { seek(vin.readLong()+in.tell()); // skip a footer } } blockCount--; return reader.read(reuse, vin); }
/** Return the current position in the input. */ @Override public long tell() throws IOException { return in.tell(); }
@Override protected void blockFinished() throws IOException { blockStart = sin.tell() - vin.inputStream().available(); }
@Override protected void blockFinished() throws IOException { blockStart = sin.tell() - vin.inputStream().available(); }
/** Return true if past the next synchronization point after a position. */ public boolean pastSync(long position) throws IOException { return ((blockStart >= position+SYNC_SIZE)||(blockStart >= sin.length())); }
@Override protected void blockFinished() throws IOException { blockStart = sin.tell() - vin.inputStream().available(); }