-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for BI Engine Statistics (#1723)
fixes b/205146044
- Loading branch information
1 parent
e7f1cf8
commit 13cc6e6
Showing
5 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BiEngineReason.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.bigquery; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import java.io.Serializable; | ||
import javax.annotation.Nullable; | ||
|
||
@AutoValue | ||
public abstract class BiEngineReason implements Serializable { | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
|
||
/** | ||
* High-level BI Engine reason for partial or disabled acceleration. | ||
* | ||
* @param code code or {@code null} for none | ||
*/ | ||
public abstract Builder setCode(String code); | ||
|
||
/** | ||
* Free form human-readable reason for partial or disabled acceleration. | ||
* | ||
* @param message message or {@code null} for none | ||
*/ | ||
public abstract Builder setMessage(String message); | ||
|
||
/** Creates a {@code BiEngineReason} object. */ | ||
public abstract BiEngineReason build(); | ||
} | ||
|
||
/** | ||
* High-level BI Engine reason for partial or disabled acceleration. | ||
* | ||
* @return value or {@code null} for none | ||
*/ | ||
@Nullable | ||
public abstract String getCode(); | ||
|
||
/** | ||
* Free form human-readable reason for partial or disabled acceleration. | ||
* | ||
* @return value or {@code null} for none | ||
*/ | ||
@Nullable | ||
public abstract String getMessage(); | ||
|
||
public abstract Builder toBuilder(); | ||
|
||
public static Builder newBuilder() { | ||
return new AutoValue_BiEngineReason.Builder(); | ||
} | ||
|
||
com.google.api.services.bigquery.model.BiEngineReason toPb() { | ||
com.google.api.services.bigquery.model.BiEngineReason biEngineReasonPb = | ||
new com.google.api.services.bigquery.model.BiEngineReason(); | ||
if (getCode() != null) { | ||
biEngineReasonPb.setCode(getCode()); | ||
} | ||
if (getMessage() != null) { | ||
biEngineReasonPb.setMessage(getMessage()); | ||
} | ||
return biEngineReasonPb; | ||
} | ||
|
||
static BiEngineReason fromPb( | ||
com.google.api.services.bigquery.model.BiEngineReason biEngineReasonPb) { | ||
Builder builder = newBuilder(); | ||
if (biEngineReasonPb.getCode() != null) { | ||
builder.setCode(biEngineReasonPb.getCode()); | ||
} | ||
if (biEngineReasonPb.getMessage() != null) { | ||
builder.setMessage(biEngineReasonPb.getMessage()); | ||
} | ||
return builder.build(); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BiEngineStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.bigquery; | ||
|
||
import com.google.api.services.bigquery.model.BiEngineStatistics; | ||
import com.google.auto.value.AutoValue; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import javax.annotation.Nullable; | ||
|
||
/** BIEngineStatistics contains query statistics specific to the use of BI Engine. */ | ||
@AutoValue | ||
public abstract class BiEngineStats implements Serializable { | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
/** | ||
* Specifies which mode of BI Engine acceleration was performed (if any). | ||
* | ||
* @param biEngineMode biEngineMode or {@code null} for none | ||
*/ | ||
public abstract Builder setBiEngineMode(String biEngineMode); | ||
|
||
/** | ||
* In case of DISABLED or PARTIAL bi_engine_mode, these contain the explanatory reasons as to | ||
* why BI Engine could not accelerate. In case the full query was accelerated, this field is not | ||
* populated. | ||
* | ||
* @param biEngineReasons biEngineReasons or {@code null} for none | ||
*/ | ||
public abstract Builder setBiEngineReasons(List<BiEngineReason> biEngineReasons); | ||
|
||
/** Creates a @code BiEngineStats} object. */ | ||
public abstract BiEngineStats build(); | ||
} | ||
|
||
/** | ||
* Specifies which mode of BI Engine acceleration was performed (if any). | ||
* | ||
* @return value or {@code null} for none | ||
*/ | ||
@Nullable | ||
public abstract String getBiEngineMode(); | ||
|
||
/** | ||
* In case of DISABLED or PARTIAL bi_engine_mode, these contain the explanatory reasons as to why | ||
* BI Engine could not accelerate. In case the full query was accelerated, this field is not | ||
* populated. | ||
* | ||
* @return value or {@code null} for none | ||
*/ | ||
@Nullable | ||
public abstract List<BiEngineReason> getBiEngineReasons(); | ||
|
||
public abstract Builder toBuilder(); | ||
|
||
public static Builder newBuilder() { | ||
return new AutoValue_BiEngineStats.Builder(); | ||
} | ||
|
||
BiEngineStatistics toPb() { | ||
BiEngineStatistics biEngineStatisticsPb = new BiEngineStatistics(); | ||
if (getBiEngineMode() != null) { | ||
biEngineStatisticsPb.setBiEngineMode(getBiEngineMode()); | ||
} | ||
if (getBiEngineReasons() != null) { | ||
biEngineStatisticsPb.setBiEngineReasons( | ||
getBiEngineReasons().stream().map(BiEngineReason::toPb).collect(Collectors.toList())); | ||
} | ||
return biEngineStatisticsPb; | ||
} | ||
|
||
static BiEngineStats fromPb(BiEngineStatistics biEngineStatisticsPb) { | ||
Builder builder = newBuilder(); | ||
if (biEngineStatisticsPb.getBiEngineMode() != null) { | ||
builder.setBiEngineMode(biEngineStatisticsPb.getBiEngineMode()); | ||
} | ||
if (biEngineStatisticsPb.getBiEngineReasons() != null) { | ||
builder.setBiEngineReasons( | ||
biEngineStatisticsPb.getBiEngineReasons().stream() | ||
.map(BiEngineReason::fromPb) | ||
.collect(Collectors.toList())); | ||
} | ||
return builder.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters