Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add trace_id for Read API #1544

Merged
merged 2 commits into from Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -93,6 +93,7 @@ public void createReadSessionTest() throws Exception {
.setReadOptions(ReadSession.TableReadOptions.newBuilder().build())
.addAllStreams(new ArrayList<ReadStream>())
.setEstimatedTotalBytesScanned(452788190)
.setTraceId("traceId-1067401920")
.build();
mockBigQueryRead.addResponse(expectedResponse);

Expand Down Expand Up @@ -144,6 +145,7 @@ public void createReadSessionTest2() throws Exception {
.setReadOptions(ReadSession.TableReadOptions.newBuilder().build())
.addAllStreams(new ArrayList<ReadStream>())
.setEstimatedTotalBytesScanned(452788190)
.setTraceId("traceId-1067401920")
.build();
mockBigQueryRead.addResponse(expectedResponse);

Expand Down
Expand Up @@ -42,6 +42,7 @@ private ReadSession() {
dataFormat_ = 0;
table_ = "";
streams_ = java.util.Collections.emptyList();
traceId_ = "";
}

@java.lang.Override
Expand Down Expand Up @@ -197,6 +198,13 @@ private ReadSession(
estimatedTotalBytesScanned_ = input.readInt64();
break;
}
case 106:
{
java.lang.String s = input.readStringRequireUtf8();

traceId_ = s;
break;
}
default:
{
if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
Expand Down Expand Up @@ -3187,6 +3195,63 @@ public long getEstimatedTotalBytesScanned() {
return estimatedTotalBytesScanned_;
}

public static final int TRACE_ID_FIELD_NUMBER = 13;
private volatile java.lang.Object traceId_;
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The traceId.
*/
@java.lang.Override
public java.lang.String getTraceId() {
java.lang.Object ref = traceId_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
traceId_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for traceId.
*/
@java.lang.Override
public com.google.protobuf.ByteString getTraceIdBytes() {
java.lang.Object ref = traceId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
traceId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}

private byte memoizedIsInitialized = -1;

@java.lang.Override
Expand Down Expand Up @@ -3232,6 +3297,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
if (estimatedTotalBytesScanned_ != 0L) {
output.writeInt64(12, estimatedTotalBytesScanned_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(traceId_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 13, traceId_);
}
unknownFields.writeTo(output);
}

Expand Down Expand Up @@ -3277,6 +3345,9 @@ public int getSerializedSize() {
size +=
com.google.protobuf.CodedOutputStream.computeInt64Size(12, estimatedTotalBytesScanned_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(traceId_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(13, traceId_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
Expand Down Expand Up @@ -3310,6 +3381,7 @@ public boolean equals(final java.lang.Object obj) {
}
if (!getStreamsList().equals(other.getStreamsList())) return false;
if (getEstimatedTotalBytesScanned() != other.getEstimatedTotalBytesScanned()) return false;
if (!getTraceId().equals(other.getTraceId())) return false;
if (!getSchemaCase().equals(other.getSchemaCase())) return false;
switch (schemaCase_) {
case 4:
Expand Down Expand Up @@ -3356,6 +3428,8 @@ public int hashCode() {
}
hash = (37 * hash) + ESTIMATED_TOTAL_BYTES_SCANNED_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getEstimatedTotalBytesScanned());
hash = (37 * hash) + TRACE_ID_FIELD_NUMBER;
hash = (53 * hash) + getTraceId().hashCode();
switch (schemaCase_) {
case 4:
hash = (37 * hash) + AVRO_SCHEMA_FIELD_NUMBER;
Expand Down Expand Up @@ -3547,6 +3621,8 @@ public Builder clear() {
}
estimatedTotalBytesScanned_ = 0L;

traceId_ = "";

schemaCase_ = 0;
schema_ = null;
return this;
Expand Down Expand Up @@ -3619,6 +3695,7 @@ public com.google.cloud.bigquery.storage.v1.ReadSession buildPartial() {
result.streams_ = streamsBuilder_.build();
}
result.estimatedTotalBytesScanned_ = estimatedTotalBytesScanned_;
result.traceId_ = traceId_;
result.schemaCase_ = schemaCase_;
onBuilt();
return result;
Expand Down Expand Up @@ -3720,6 +3797,10 @@ public Builder mergeFrom(com.google.cloud.bigquery.storage.v1.ReadSession other)
if (other.getEstimatedTotalBytesScanned() != 0L) {
setEstimatedTotalBytesScanned(other.getEstimatedTotalBytesScanned());
}
if (!other.getTraceId().isEmpty()) {
traceId_ = other.traceId_;
onChanged();
}
switch (other.getSchemaCase()) {
case AVRO_SCHEMA:
{
Expand Down Expand Up @@ -5725,6 +5806,132 @@ public Builder clearEstimatedTotalBytesScanned() {
return this;
}

private java.lang.Object traceId_ = "";
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The traceId.
*/
public java.lang.String getTraceId() {
java.lang.Object ref = traceId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
traceId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for traceId.
*/
public com.google.protobuf.ByteString getTraceIdBytes() {
java.lang.Object ref = traceId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
traceId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The traceId to set.
* @return This builder for chaining.
*/
public Builder setTraceId(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}

traceId_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearTraceId() {

traceId_ = getDefaultInstance().getTraceId();
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for traceId to set.
* @return This builder for chaining.
*/
public Builder setTraceIdBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);

traceId_ = value;
onChanged();
return this;
}

@java.lang.Override
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
Expand Down
Expand Up @@ -418,5 +418,38 @@ public interface ReadSessionOrBuilder
*/
long getEstimatedTotalBytesScanned();

/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The traceId.
*/
java.lang.String getTraceId();
/**
*
*
* <pre>
* Optional. ID set by client to annotate a session identity. This does not need
* to be strictly unique, but instead the same ID should be used to group
* logically connected sessions (e.g. All using the same ID for all sessions
* needed to complete a Spark SQL query is reasonable).
* Maximum length is 256 bytes.
* </pre>
*
* <code>string trace_id = 13 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for traceId.
*/
com.google.protobuf.ByteString getTraceIdBytes();

public com.google.cloud.bigquery.storage.v1.ReadSession.SchemaCase getSchemaCase();
}