Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@irainia
Copy link
Member

@irainia irainia commented Jul 26, 2022

This PR is to fix and add additional implementations for the targetted branch, as the source branch is extended on it. This PR is related to this issue.

@irainia irainia mentioned this pull request Jul 26, 2022
4 tasks
@irainia irainia requested a review from sravankorumilli July 27, 2022 10:44
@irainia irainia marked this pull request as ready for review July 27, 2022 10:44
@irainia irainia linked an issue Jul 27, 2022 that may be closed by this pull request
2 tasks

func (w windowV1) GetSize() string {
return w.size
if w.size != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if defaults are set before hand at the time of initialization of window

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default value is being set in the implementation under method getFieldValues. if we move the default value into the constructor, then that constructor has to deal with two different default values, one for version 1 and another is for version 2. I believe the current constructor shouldn't handle such a thing.

however, if we really want to specify the default value during construction, we can create unexported constructors for window version 1 (and version 2 as well, if required). each of them will handle the default value for each one. meaning, the current constructor do not need to deal with it. for example:

NewWindow() {
  if version == 1 {
    newWindowV1()
  } else {
    newWindowV2()
}

// each constructor will specify default value

}

var truncateTo, offset, size string
if spec.Task.Window != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need this check? and these intermediate variables we can directly refer to the window variables

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to avoid panic. for example, the spec being used does not have Window field being configured, meaning it's nil. if we do not check it first and access the field Window, panic will hapen

}

version := spec.Version
if version == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be handled within the constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in case the job spec version is not specified. it's like a default value. the constructor's responsibility is construct a window based on valid inputs, or return error otherwise. if there's any invalid input such as version, I believe the constructor shouldn't assume the version of a spec. if there's a strong reason to do otherwise, then we need to at least change the function name to be not NewWindow

@sravankorumilli sravankorumilli force-pushed the window-versioning-extend branch from 3f5f3f2 to 3efac5f Compare August 18, 2022 15:17
@irainia irainia force-pushed the window-versioning-extend branch from 3efac5f to 617e630 Compare August 19, 2022 03:59
@sravankorumilli sravankorumilli force-pushed the window-versioning-extend branch from cf77f18 to a8a03a1 Compare August 29, 2022 07:10
@sravankorumilli sravankorumilli merged commit 1fd1785 into window-versioning Aug 29, 2022
@sravankorumilli sravankorumilli deleted the window-versioning-extend branch August 29, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

start and end times are not computed as per expectations

3 participants