public int readProtobufStream(InputStream inputStream) throws IOException {
    DataInputStream stream = new DataInputStream(inputStream);
    CellSetModel model = null;
    int rowCount = 0;
    try {
      while (true) {
        byte[] lengthBytes = new byte[2];
        int readBytes = stream.read(lengthBytes);
        if (readBytes == -1) {
          break;
        }
        assertEquals(2, readBytes);
        int length = Bytes.toShort(lengthBytes);
        byte[] cellset = new byte[length];
        stream.read(cellset);
        model = new CellSetModel();
        model.getObjectFromMessage(cellset);
        checkRowsNotNull(model);
        rowCount = rowCount + TestScannerResource.countCellSet(model);
      }
    } catch (EOFException exp) {
      exp.printStackTrace();
    } finally {
      stream.close();
    }
    return rowCount;
  }
Read protobuf stream.
@param inputStream the input stream
@return The number of rows in the cell set model.
@throws IOException Signals that an I/O exception has occurred.
hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestTableScan.java