Skip to content

Commit

Permalink
feat: improve json to proto conversion by caching schema (#2179)
Browse files Browse the repository at this point in the history
* feat: add public api to stream writer to set the maximum wait time

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* modify back the readme change from owl post processor

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix: Reduce the timeout to 5 minutes for the requests wait time in queue.

Since in write api server side we have total timeout of 2 minutes, it
does not make sense to wait 15 minutes to determine whether we have met
dead connection, let's reduce the timeout here

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix:  1.disable refresh of stream writer when the table schema is
explicitly provided 2. fix location string matching for multiplexing

* feat: improve json stream writer json to proto conversion speed by
caching the schema. This will introduce approximately 2x improvement to
append speed

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
GaoleMeng and gcf-owl-bot[bot] committed Jul 13, 2023
1 parent e5bb5d0 commit afc550a
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 133 deletions.
12 changes: 12 additions & 0 deletions google-cloud-bigquerystorage/clirr-ignored-differences.xml
Expand Up @@ -157,5 +157,17 @@
<className>com/google/cloud/bigquery/storage/v1/JsonStreamWriter</className>
<method>boolean isDone()</method>
</difference>
<difference>
<differenceType>7006</differenceType>
<className>com/google/cloud/bigquery/storage/v1/ToProtoConverter</className>
<method>com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors$Descriptor, com.google.cloud.bigquery.storage.v1.TableSchema, java.lang.Object, boolean)</method>
<to>java.util.List</to>
</difference>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/bigquery/storage/v1/ToProtoConverter</className>
<method>com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors$Descriptor, com.google.cloud.bigquery.storage.v1.TableSchema, java.lang.Object, boolean)</method>
<to>com.google.protobuf.DynamicMessage convertToProtoMessage(com.google.protobuf.Descriptors$Descriptor, com.google.cloud.bigquery.storage.v1.TableSchema, java.lang.Iterable, boolean)</to>
</difference>
</differences>

Expand Up @@ -259,6 +259,29 @@ public AppendSerializationError(
}
}

/** This exception is thrown from proto converter to wrap the row index to error mapping. */
static class RowIndexToErrorException extends IllegalArgumentException {
Map<Integer, String> rowIndexToErrorMessage;

boolean hasDataUnknownError;

public RowIndexToErrorException(
Map<Integer, String> rowIndexToErrorMessage, boolean hasDataUnknownError) {
this.rowIndexToErrorMessage = rowIndexToErrorMessage;
this.hasDataUnknownError = hasDataUnknownError;
}

// This message should not be exposed to the user directly.
// Please examine individual row's error through `rowIndexToErrorMessage`.
public String getMessage() {
return "The map of row index to error message is " + rowIndexToErrorMessage.toString();
}

public boolean hasDataUnknownError() {
return hasDataUnknownError;
}
}

/** This exception is used internally to handle field level parsing errors. */
public static class FieldParseError extends IllegalArgumentException {
private final String fieldName;
Expand Down

0 comments on commit afc550a

Please sign in to comment.