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

Cloud Spanner: Make Spanner value classes serializable #2040

Merged
merged 17 commits into from
Jun 6, 2017

Conversation

mairbek
Copy link

@mairbek mairbek commented May 8, 2017

Is needed to get PCollection<Struct> in Apache Beam working.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 8, 2017
Copy link
Contributor

@shinfan shinfan left a 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.

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.

Copy link
Contributor

@shinfan shinfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3375959 on mairbek:struct-mutations into ** on GoogleCloudPlatform:master**.

@coveralls
Copy link

Coverage Status

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.

@@ -41,7 +43,9 @@
* <p>{@code Struct} instances are immutable.
*/
@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.

This comment was marked as spam.

@mairbek mairbek force-pushed the struct-mutations branch from beee08c to 042ce76 Compare May 25, 2017 23:15
@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 80.905% when pulling 73fdfa3 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@mairbek
Copy link
Author

mairbek commented May 25, 2017

Reverted Struct serialization

@mairbek mairbek changed the title Cloud Spanner: Make Struct serializable Cloud Spanner: Make Spanner value classes serializable May 25, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 80.902% when pulling a6005ed on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 80.905% when pulling 73fdfa3 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 80.905% when pulling 73fdfa3 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 80.902% when pulling a6005ed on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 80.902% when pulling a6005ed on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

public final class Statement {
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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 81.164% when pulling b37df27 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

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.

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.

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.

reserializeAndAssert(Value.bytesArray(null));
}

@Test(expected = IllegalStateException.class)

This comment was marked as spam.

reserializeAndAssert(Value.stringArray(null));

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 81.173% when pulling 893d9f1 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 81.173% when pulling 893d9f1 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 81.173% when pulling 893d9f1 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@@ -38,6 +39,7 @@ public void basic() {
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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 81.187% when pulling 8210ee3 on mairbek:struct-mutations into a08d3fd on GoogleCloudPlatform:master.

@mairbek
Copy link
Author

mairbek commented Jun 6, 2017

Ping?

@vkedia vkedia merged commit 9432d8b into googleapis:master Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants