public class JsonStreamWriter extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonStreamWriter.Builder |
| Modifier and Type | Method and Description |
|---|---|
com.google.api.core.ApiFuture<AppendRowsResponse> |
append(org.json.JSONArray jsonArr)
Writes a JSONArray that contains JSONObjects to the BigQuery table by first converting the JSON
data to protobuf messages, then using StreamWriter's append() to write the data at current end
of stream.
|
com.google.api.core.ApiFuture<AppendRowsResponse> |
append(org.json.JSONArray jsonArr,
long offset)
Writes a JSONArray that contains JSONObjects to the BigQuery table by first converting the JSON
data to protobuf messages, then using StreamWriter's append() to write the data at the
specified offset.
|
void |
close()
Closes the underlying StreamWriter.
|
com.google.protobuf.Descriptors.Descriptor |
getDescriptor()
Gets current descriptor
|
long |
getInflightWaitSeconds()
Returns the wait of a request in Client side before sending to the Server.
|
String |
getLocation()
Gets the location of the destination
|
String |
getStreamName() |
String |
getWriterId() |
boolean |
isClosed() |
boolean |
isUserClosed() |
static JsonStreamWriter.Builder |
newBuilder(String streamOrTableName,
BigQueryWriteClient client)
newBuilder that constructs a JsonStreamWriter builder with TableSchema being initialized by
StreamWriter by default.
|
static JsonStreamWriter.Builder |
newBuilder(String streamOrTableName,
TableSchema tableSchema)
newBuilder that constructs a JsonStreamWriter builder with BigQuery client being initialized by
StreamWriter by default.
|
static JsonStreamWriter.Builder |
newBuilder(String streamOrTableName,
TableSchema tableSchema,
BigQueryWriteClient client)
newBuilder that constructs a JsonStreamWriter builder.
|
public com.google.api.core.ApiFuture<AppendRowsResponse> append(org.json.JSONArray jsonArr) throws IOException, com.google.protobuf.Descriptors.DescriptorValidationException
jsonArr - The JSON array that contains JSONObjects to be writtenIOExceptioncom.google.protobuf.Descriptors.DescriptorValidationExceptionpublic com.google.api.core.ApiFuture<AppendRowsResponse> append(org.json.JSONArray jsonArr, long offset) throws IOException, com.google.protobuf.Descriptors.DescriptorValidationException
jsonArr - The JSON array that contains JSONObjects to be writtenoffset - Offset for deduplicationIOExceptioncom.google.protobuf.Descriptors.DescriptorValidationExceptionpublic String getStreamName()
public String getWriterId()
public com.google.protobuf.Descriptors.Descriptor getDescriptor()
public String getLocation()
public long getInflightWaitSeconds()
public static JsonStreamWriter.Builder newBuilder(String streamOrTableName, TableSchema tableSchema)
The table schema passed in will be updated automatically when there is a schema update event. When used for Writer creation, it should be the latest schema. So when you are trying to reuse a stream, you should use Builder newBuilder( String streamOrTableName, BigQueryWriteClient client) instead, so the created Writer will be based on a fresh schema.
streamOrTableName - name of the stream that must follow
"projects/[^/]+/datasets/[^/]+/tables/[^/]+/streams/[^/]+" or table name
"projects/[^/]+/datasets/[^/]+/tables/[^/]+"tableSchema - The schema of the table when the stream was created, which is passed back
through WriteStreampublic static JsonStreamWriter.Builder newBuilder(String streamOrTableName, TableSchema tableSchema, BigQueryWriteClient client)
The table schema passed in will be updated automatically when there is a schema update event. When used for Writer creation, it should be the latest schema. So when you are trying to reuse a stream, you should use Builder newBuilder( String streamOrTableName, BigQueryWriteClient client) instead, so the created Writer will be based on a fresh schema.
streamOrTableName - name of the stream that must follow
"projects/[^/]+/datasets/[^/]+/tables/[^/]+/streams/[^/]+"tableSchema - The schema of the table when the stream was created, which is passed back
through WriteStreamclient - public static JsonStreamWriter.Builder newBuilder(String streamOrTableName, BigQueryWriteClient client)
streamOrTableName - name of the stream that must follow
"projects/[^/]+/datasets/[^/]+/tables/[^/]+/streams/[^/]+"client - BigQueryWriteClientpublic void close()
close in interface AutoCloseablepublic boolean isClosed()
public boolean isUserClosed()
Copyright © 2023 Google LLC. All rights reserved.