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
Transition to BSER v2. #270
Conversation
@dhruvsinghal updated the pull request. |
@@ -48,7 +48,7 @@ static int bser_real(double val, json_dump_callback_t dump, void *data) | |||
return dump((char*)&val, sizeof(val), data); | |||
} | |||
|
|||
bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed, | |||
bool bunser_bytestring(const char *buf, json_int_t avail, json_int_t *needed, |
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 should actually be a static function. Feel free to change it to one.)
So something to think about is making sure we have the testing story straight for old server/new client and new server/old client. It's probably not something that you'll have to deal with right now but it'll become important very soon. |
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
1 similar comment
@dhruvsinghal updated the pull request. |
I took a brief look over this, and it is looking good! The CI failures appear to be due to unconditionally emitting the new UTF8 string encoding; I think you'll need to add a way to explicitly enable that while defaulting to disabled to make them pass and then I think you're about ready to land this initial series--so long as it doesn't change or break the default behavior it's ok to land partially done work towards the larger goal. |
@@ -48,7 +50,8 @@ static int bser_real(double val, json_dump_callback_t dump, void *data) | |||
return dump((char*)&val, sizeof(val), data); | |||
} | |||
|
|||
bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed, | |||
/* Common codepath for bytestring and UTF-8 encoded strings. */ | |||
static bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed, |
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.
you may want to rename this or change the type signature to help ensure that you got all references to this name and replaced them with bunser_bytestring
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 is actually fine -- in d443952 @dhruvsinghal renamed bunser_string
to bunser_bytestring
.
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
@Sid0 Can you have a look sometime and say if the refactor involving the context variable is on the right track? (Note that this build won't pass the tests yet since ASAN found bugs) |
{ | ||
json_int_t m_size = 0; | ||
bser_ctx_t measurement_ctx = *ctx; | ||
ctx->dump = measure; |
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.
measurement_ctx->dump = measure
.
fdbb2c7
to
21ffd60
Compare
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
@dhruvsinghal updated the pull request. |
@@ -353,7 +372,16 @@ int w_bser_dump(const bser_ctx_t* ctx, json_t *json, void *data) | |||
case JSON_INTEGER: | |||
return bser_int(ctx, json_integer_value(json), data); | |||
case JSON_STRING: | |||
return bser_bytestring(ctx, json_string_value(json), data); | |||
wstr = json_to_w_string(json); |
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.
Wouldn't this affect BSERv1 as well?
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.
Ah yes. This is a WIP, got pushed prematurely, when I rebased on the latest head and pushed.
@dhruvsinghal updated the pull request - view changes |
@dhruvsinghal updated the pull request - view changes |
…lback logic once BSER v2 becomes default.
@dhruvsinghal updated the pull request - view changes |
@dhruvsinghal updated the pull request - view changes |
@dhruvsinghal updated the pull request - view changes |
@@ -401,7 +401,7 @@ int w_bser_write_pdu(const uint32_t bser_version, | |||
} | |||
|
|||
if (bser_version == 2) { | |||
if (bser_int(&ctx, bser_capabilities, data)) { | |||
if (dump((const char*) &bser_capabilities, 4, data)) { |
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.
Could you make the 4 a #define
or similar?
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.
Made it sizeof(bser_capabilities)
I'm closing this out because it has been idle for a while and has conflicts. Please open a new pull request rebased off master when you're ready to follow up on this work. |
As per https://github.com/facebook/watchman/wiki/Better-Unicode-handling-plan.
STRING
toBYTESTRING
.version
command.