[ 
https://issues.apache.org/jira/browse/FLINK-5133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15882747#comment-15882747
 ] 

ASF GitHub Bot commented on FLINK-5133:
---------------------------------------

Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3303#discussion_r102946206
  
    --- Diff: 
flink-streaming-scala/src/main/scala/org/apache/flink/streaming/api/scala/DataStream.scala
 ---
    @@ -144,6 +145,43 @@ class DataStream[T](stream: JavaStream[T]) {
         this
       }
     
    +
    +  /**
    +   * Returns the minimum resource of this operation.
    +   */
    +  def getMinResource: ResourceSpec = stream.getMinResource()
    +
    +  /**
    +   * Returns the maximum resource of this operation.
    +   */
    +  def getMaxResource: ResourceSpec = stream.getMaxResource()
    +
    +  /**
    +   * Sets the minimum and maximum resources of this operation.
    +   */
    +  def setResource(minResource: ResourceSpec, maxResource: ResourceSpec): 
DataStream[T] = {
    +    stream match {
    +      case ds: SingleOutputStreamOperator[T] => 
ds.setResource(minResource, maxResource)
    +      case _ =>
    +        throw new UnsupportedOperationException(
    +          "Operator " + stream + " cannot set the resource.")
    +    }
    +    this
    +  }
    +
    +  /**
    +   * Sets the resource of this operation.
    +   */
    +  def setResource(resource: ResourceSpec): DataStream[T] = {
    --- End diff --
    
    The more Scala-like way of writing this would be
    ```scala
    def resource_=(resource: ResourceSpec): Unit = {
        ...
    }
    ```
    That way you can write Scala code like this (and it will translate to the 
setter call):
    ```scala
    val stream: DataStream[MyType] = ...
    stream.resource = new Resource(a, b, c, d)
    ```
    (We have missed that in most places in Flink so far, but it may make sense 
to start picking up the proper Scala style for new changed)


> Support to set resource for operator in DataStream and DataSet
> --------------------------------------------------------------
>
>                 Key: FLINK-5133
>                 URL: https://issues.apache.org/jira/browse/FLINK-5133
>             Project: Flink
>          Issue Type: Sub-task
>          Components: DataSet API, DataStream API
>            Reporter: zhijiang
>            Assignee: zhijiang
>
> This is part of the fine-grained resource configuration.
> For *DataStream*, the *setResource* API will be setted onto 
> *SingleOutputStreamOperator* similar with other existing properties like 
> parallelism, name, etc.
> For *DataSet*, the *setResource* API will be setted onto *Operator* in the 
> similar way.
> There are two parameters described with minimum *ResourceSpec* and maximum 
> *ResourceSpec* separately in the API for considering resource resize in 
> future improvements.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to