Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add picker to pick value from record #246

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

veezhang
Copy link
Contributor

@veezhang veezhang commented Dec 9, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

Ref #245

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

@veezhang veezhang force-pushed the feat branch 2 times, most recently from bddedbf to 9aa677d Compare December 13, 2022 09:30
Copy link
Contributor

@yixinglu yixinglu left a comment

Choose a reason for hiding this comment

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

lgtm

@yixinglu yixinglu merged commit b35eeab into vesoft-inc:master Dec 13, 2022
package picker

var _ Picker = ConverterPicker{}

Copy link

Choose a reason for hiding this comment

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

add var _ Picker = NullablePickers{} too ?

veezhang added a commit to veezhang/nebula-importer that referenced this pull request Dec 14, 2022
veezhang added a commit to veezhang/nebula-importer that referenced this pull request Dec 14, 2022
Comment on lines +46 to +51
case 0:
return v, nil
case 1:
return ncs[0].Convert(v)
}
return ncs.convertSlow(v)
Copy link

Choose a reason for hiding this comment

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

No need to process case1?

if len(nsc) == 0 {
    return v, nil
}
return ncs.convertSlow(v)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It‘s for performance. It's need not to loop.

Comment on lines +21 to +27
switch len(cs) {
case 0:
return v, nil
case 1:
return cs[0].Convert(v)
}
return cs.convertSlow(v)
Copy link

Choose a reason for hiding this comment

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

No need to process case 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as #246 (comment) .

Comment on lines +63 to +79
if !nullHandled && c.Nullable != nil {
converters = append(converters, NullableConverter{
Nullable: c.Nullable,
})
}

if c.Nullable != nil {
if c.DefaultValue != nil {
converters = append(converters, DefaultConverter{
Value: *c.DefaultValue,
})
} else {
converters = append(converters, NullConverter{
Value: c.NullValue,
})
}
}
Copy link

Choose a reason for hiding this comment

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

can combine them ?

	if c.Nullable != nil {
		if !nullHandled {
			converters = append(converters, NullableConverter{
				Nullable: c.Nullable,
			})
		}
		
		if c.DefaultValue != nil {
			converters = append(converters, DefaultConverter{
				Value: *c.DefaultValue,
			})
		} else {
			converters = append(converters, NullConverter{
				Value: c.NullValue,
			})
		}
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌🏻

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.

3 participants