Skip to content

Commit

Permalink
Fix code review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yihanzhen committed Jun 21, 2018
1 parent 82efad2 commit 9cca46e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1179,11 +1179,7 @@ CloseableIterator<PartialResultSet> startStream(@Nullable ByteString resumeToken
: request.toBuilder().setResumeToken(resumeToken).build(),
stream.consumer(),
session.options);
// StreamController does not auto-request 1 message. Kick it off mannually
call.request(1);
if (prefetchChunks > 1) {
call.request(prefetchChunks - 1);
}
call.request(prefetchChunks);
stream.setCall(call);
return stream;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class GapicSpannerRpc implements SpannerRpc {
PathTemplate.create("projects/{project}");
private static final int MAX_MESSAGE_SIZE = 100 * 1024 * 1024;

// TODO(hzyi): change the stub names to be more intuitive
private final SpannerStub stub;
private final InstanceAdminStub instanceStub;
private final DatabaseAdminStub databaseStub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
*/
package com.google.cloud.spanner.spi.v1;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.grpc.Metadata;
import io.grpc.Metadata.Key;
import java.util.List;
import java.util.Map;
import org.junit.Test;

Expand Down Expand Up @@ -67,6 +70,16 @@ public void testGetResourceHeaderValue() {
getResourceHeaderValue(metadataProvider, "projects/p/instances/i/databases/d/operations"));
}

@Test
public void testNewExtraHeaders() {
SpannerMetadataProvider metadataProvider =
SpannerMetadataProvider.create(ImmutableMap.<String, String>of(), "header1");
Map<String, List<String>> extraHeaders = metadataProvider.newExtraHeaders(null, "value1");
assertThat(extraHeaders)
.containsExactlyEntriesIn(
ImmutableMap.<String, List<String>>of("header1", ImmutableList.<String>of("value1")));
}

private String getResourceHeaderValue(
SpannerMetadataProvider headerProvider, String resourceTokenTemplate) {
Metadata metadata = headerProvider.newMetadata(resourceTokenTemplate, "projects/p");
Expand Down

0 comments on commit 9cca46e

Please sign in to comment.