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
add support for enum in deepCopyIfNeeded() in RecordConstructorValue #1933
add support for enum in deepCopyIfNeeded() in RecordConstructorValue #1933
Conversation
Result of fdb-record-layer-pr-proto2 on Linux CentOS 7
|
Result of fdb-record-layer-pr-proto3 on Linux CentOS 7
|
@@ -161,7 +161,7 @@ private Object deepCopyIfNeeded(@Nonnull TypeRepository typeRepository, | |||
return null; | |||
} | |||
|
|||
if (fieldType.isPrimitive()) { | |||
if (fieldType.isPrimitive() || fieldType instanceof Type.Enum) { |
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.
Is this sufficient? Doesn't the Descriptors.EnumValueDescriptor.getType
need to match to target field descriptor in the same way as nested messages?
@@ -161,7 +161,7 @@ private Object deepCopyIfNeeded(@Nonnull TypeRepository typeRepository, | |||
return null; | |||
} | |||
|
|||
if (fieldType.isPrimitive()) { | |||
if (fieldType.isPrimitive() || fieldType instanceof Type.Enum) { |
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.
Right, also, it seems there is a missing code path for handling enum
fields in deepCopyMessageIfNeeded
. To make sure this works as expected, I would suggest the following test:
enum Corpus {
CORPUS_UNSPECIFIED = 0;
CORPUS_UNIVERSAL = 1;
CORPUS_WEB = 2;
CORPUS_IMAGES = 3;
CORPUS_LOCAL = 4;
CORPUS_NEWS = 5;
CORPUS_PRODUCTS = 6;
CORPUS_VIDEO = 7;
}
message SearchRequest {
string query = 1;
int32 page_number = 2;
int32 result_per_page = 3;
Corpus corpus = 4;
}
case1: CORPUS_WEB against CORPUS_WEB
case2:
{"foo", 42, 100, CORPUS_LOCAL} against {"foo", 42, 100, CORPUS_LOCAL}
another case for this message:
message SearchRequest {
string query = 1;
int32 page_number = 2;
int32 result_per_page = 3;
repeated Corpus corpus = 4;
}
{"foo", 42, 100, [CORPUS_LOCAL]} against {"foo", 42, 100, [CORPUS_LOCAL]}
I think the first case will hit this code path, but the second case will hit the (currently missing) handling of enum
inside a message. The last case, will hit handling enum
for repeated (array) fields.
…pCopyIfNeeded() in RecordConstructorValue)
af066ff
to
1e0a3e3
Compare
Result of fdb-record-layer-pr-proto2 on Linux CentOS 7
|
Result of fdb-record-layer-pr-proto3 on Linux CentOS 7
|
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.
LGTM, very minor commits.
Please mark the deepCopyIfNeeded
as @VisibleForTesting
if the intention behind making it public
was only to enable unit-testing it.
...e/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/MessageHelpers.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/MessageHelpers.java
Outdated
Show resolved
Hide resolved
...in/java/com/apple/foundationdb/record/query/plan/cascades/values/RecordConstructorValue.java
Show resolved
Hide resolved
...in/java/com/apple/foundationdb/record/query/plan/cascades/values/RecordConstructorValue.java
Outdated
Show resolved
Hide resolved
...ava/com/apple/foundationdb/record/query/plan/cascades/values/RecordConstructorValueTest.java
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. |
Result of fdb-record-layer-pr-proto2 on Linux CentOS 7
|
Result of fdb-record-layer-pr-proto3 on Linux CentOS 7
|
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.
Nice work!
…pCopyIfNeeded() in RecordConstructorValue)