-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cloud Spanner: Make Spanner value classes serializable #2040
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
Conversation
shinfan
left a comment
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.
Just some small nits
| private static final long serialVersionUID = 695127243179520960L; | ||
| private final List<com.google.protobuf.Value> underlying; | ||
|
|
||
| private StringArray(List<com.google.protobuf.Value> underlying) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| private static final long serialVersionUID = -2850504708084921083L; | ||
| private final List<com.google.protobuf.Value> underlying; | ||
|
|
||
| private BoolArray(List<com.google.protobuf.Value> underlying) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
shinfan
left a comment
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
|
Changes Unknown when pulling 3375959 on mairbek:struct-mutations into ** on GoogleCloudPlatform:master**. |
|
Changes Unknown when pulling afbd59a on mairbek:struct-mutations into ** on GoogleCloudPlatform:master**. |
| @@ -2474,6 +2466,8 @@ A toPrimitiveArray(int columnIndex) { | |||
| } | |||
|
|
|||
| private static class Int64Array extends PrimitiveArray<Long, long[]> { | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| */ | ||
| @Immutable | ||
| public abstract class Struct extends AbstractStructReader { | ||
| public abstract class Struct extends AbstractStructReader implements Serializable { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Reverted Struct serialization |
| public final class Statement implements Serializable { | ||
| private static final long serialVersionUID = -1967958247625065259L; | ||
|
|
||
| private final ImmutableMap<String, Value> parameters; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| case ARRAY: | ||
| switch(fieldType.getArrayElementType().getCode()) { | ||
| case BOOL: | ||
| builder.set(fieldName).toBoolArray((Iterable<Boolean>) value); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| builder.set(fieldName).toDateArray((Iterable<Date>) value); | ||
| break; | ||
| case STRUCT: | ||
| builder.add(fieldName, fieldType.getStructFields(), (Iterable<Struct>) value); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| Value.timestampArray(null), | ||
| Value.dateArray(ImmutableList.of( | ||
| Date.fromYearMonthDay(2017, 4, 17), Date.fromYearMonthDay(2017, 5, 18))), | ||
| Value.dateArray(null) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| reserializeAndAssert(Value.bytesArray(null)); | ||
| } | ||
|
|
||
| @Test(expected = IllegalStateException.class) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| reserializeAndAssert( | ||
| Value.bytesArray(Arrays.asList(newByteArray("a"), newByteArray("b")))); | ||
| Value.bytesArray(BrokenSerializationList.of(newByteArray("a"), newByteArray("b")))); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| assertThat(stmt.getSql()).isEqualTo(sql); | ||
| assertThat(stmt.getParameters()).isEmpty(); | ||
| assertThat(stmt.toString()).isEqualTo(sql); | ||
| reserializeAndAssert(stmt); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Ping? |
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Is needed to get
PCollection<Struct>in Apache Beam working.