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

refactor entity parser #398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

refactor entity parser #398

wants to merge 1 commit into from

Conversation

skywhat
Copy link
Contributor

@skywhat skywhat commented Aug 22, 2019

No description provided.

indexType = reflect.TypeOf((*Index)(nil)).Elem()
tagsKey = []string{"primaryKey", "key", "name", "columns", "etl", "ttl"}

Choose a reason for hiding this comment

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

I see the same strings are repeated in the below code, which can be error-prone. How about defining them as variables like:

primaryKeyTag = "primaryKey";

and use "primaryKeyTag" in the remaining places so that compiler will tell you whether or not you are spelling correctly.

return "", nil, nil, fmt.Errorf("index field %s with an invalid dosa index tag: %s", indexName, tag)
var key *PrimaryKey
if val, ok := tagsMap["key"]; ok {
key, err = parsePrimaryKey(val)

Choose a reason for hiding this comment

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

Given that we use the same function for paring primary keys and index keys, how about calling it "parseKey"

fullNameTag = matches[0]
name = matches[1]
// parseSinglePrimaryKey func parses the single parimary key of DOSA object
func parseSinglePrimaryKey(s string) (*PrimaryKey, error) {

Choose a reason for hiding this comment

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

parimary => primary

// parseSinglePrimaryKey func parses the single parimary key of DOSA object
func parseSinglePrimaryKey(s string) (*PrimaryKey, error) {
s = strings.TrimSpace(s)
spaceIdx := strings.Index(s, " ")
Copy link

@ateliersakura ateliersakura Aug 23, 2019

Choose a reason for hiding this comment

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

Will this impact existing users?

// parseCompoundPartitionKeys func parses the compund partition key of DOSA object
func parseCompoundPartitionKeys(s string) ([]string, error) {
s = strings.TrimSpace(strings.Trim(s, "()"))
fields := strings.Split(s, ",")

Choose a reason for hiding this comment

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

do we need to check for the existence of spaces like the function above?

for _, ckField := range ckFields {
fields := strings.Fields(ckField)
if len(fields) == 0 {
continue

Choose a reason for hiding this comment

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

Should this be an error?

@CLAassistant
Copy link

CLAassistant commented Jun 13, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Gang Zhang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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