Sets the maximum time a request is allowed to be waiting in request waiting queue. Under very
low chance, it's possible for append request to be waiting indefintely for request callback
when Google networking SDK does not detect the networking breakage. The default timeout is 15
minutes. We are investigating the root cause for callback not triggered by networking SDK.
ApiFuture<AppendRowsResponse>future=writer.append(rows,0);ApiFutures.addCallback(future,newApiFutureCallback<AppendRowsResponse>(){publicvoidonSuccess(AppendRowsResponseresponse){if(!response.hasError()){System.out.println("written with offset: "+response.getAppendResult().getOffset());}else{System.out.println("received an in stream error: "+response.getError().toString());}}publicvoidonFailure(Throwablet){System.out.println("failed to write: "+t);}},MoreExecutors.directExecutor());
Returns the wait of a request in Client side before sending to the Server. Request could wait
in Client because it reached the client side inflight request limit (adjustable when
constructing the StreamWriter). The value is the wait time for the last sent request. A
constant high wait value indicates a need for more throughput, you can create a new Stream for
to increase the throughput in exclusive stream case, or create a new Writer in the default
stream case.
if a stream writer can no longer be used for writing. It is due to either the
StreamWriter is explicitly closed or the underlying connection is broken when connection
pool is not used. Client should recreate StreamWriter in this case.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-18 UTC."],[],[],null,["# Class StreamWriter (3.16.2)\n\nVersion latestkeyboard_arrow_down\n\n- [3.16.2 (latest)](/java/docs/reference/google-cloud-bigquerystorage/latest/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.16.1](/java/docs/reference/google-cloud-bigquerystorage/3.16.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.15.3](/java/docs/reference/google-cloud-bigquerystorage/3.15.3/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.14.1](/java/docs/reference/google-cloud-bigquerystorage/3.14.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.12.0](/java/docs/reference/google-cloud-bigquerystorage/3.12.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.11.4](/java/docs/reference/google-cloud-bigquerystorage/3.11.4/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.10.3](/java/docs/reference/google-cloud-bigquerystorage/3.10.3/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.9.3](/java/docs/reference/google-cloud-bigquerystorage/3.9.3/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.8.0](/java/docs/reference/google-cloud-bigquerystorage/3.8.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.6.1](/java/docs/reference/google-cloud-bigquerystorage/3.6.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.5.2](/java/docs/reference/google-cloud-bigquerystorage/3.5.2/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.4.0](/java/docs/reference/google-cloud-bigquerystorage/3.4.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.3.1](/java/docs/reference/google-cloud-bigquerystorage/3.3.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.2.0](/java/docs/reference/google-cloud-bigquerystorage/3.2.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.1.0](/java/docs/reference/google-cloud-bigquerystorage/3.1.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [3.0.1](/java/docs/reference/google-cloud-bigquerystorage/3.0.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [2.47.0](/java/docs/reference/google-cloud-bigquerystorage/2.47.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [2.45.0](/java/docs/reference/google-cloud-bigquerystorage/2.45.0/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [2.44.1](/java/docs/reference/google-cloud-bigquerystorage/2.44.1/com.google.cloud.bigquery.storage.v1.StreamWriter)\n- [2.43.0](/java/docs/reference/google-cloud-bigquerystorage/2.43.0/com.google.cloud.bigquery.storage.v1.StreamWriter) \n\n public class StreamWriter implements AutoCloseable\n\nA BigQuery Stream Writer that can be used to write data into BigQuery Table.\n\nTODO: Support batching. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e StreamWriter \n\nImplements\n----------\n\n[AutoCloseable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### getApiMaxRequestBytes()\n\n public static long getApiMaxRequestBytes()\n\nThe maximum size of one request. Defined by the API.\n\n### getDefaultStreamName(TableName tableName)\n\n public static String getDefaultStreamName(TableName tableName)\n\n### newBuilder(String streamName)\n\n public static StreamWriter.Builder newBuilder(String streamName)\n\nConstructs a new [StreamWriter.Builder](/java/docs/reference/google-cloud-bigquerystorage/latest/com.google.cloud.bigquery.storage.v1.StreamWriter.Builder) using the given stream.\n\n### newBuilder(String streamName, BigQueryWriteClient client)\n\n public static StreamWriter.Builder newBuilder(String streamName, BigQueryWriteClient client)\n\nConstructs a new [StreamWriter.Builder](/java/docs/reference/google-cloud-bigquerystorage/latest/com.google.cloud.bigquery.storage.v1.StreamWriter.Builder) using the given stream and client.\n\n### setMaxRequestCallbackWaitTime(Duration waitTime)\n\n public static void setMaxRequestCallbackWaitTime(Duration waitTime)\n\nSets the maximum time a request is allowed to be waiting in request waiting queue. Under very\nlow chance, it's possible for append request to be waiting indefintely for request callback\nwhen Google networking SDK does not detect the networking breakage. The default timeout is 15\nminutes. We are investigating the root cause for callback not triggered by networking SDK.\n\nMethods\n-------\n\n### append(ProtoRows rows)\n\n public ApiFuture\u003cAppendRowsResponse\u003e append(ProtoRows rows)\n\nSchedules the writing of rows at the end of current stream.\n\n### append(ProtoRows rows, long offset)\n\n public ApiFuture\u003cAppendRowsResponse\u003e append(ProtoRows rows, long offset)\n\nSchedules the writing of rows at given offset.\n\nExample of writing rows with specific offset. \n\n\n ApiFuture\u003cAppendRowsResponse\u003e future = writer.append(rows, 0);\n ApiFutures.addCallback(future, new ApiFutureCallback\u003cAppendRowsResponse\u003e() {\n public void onSuccess(AppendRowsResponse response) {\n if (!response.hasError()) {\n System.out.println(\"written with offset: \" + response.getAppendResult().getOffset());\n } else {\n System.out.println(\"received an in stream error: \" + response.getError().toString());\n }\n }\n\n public void onFailure(Throwable t) {\n System.out.println(\"failed to write: \" + t);\n }\n }, MoreExecutors.directExecutor());\n \n### close()\n\n public void close()\n\nClose the stream writer. Shut down all resources.\n\n### getInflightWaitSeconds()\n\n public long getInflightWaitSeconds()\n\nReturns the wait of a request in Client side before sending to the Server. Request could wait\nin Client because it reached the client side inflight request limit (adjustable when\nconstructing the StreamWriter). The value is the wait time for the last sent request. A\nconstant high wait value indicates a need for more throughput, you can create a new Stream for\nto increase the throughput in exclusive stream case, or create a new Writer in the default\nstream case.\n\n### getLocation()\n\n public String getLocation()\n\n### getMissingValueInterpretationMap()\n\n public Map\u003cString,AppendRowsRequest.MissingValueInterpretation\u003e getMissingValueInterpretationMap()\n\n### getProtoSchema()\n\n public ProtoSchema getProtoSchema()\n\n### getStreamName()\n\n public String getStreamName()\n\n### getUpdatedSchema()\n\n public synchronized TableSchema getUpdatedSchema()\n\nThread-safe getter of updated TableSchema.\n\nThis will return the updated schema only when the creation timestamp of this writer is older\nthan the updated schema.\n\n### getWriterId()\n\n public String getWriterId()\n\n### isClosed()\n\n public boolean isClosed()\n\n### isUserClosed()\n\n public boolean isUserClosed()"]]