Skip to content
Permalink
Browse files
feat: add default stream support for StreamWriter (#744)
* fix: a race condition in test

* .

* .

* fix: allow default stream name to StreamWriter

* .
  • Loading branch information
yirutang committed Dec 17, 2020
1 parent 29f2bac commit 248ab73eebb9feda94e7e29de591a70c91a064c1
@@ -82,7 +82,7 @@ public class StreamWriter implements AutoCloseable {
private static final Logger LOG = Logger.getLogger(StreamWriter.class.getName());

private static String streamPatternString =
"(projects/[^/]+/datasets/[^/]+/tables/[^/]+)/streams/[^/]+";
"(projects/[^/]+/datasets/[^/]+/tables/[^/]+)/(streams/[^/]+|_default)";

private static Pattern streamPattern = Pattern.compile(streamPatternString);

@@ -58,6 +58,7 @@
public class StreamWriterTest {
private static final Logger LOG = Logger.getLogger(StreamWriterTest.class.getName());
private static final String TEST_STREAM = "projects/p/datasets/d/tables/t/streams/s";
private static final String TEST_DEFAULT_STREAM = "projects/p/datasets/d/tables/t/_default";
private static final ExecutorProvider SINGLE_THREAD_EXECUTOR =
InstantiatingExecutorProvider.newBuilder().setExecutorThreadCount(1).build();
private static LocalChannelProvider channelProvider;
@@ -102,6 +103,10 @@ private StreamWriter.Builder getTestStreamWriterBuilder() {
return getTestStreamWriterBuilder(TEST_STREAM);
}

private StreamWriter.Builder getDefaultTestStreamWriterBuilder() {
return getTestStreamWriterBuilder(TEST_DEFAULT_STREAM);
}

private AppendRowsRequest createAppendRequest(String[] messages, long offset) {
AppendRowsRequest.Builder requestBuilder = AppendRowsRequest.newBuilder();
AppendRowsRequest.ProtoData.Builder dataBuilder = AppendRowsRequest.ProtoData.newBuilder();
@@ -143,6 +148,13 @@ public void testTableName() throws Exception {
}
}

@Test
public void testDefaultStream() throws Exception {
try (StreamWriter writer = getDefaultTestStreamWriterBuilder().build()) {
assertEquals("projects/p/datasets/d/tables/t", writer.getTableNameString());
}
}

@Test
public void testAppendByDuration() throws Exception {
StreamWriter writer =

0 comments on commit 248ab73

Please sign in to comment.