-
Notifications
You must be signed in to change notification settings - Fork 701
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
Cleanup codec usage #2563
Cleanup codec usage #2563
Conversation
) | ||
|
||
var c codec.Manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codec
is much easier to read than c
and this allows easier usage of the format.
const CodecVersion = 0 | ||
|
||
var Codec codec.Manager | ||
|
||
func init() { | ||
lc := linearcodec.NewDefault() | ||
Codec = codec.NewDefaultManager() | ||
|
||
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { | ||
panic(err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no reason we created a new codec for each encdb
instance.
const CodecVersion = 0 | ||
|
||
var Codec codec.Manager | ||
|
||
func init() { | ||
lc := linearcodec.NewCustomMaxLength(math.MaxUint32) | ||
Codec = codec.NewManager(math.MaxInt) | ||
|
||
if err := Codec.RegisterCodec(CodecVersion, lc); err != nil { | ||
panic(err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no reason we created a new codec for each indexer.
|
||
func init() { | ||
lc := linearcodec.NewCustomMaxLength(math.MaxUint32) | ||
Codec = codec.NewManager(math.MaxInt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no reason to have a complex calculated maximum length here.
|
||
func init() { | ||
lc := linearcodec.New([]string{reflectcodec.DefaultTagName + "V0"}, maxSize) | ||
lc2 := linearcodec.New([]string{reflectcodec.DefaultTagName + "V1"}, maxSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lc2
seemed very confusing here... because this is version 1.
|
||
c = codec.NewManager(maxSize) | ||
// for backward compatibility, still register the initial codec version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really for backwards compatibility... I think this was a remnant of a prior design for the stop vertex codec handling.
Co-authored-by: Stephen <[email protected]>
Why this should be merged
This standardizes how we use the reflect codec and simplifies some code paths.
How this works
It's essentially a pure refactor.
How this was tested