Package org.apache.hadoop.hdfs.util

Examples of org.apache.hadoop.hdfs.util.ExactSizeInputStream


      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here


    }
   
    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
 
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

    }
   
    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
 
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

      throw new EOFException("Premature EOF: no length prefix available");
    }

    int size = CodedInputStream.readRawVarint32(firstByte, input);
    assert size >= 0;
    return new ExactSizeInputStream(input, size);
  }
View Full Code Here

import org.junit.Test;

public class TestExactSizeInputStream {
  @Test
  public void testBasicsReadSingle() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    assertEquals((int)'h', s.read());
    assertEquals((int)'e', s.read());
    assertEquals((int)'l', s.read());
    assertEquals(-1, s.read());
    assertEquals(0, s.available());
  }
View Full Code Here

    assertEquals(0, s.available());
  }
 
  @Test
  public void testBasicsReadArray() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    byte[] buf = new byte[10];
   
    assertEquals(2, s.read(buf, 0, 2));
    assertEquals('h', buf[0]);
    assertEquals('e', buf[1]);
   
    assertEquals(1, s.read(buf, 0, 2));
    assertEquals('l', buf[0]);
   
    assertEquals(-1, s.read(buf, 0, 2));
  }
View Full Code Here

    assertEquals(-1, s.read(buf, 0, 2));
  }
 
  @Test
  public void testBasicsSkip() throws IOException {
    ExactSizeInputStream s = new ExactSizeInputStream(byteStream("hello"), 3);
    assertEquals(3, s.available());
   
    assertEquals(2, s.skip(2));
    assertEquals(1, s.skip(2));
    assertEquals(0, s.skip(2));
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.util.ExactSizeInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.