Skip to content

Commit

Permalink
Revert struct and session pool options serializatio
Browse files Browse the repository at this point in the history
  • Loading branch information
Mairbek Khadikov committed May 25, 2017
1 parent 35ea0e1 commit 042ce76
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

import com.google.common.base.Preconditions;

import java.io.Serializable;

/** Options for the session pool used by {@code DatabaseClient}. */
public class SessionPoolOptions implements Serializable {
private static final long serialVersionUID = -4362880062762314525L;

public class SessionPoolOptions {
private final int minSessions;
private final int maxSessions;
private final int maxIdleSessions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,6 @@ public Transaction call() throws Exception {
* @param <R> the type of row data
*/
private static class BaseStruct<R> extends Struct {
private static final long serialVersionUID = -1850257565078946587L;

protected final Type type;
protected final List<Object> rowData;

Expand Down Expand Up @@ -1841,8 +1839,6 @@ private SpannerException yieldError(SpannerException e) {
}

private static class GrpcStruct extends BaseStruct<List<Object>> {
private static final long serialVersionUID = -2067943506736181881L;

GrpcStruct(Type type, List<Object> rowData) {
super(type, rowData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.common.primitives.Doubles;
import com.google.common.primitives.Longs;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -43,9 +42,7 @@
* <p>{@code Struct} instances are immutable.
*/
@Immutable
public abstract class Struct extends AbstractStructReader implements Serializable {
private static final long serialVersionUID = 1698871272663044565L;

public abstract class Struct extends AbstractStructReader {
// Only implementations within the package are allowed.
Struct() {}

Expand Down Expand Up @@ -125,8 +122,6 @@ private void checkBindingInProgress(boolean expectInProgress) {

/** Default implementation for test value structs produced by {@link Builder}. */
private static class ValueListStruct extends Struct {
private static final long serialVersionUID = 1712981659934867577L;

private final Type type;
private final List<Value> values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@
package com.google.cloud.spanner;

import static com.google.cloud.spanner.SpannerMatchers.isSpannerException;
import static com.google.common.testing.SerializableTester.reserializeAndAssert;
import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.ByteArray;
import com.google.cloud.Date;
import com.google.cloud.Timestamp;
import com.google.cloud.spanner.spi.v1.SpannerRpc;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.protobuf.ByteString;
import com.google.protobuf.NullValue;
Expand Down Expand Up @@ -592,50 +588,4 @@ private static ResultSetMetadata makeMetadata(Type rowType) {
com.google.spanner.v1.Type typeProto = rowType.toProto();
return ResultSetMetadata.newBuilder().setRowType(typeProto.getStructType()).build();
}

@Test
public void serialization() throws Exception {
verifySerialization(Value.string("a"),
Value.string(null),
Value.bool(true),
Value.bool(null),
Value.int64(1),
Value.int64(null),
Value.float64(1.0),
Value.float64(null),
Value.bytes(ByteArray.fromBase64("abcd")),
Value.bytes(null),
Value.timestamp(Timestamp.ofTimeSecondsAndNanos(1, 2)),
Value.timestamp(null),
Value.date(Date.fromYearMonthDay(2017, 04, 17)),
Value.date(null),
Value.stringArray(ImmutableList.of("one", "two")),
Value.stringArray(null),
Value.boolArray(new boolean[]{true, false}),
Value.boolArray((boolean[]) null),
Value.int64Array(new long[]{1, 2, 3}),
Value.int64Array((long[]) null),
Value.timestampArray(ImmutableList.of(Timestamp.MAX_VALUE, Timestamp.MAX_VALUE)),
Value.timestampArray(null),
Value.dateArray(ImmutableList.of(
Date.fromYearMonthDay(2017, 4, 17), Date.fromYearMonthDay(2017, 5, 18))),
Value.dateArray(null)
);
}

private void verifySerialization(Value... values) {
resultSet = new SpannerImpl.GrpcResultSet(stream, new NoOpListener(), QueryMode.NORMAL);
PartialResultSet.Builder builder = PartialResultSet.newBuilder();
List<Type.StructField> types = new ArrayList<>();
for (Value value : values) {
types.add(Type.StructField.of("f", value.getType()));
builder.addValues(value.toProto());
}
consumer.onPartialResultSet(
builder.setMetadata(makeMetadata(Type.struct(types)))
.build());
consumer.onCompleted();
assertThat(resultSet.next()).isTrue();
reserializeAndAssert(resultSet.getCurrentRowAsStruct());
}
}

0 comments on commit 042ce76

Please sign in to comment.