original_string: public function guess_antelope_row_size(array $columns) {
  
          if (empty($columns)) {
              return 0;
          }
  
          $size = 0;
          $first = reset($columns);
  
          if (count($columns) > 1) {
              // Do not start with zero because we need to cover changes of field types and
              // this calculation is most probably not be accurate.
              $size += 1000;
          }
  
          if ($first instanceof xmldb_field) {
              foreach ($columns as $field) {
                  switch ($field->getType()) {
                      case XMLDB_TYPE_TEXT:
                          $size += 768;
                          break;
                      case XMLDB_TYPE_BINARY:
                          $size += 768;
                          break;
                      case XMLDB_TYPE_CHAR:
                          $bytes = $field->getLength() * 3;
                          if ($bytes > 768) {
                              $bytes = 768;
                          }
                          $size += $bytes;
                          break;
                      default:
                          // Anything else is usually maximum 8 bytes.
                          $size += 8;
                  }
              }
  
          } else if ($first instanceof database_column_info) {
              foreach ($columns as $column) {
                  switch ($column->meta_type) {
                      case 'X':
                          $size += 768;
                          break;
                      case 'B':
                          $size += 768;
                          break;
                      case 'C':
                          $bytes = $column->max_length * 3;
                          if ($bytes > 768) {
                              $bytes = 768;
                          }
                          $size += $bytes;
                          break;
                      default:
                          // Anything else is usually maximum 8 bytes.
                          $size += 8;
                  }
              }
          }
  
          return $size;
      }
code: public function guess_antelope_row_size(array $columns) {
  
          if (empty($columns)) {
              return 0;
          }
  
          $size = 0;
          $first = reset($columns);
  
          if (count($columns) > 1) {
              // Do not start with zero because we need to cover changes of field types and
              // this calculation is most probably not be accurate.
              $size += 1000;
          }
  
          if ($first instanceof xmldb_field) {
              foreach ($columns as $field) {
                  switch ($field->getType()) {
                      case XMLDB_TYPE_TEXT:
                          $size += 768;
                          break;
                      case XMLDB_TYPE_BINARY:
                          $size += 768;
                          break;
                      case XMLDB_TYPE_CHAR:
                          $bytes = $field->getLength() * 3;
                          if ($bytes > 768) {
                              $bytes = 768;
                          }
                          $size += $bytes;
                          break;
                      default:
                          // Anything else is usually maximum 8 bytes.
                          $size += 8;
                  }
              }
  
          } else if ($first instanceof database_column_info) {
              foreach ($columns as $column) {
                  switch ($column->meta_type) {
                      case 'X':
                          $size += 768;
                          break;
                      case 'B':
                          $size += 768;
                          break;
                      case 'C':
                          $bytes = $column->max_length * 3;
                          if ($bytes > 768) {
                              $bytes = 768;
                          }
                          $size += $bytes;
                          break;
                      default:
                          // Anything else is usually maximum 8 bytes.
                          $size += 8;
                  }
              }
          }
  
          return $size;
      }
code_tokens: public function guess_antelope_row_size ( array $ columns ) { if ( empty ( $ columns ) ) { return 0 ; } $ size = 0 ; $ first = reset ( $ columns ) ; if ( count ( $ columns ) > 1 ) { // Do not start with zero because we need to cover changes of field types and // this calculation is most probably not be accurate. $ size += 1000 ; } if ( $ first instanceof xmldb_field ) { foreach ( $ columns as $ field ) { switch ( $ field -> getType ( ) ) { case XMLDB_TYPE_TEXT : $ size += 768 ; break ; case XMLDB_TYPE_BINARY : $ size += 768 ; break ; case XMLDB_TYPE_CHAR : $ bytes = $ field -> getLength ( ) * 3 ; if ( $ bytes > 768 ) { $ bytes = 768 ; } $ size += $ bytes ; break ; default : // Anything else is usually maximum 8 bytes. $ size += 8 ; } } } else if ( $ first instanceof database_column_info ) { foreach ( $ columns as $ column ) { switch ( $ column -> meta_type ) { case 'X' : $ size += 768 ; break ; case 'B' : $ size += 768 ; break ; case 'C' : $ bytes = $ column -> max_length * 3 ; if ( $ bytes > 768 ) { $ bytes = 768 ; } $ size += $ bytes ; break ; default : // Anything else is usually maximum 8 bytes. $ size += 8 ; } } } return $ size ; }
docstring: Calculate proximate row size when using InnoDB tables in Antelope row format.
  
  Note: the returned value is a bit higher to compensate for errors and changes of column data types.
  
  @param xmldb_field[]|database_column_info[] $columns
  @return int approximate row size in bytes
docstring_tokens: Calculate proximate row size when using InnoDB tables in Antelope row format .