@@ -43,6 +43,7 @@ public abstract class JobStatistics implements Serializable {
4343 private final Long numChildJobs ;
4444 private final String parentJobId ;
4545 private final ScriptStatistics scriptStatistics ;
46+ private final List <ReservationUsage > reservationUsage ;
4647
4748 /** A Google BigQuery Copy Job statistics. */
4849 public static class CopyStatistics extends JobStatistics {
@@ -1047,6 +1048,118 @@ static ScriptStatistics fromPb(
10471048 }
10481049 }
10491050
1051+ /** ReservationUsage contains information about a job's usage of a single reservation. */
1052+ public static class ReservationUsage {
1053+
1054+ static final Function <
1055+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage , ReservationUsage >
1056+ FROM_PB_FUNCTION =
1057+ new Function <
1058+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage ,
1059+ ReservationUsage >() {
1060+ @ Override
1061+ public ReservationUsage apply (
1062+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage usage ) {
1063+ return ReservationUsage .fromPb (usage );
1064+ }
1065+ };
1066+
1067+ static final Function <
1068+ ReservationUsage , com .google .api .services .bigquery .model .JobStatistics .ReservationUsage >
1069+ TO_PB_FUNCTION =
1070+ new Function <
1071+ ReservationUsage ,
1072+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage >() {
1073+ @ Override
1074+ public com .google .api .services .bigquery .model .JobStatistics .ReservationUsage apply (
1075+ ReservationUsage usage ) {
1076+ return usage .toPb ();
1077+ }
1078+ };
1079+
1080+ private final String name ;
1081+ private final Long slotMs ;
1082+
1083+ public static class Builder {
1084+
1085+ private String name ;
1086+ private Long slotMs ;
1087+
1088+ private Builder () {};
1089+
1090+ Builder setName (String name ) {
1091+ this .name = name ;
1092+ return this ;
1093+ }
1094+
1095+ Builder setSlotMs (Long slotMs ) {
1096+ this .slotMs = slotMs ;
1097+ return this ;
1098+ }
1099+
1100+ ReservationUsage build () {
1101+ return new ReservationUsage (this );
1102+ }
1103+ }
1104+
1105+ private ReservationUsage (Builder builder ) {
1106+ this .name = builder .name ;
1107+ this .slotMs = builder .slotMs ;
1108+ }
1109+
1110+ // Return mame indicates the utilized reservation name, or "unreserved" for ondemand usage.
1111+ public String getName () {
1112+ return name ;
1113+ }
1114+
1115+ // Returns slotMs reports the slot milliseconds utilized within in the given reservation.
1116+ public Long getSlotMs () {
1117+ return slotMs ;
1118+ }
1119+
1120+ static Builder newBuilder () {
1121+ return new Builder ();
1122+ }
1123+
1124+ ToStringHelper toStringHelper () {
1125+ return MoreObjects .toStringHelper (this ).add ("name" , name ).add ("slotMs" , slotMs );
1126+ }
1127+
1128+ @ Override
1129+ public String toString () {
1130+ return toStringHelper ().toString ();
1131+ }
1132+
1133+ @ Override
1134+ public boolean equals (Object obj ) {
1135+ return obj == this
1136+ || obj != null
1137+ && obj .getClass ().equals (ReservationUsage .class )
1138+ && Objects .equals (toPb (), ((ReservationUsage ) obj ).toPb ());
1139+ }
1140+
1141+ @ Override
1142+ public int hashCode () {
1143+ return Objects .hash (name , slotMs );
1144+ }
1145+
1146+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage toPb () {
1147+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage usage =
1148+ new com .google .api .services .bigquery .model .JobStatistics .ReservationUsage ();
1149+ usage .setName (name );
1150+ usage .setSlotMs (slotMs );
1151+ return usage ;
1152+ }
1153+
1154+ static ReservationUsage fromPb (
1155+ com .google .api .services .bigquery .model .JobStatistics .ReservationUsage usage ) {
1156+ Builder builder = newBuilder ();
1157+ builder .setName (usage .getName ());
1158+ builder .setSlotMs (usage .getSlotMs ());
1159+ return builder .build ();
1160+ }
1161+ }
1162+
10501163 abstract static class Builder <T extends JobStatistics , B extends Builder <T , B >> {
10511164
10521165 private Long creationTime ;
@@ -1055,6 +1168,7 @@ abstract static class Builder<T extends JobStatistics, B extends Builder<T, B>>
10551168 private Long numChildJobs ;
10561169 private String parentJobId ;
10571170 private ScriptStatistics scriptStatistics ;
1171+ private List <ReservationUsage > reservationUsage ;
10581172
10591173 protected Builder () {}
10601174
@@ -1067,6 +1181,10 @@ protected Builder(com.google.api.services.bigquery.model.JobStatistics statistic
10671181 if (statisticsPb .getScriptStatistics () != null ) {
10681182 this .scriptStatistics = ScriptStatistics .fromPb (statisticsPb .getScriptStatistics ());
10691183 }
1184+ if (reservationUsage != null ) {
1185+ this .reservationUsage =
1186+ Lists .transform (statisticsPb .getReservationUsage (), ReservationUsage .FROM_PB_FUNCTION );
1187+ }
10701188 }
10711189
10721190 @ SuppressWarnings ("unchecked" )
@@ -1099,6 +1217,7 @@ protected JobStatistics(Builder builder) {
10991217 this .numChildJobs = builder .numChildJobs ;
11001218 this .parentJobId = builder .parentJobId ;
11011219 this .scriptStatistics = builder .scriptStatistics ;
1220+ this .reservationUsage = builder .reservationUsage ;
11021221 }
11031222
11041223 /** Returns the creation time of the job in milliseconds since epoch. */
@@ -1137,14 +1256,20 @@ public ScriptStatistics getScriptStatistics() {
11371256 return scriptStatistics ;
11381257 }
11391258
1259+ /** ReservationUsage contains information about a job's usage of a single reservation. */
1260+ public List <ReservationUsage > getReservationUsage () {
1261+ return reservationUsage ;
1262+ }
1263+
11401264 ToStringHelper toStringHelper () {
11411265 return MoreObjects .toStringHelper (this )
11421266 .add ("creationTime" , creationTime )
11431267 .add ("endTime" , endTime )
11441268 .add ("startTime" , startTime )
11451269 .add ("numChildJobs" , numChildJobs )
11461270 .add ("parentJobId" , parentJobId )
1147- .add ("scriptStatistics" , scriptStatistics );
1271+ .add ("scriptStatistics" , scriptStatistics )
1272+ .add ("reservationUsage" , reservationUsage );
11481273 }
11491274
11501275 @ Override
@@ -1154,7 +1279,13 @@ public String toString() {
11541279
11551280 final int baseHashCode () {
11561281 return Objects .hash (
1157- creationTime , endTime , startTime , numChildJobs , parentJobId , scriptStatistics );
1282+ creationTime ,
1283+ endTime ,
1284+ startTime ,
1285+ numChildJobs ,
1286+ parentJobId ,
1287+ scriptStatistics ,
1288+ reservationUsage );
11581289 }
11591290
11601291 final boolean baseEquals (JobStatistics jobStatistics ) {
@@ -1172,6 +1303,10 @@ com.google.api.services.bigquery.model.JobStatistics toPb() {
11721303 if (scriptStatistics != null ) {
11731304 statistics .setScriptStatistics (scriptStatistics .toPb ());
11741305 }
1306+ if (reservationUsage != null ) {
1307+ statistics .setReservationUsage (
1308+ Lists .transform (reservationUsage , ReservationUsage .TO_PB_FUNCTION ));
1309+ }
11751310 return statistics ;
11761311 }
11771312
0 commit comments