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

Convert as many interface{} on the marshaling types to primitive pointer types or dynamic types #1

Open
chanced opened this issue Apr 22, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@chanced
Copy link
Owner

chanced commented Apr 22, 2021

In an effort to move things along, I used interface{} for dynamic fields on the internal types used for (un)marshaling.

type completionField struct {
	Analyzer                   string      `json:"analyzer,omitempty"`
	SearchAnalyzer             string      `json:"search_analyzer,omitempty"`
	SearchQuoteAnalyzer        string      `json:"search_quote_analyzer,omitempty"`
	PreserveSeperators         interface{} `json:"preserve_separators,omitempty"`
	PreservePositionIncrements interface{} `json:"preserve_position_increments,omitempty"`
	MaxInputLength             interface{} `json:"max_input_length,omitempty"`
	Type                       FieldType   `json:"type"`
}

These need to be migrated to either primitive pointer types or dynamic types:

type completionField struct {
	Analyzer                   string        `json:"analyzer,omitempty"`
	SearchAnalyzer             string        `json:"search_analyzer,omitempty"`
	SearchQuoteAnalyzer        string        `json:"search_quote_analyzer,omitempty"`
	PreserveSeperators         *dynamic.Bool `json:"preserve_separators,omitempty"`
	PreservePositionIncrements *bool         `json:"preserve_position_increments,omitempty"`
	MaxInputLength             *int          `json:"max_input_length,omitempty"`
	Type                       FieldType     `json:"type"`
}

I'm just not sure which. Things I need to think through:

  • If I use primitives, I'll need to add something to the effect of Float64Ptr and CoerceInt64Ptr to the types in the dynamic package. Should I be concerned about the usability of this for the dynamic package? It wont be a pointer to the actual value.
  • If I use dynamic, that'll be a lot cleaner but I won't be able to cleanly coerce. This is a problem as some accessors currently coerce int values.

Doing so should improve performance of enc/dec.

@chanced chanced added the enhancement New feature or request label Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant