public static FastInputStream wrap(InputStream in) { return (in instanceof FastInputStream) ? (FastInputStream)in : new FastInputStream(in); }
@Override public void readFully(byte b[]) throws IOException { readFully(b, 0, b.length); }
protected FastInputStream initRead(InputStream is) throws IOException { assert !alreadyUnmarshalled; FastInputStream dis = FastInputStream.wrap(is); version = dis.readByte(); if (version != VERSION) { throw new RuntimeException("Invalid version (expected " + VERSION + ", but " + version + ") or the data in not in 'javabin' format"); } alreadyUnmarshalled = true; return dis; }
public Object readVal(FastInputStream dis) throws IOException { tagByte = dis.readByte(); case DATE : return new Date(dis.readLong()); case INT : return dis.readInt(); case BOOL_TRUE : return Boolean.TRUE; case BOOL_FALSE : return Boolean.FALSE; case FLOAT : return dis.readFloat(); case DOUBLE : return dis.readDouble(); case LONG : return dis.readLong(); case BYTE : return dis.readByte(); case SHORT : return dis.readShort(); case MAP : return readMap(dis); case SOLRDOC : return readSolrDocument(dis);
@Override public int read() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos++] & 0xff; }
@Override public char readChar() throws IOException { return (char)((readUnsignedByte() << 8) | readUnsignedByte()); }
@Override public boolean readBoolean() throws IOException { return readByte()==1; }
int ret = readWrappedStream(b, off+r, len-r); if (ret >= 0) { readFromStream += ret; refill();
/** Reads UTF-8 encoded characters into an array. * @param buffer the array to read characters into * @param start the offset in the array to start storing characters * @param length the number of characters to read * @see org.apache.lucene.store.IndexOutput#writeChars(String,int,int) */ public static void readChars(FastInputStream in, char[] buffer, int start, int length) throws IOException { final int end = start + length; for (int i = start; i < end; i++) { int b = in.read(); if ((b & 0x80) == 0) buffer[i] = (char)b; else if ((b & 0xE0) != 0xE0) { buffer[i] = (char)(((b & 0x1F) << 6) | (in.read() & 0x3F)); } else buffer[i] = (char)(((b & 0x0F) << 12) | ((in.read() & 0x3F) << 6) | (in.read() & 0x3F)); } }
@Override public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
@Override public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
public void refill() throws IOException { // this will set end to -1 at EOF end = readWrappedStream(buf, 0, buf.length); if (end > 0) readFromStream += end; pos = 0; }
public int peek() throws IOException { if (pos >= end) { refill(); if (pos >= end) return -1; } return buf[pos] & 0xff; }
@Override public int readUnsignedShort() throws IOException { return (readUnsignedByte() << 8) | readUnsignedByte(); }
int ret = readWrappedStream(b, off+r, len-r); if (ret >= 0) { readFromStream += ret; refill();
@Override public void readFully(byte b[], int off, int len) throws IOException { while (len>0) { int ret = read(b, off, len); if (ret==-1) { throw new EOFException(); } off += ret; len -= ret; } }
@Override public float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
@Override public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
public void refill() throws IOException { // this will set end to -1 at EOF end = readWrappedStream(buf, 0, buf.length); if (end > 0) readFromStream += end; pos = 0; }