content) {
@@ -241,7 +241,7 @@ public Builder ignoreUnknownValues(boolean ignoreUnknownValues) {
* is called use:
* {@code
* String suffixTableId = ...;
- * BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
+ * TableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
* while (suffixTable == null) {
* Thread.sleep(1000L);
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
@@ -307,7 +307,7 @@ public Boolean skipInvalidRows() {
* called use:
* {@code
* String suffixTableId = ...;
- * BaseTableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
+ * TableInfo suffixTable = bigquery.getTable(DATASET, suffixTableId);
* while (suffixTable == null) {
* Thread.sleep(1000L);
* suffixTable = bigquery.getTable(DATASET, suffixTableId);
@@ -371,7 +371,7 @@ public static Builder builder(String datasetId, String tableId, RowToInsert... r
* Returns a builder for an {@code InsertAllRequest} object given the destination table and the
* rows to insert.
*/
- public static Builder builder(BaseTableInfo tableInfo, Iterable rows) {
+ public static Builder builder(TableInfo tableInfo, Iterable rows) {
return builder(tableInfo.tableId(), rows);
}
@@ -379,7 +379,7 @@ public static Builder builder(BaseTableInfo tableInfo, Iterable row
* Returns a builder for an {@code InsertAllRequest} object given the destination table and the
* rows to insert.
*/
- public static Builder builder(BaseTableInfo tableInfo, RowToInsert... rows) {
+ public static Builder builder(TableInfo tableInfo, RowToInsert... rows) {
return builder(tableInfo.tableId(), rows);
}
@@ -414,14 +414,14 @@ public static InsertAllRequest of(String datasetId, String tableId, RowToInsert.
/**
* Returns a {@code InsertAllRequest} object given the destination table and the rows to insert.
*/
- public static InsertAllRequest of(BaseTableInfo tableInfo, Iterable rows) {
+ public static InsertAllRequest of(TableInfo tableInfo, Iterable rows) {
return builder(tableInfo.tableId(), rows).build();
}
/**
* Returns a {@code InsertAllRequest} object given the destination table and the rows to insert.
*/
- public static InsertAllRequest of(BaseTableInfo tableInfo, RowToInsert... rows) {
+ public static InsertAllRequest of(TableInfo tableInfo, RowToInsert... rows) {
return builder(tableInfo.tableId(), rows).build();
}
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Job.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Job.java
index c0d7ddc29c37..1e63344a600d 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Job.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Job.java
@@ -18,50 +18,102 @@
import static com.google.common.base.Preconditions.checkNotNull;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Objects;
+
/**
* A Google BigQuery Job.
*
* Objects of this class are immutable. To get a {@code Job} object with the most recent
- * information use {@link #reload}.
+ * information use {@link #reload}. {@code Job} adds a layer of service-related functionality over
+ * {@link JobInfo}.
*
*/
-public final class Job {
+public final class Job extends JobInfo {
- private final BigQuery bigquery;
- private final JobInfo info;
+ private static final long serialVersionUID = -4324100991693024704L;
- /**
- * Constructs a {@code Job} object for the provided {@code JobInfo}. The BigQuery service
- * is used to issue requests.
- *
- * @param bigquery the BigQuery service used for issuing requests
- * @param info jobs's info
- */
- public Job(BigQuery bigquery, JobInfo info) {
- this.bigquery = checkNotNull(bigquery);
- this.info = checkNotNull(info);
- }
+ private final BigQueryOptions options;
+ private transient BigQuery bigquery;
/**
- * Creates a {@code Job} object for the provided job's user-defined id. Performs an RPC call to
- * get the latest job information.
- *
- * @param bigquery the BigQuery service used for issuing requests
- * @param job job's id, either user-defined or picked by the BigQuery service
- * @param options job options
- * @return the {@code Job} object or {@code null} if not found
- * @throws BigQueryException upon failure
+ * A builder for {@code Job} objects.
*/
- public static Job get(BigQuery bigquery, String job, BigQuery.JobOption... options) {
- JobInfo info = bigquery.getJob(job, options);
- return info != null ? new Job(bigquery, info) : null;
+ public static final class Builder extends JobInfo.Builder {
+
+ private final BigQuery bigquery;
+ private final JobInfo.BuilderImpl infoBuilder;
+
+ Builder(BigQuery bigquery, JobConfiguration configuration) {
+ this.bigquery = bigquery;
+ this.infoBuilder = new JobInfo.BuilderImpl();
+ this.infoBuilder.configuration(configuration);
+ }
+
+ Builder(Job job) {
+ this.bigquery = job.bigquery;
+ this.infoBuilder = new JobInfo.BuilderImpl(job);
+ }
+
+ @Override
+ Builder etag(String etag) {
+ infoBuilder.etag(etag);
+ return this;
+ }
+
+ @Override
+ Builder id(String id) {
+ infoBuilder.id(id);
+ return this;
+ }
+
+ @Override
+ public Builder jobId(JobId jobId) {
+ infoBuilder.jobId(jobId);
+ return this;
+ }
+
+ @Override
+ Builder selfLink(String selfLink) {
+ infoBuilder.selfLink(selfLink);
+ return this;
+ }
+
+ @Override
+ Builder status(JobStatus status) {
+ infoBuilder.status(status);
+ return this;
+ }
+
+ @Override
+ Builder statistics(JobStatistics statistics) {
+ infoBuilder.statistics(statistics);
+ return this;
+ }
+
+ @Override
+ Builder userEmail(String userEmail) {
+ infoBuilder.userEmail(userEmail);
+ return this;
+ }
+
+ @Override
+ public Builder configuration(JobConfiguration configuration) {
+ infoBuilder.configuration(configuration);
+ return this;
+ }
+
+ @Override
+ public Job build() {
+ return new Job(bigquery, infoBuilder);
+ }
}
- /**
- * Returns the job's information.
- */
- public JobInfo info() {
- return info;
+ Job(BigQuery bigquery, JobInfo.BuilderImpl infoBuilder) {
+ super(infoBuilder);
+ this.bigquery = checkNotNull(bigquery);
+ this.options = bigquery.options();
}
/**
@@ -71,7 +123,7 @@ public JobInfo info() {
* @throws BigQueryException upon failure
*/
public boolean exists() {
- return bigquery.getJob(info.jobId(), BigQuery.JobOption.fields()) != null;
+ return bigquery.getJob(jobId(), BigQuery.JobOption.fields()) != null;
}
/**
@@ -90,8 +142,7 @@ public boolean exists() {
* @throws BigQueryException upon failure
*/
public boolean isDone() {
- JobInfo job = bigquery.getJob(info.jobId(),
- BigQuery.JobOption.fields(BigQuery.JobField.STATUS));
+ Job job = bigquery.getJob(jobId(), BigQuery.JobOption.fields(BigQuery.JobField.STATUS));
return job != null && job.status().state() == JobStatus.State.DONE;
}
@@ -103,7 +154,7 @@ public boolean isDone() {
* @throws BigQueryException upon failure
*/
public Job reload(BigQuery.JobOption... options) {
- return Job.get(bigquery, info.jobId().job(), options);
+ return bigquery.getJob(jobId().job(), options);
}
/**
@@ -114,7 +165,7 @@ public Job reload(BigQuery.JobOption... options) {
* @throws BigQueryException upon failure
*/
public boolean cancel() {
- return bigquery.cancel(info.jobId());
+ return bigquery.cancel(jobId());
}
/**
@@ -123,4 +174,30 @@ public boolean cancel() {
public BigQuery bigquery() {
return bigquery;
}
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof Job
+ && Objects.equals(toPb(), ((Job) obj).toPb())
+ && Objects.equals(options, ((Job) obj).options);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), options);
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ this.bigquery = options.service();
+ }
+
+ static Job fromPb(BigQuery bigquery, com.google.api.services.bigquery.model.Job jobPb) {
+ return new Job(bigquery, new JobInfo.BuilderImpl(jobPb));
+ }
}
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobConfiguration.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobConfiguration.java
new file mode 100644
index 000000000000..2244969567ef
--- /dev/null
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobConfiguration.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * 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.gcloud.bigquery;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+/**
+ * Base class for a BigQuery job configuration.
+ */
+public abstract class JobConfiguration implements Serializable {
+
+ private static final long serialVersionUID = -548132177415406526L;
+
+ private final Type type;
+
+ /**
+ * Type of a BigQuery Job.
+ */
+ enum Type {
+ /**
+ * A Copy Job copies an existing table to another new or existing table. Instances of
+ * {@code JobConfiguration} for this type are implemented by {@link CopyJobConfiguration}.
+ */
+ COPY,
+ /**
+ * An Extract Job exports a BigQuery table to Google Cloud Storage. Instances of
+ * {@code JobConfiguration} for this type are implemented by {@link ExtractJobConfiguration}.
+ */
+ EXTRACT,
+ /**
+ * A Load Job loads data from one of several formats into a table. Instances of
+ * {@code JobConfiguration} for this type are implemented by {@link LoadJobConfiguration}.
+ */
+ LOAD,
+ /**
+ * A Query Job runs a query against BigQuery data. Instances of
+ * {@code JobConfiguration} for this type are implemented by {@link QueryJobConfiguration}.
+ */
+ QUERY
+ }
+
+ /**
+ * Base builder for job configurations.
+ *
+ * @param the job configuration type
+ * @param the job configuration builder
+ */
+ public abstract static class Builder> {
+
+ private Type type;
+
+ Builder(Type type) {
+ this.type = checkNotNull(type);
+ }
+
+ @SuppressWarnings("unchecked")
+ B self() {
+ return (B) this;
+ }
+
+ B type(Type type) {
+ this.type = checkNotNull(type);
+ return self();
+ }
+
+ /**
+ * Creates an object.
+ */
+ public abstract T build();
+ }
+
+ JobConfiguration(Builder builder) {
+ this.type = builder.type;
+ }
+
+ /**
+ * Returns the type of the job configuration.
+ */
+ public Type type() {
+ return type;
+ }
+
+ /**
+ * Returns a builder for the object.
+ */
+ public abstract Builder toBuilder();
+
+ ToStringHelper toStringHelper() {
+ return MoreObjects.toStringHelper(this).add("type", type);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper().toString();
+ }
+
+ final int baseHashCode() {
+ return Objects.hash(type);
+ }
+
+ final boolean baseEquals(JobConfiguration jobConfiguration) {
+ return Objects.equals(toPb(), jobConfiguration.toPb());
+ }
+
+ abstract JobConfiguration setProjectId(String projectId);
+
+ abstract com.google.api.services.bigquery.model.JobConfiguration toPb();
+
+ @SuppressWarnings("unchecked")
+ static T fromPb(
+ com.google.api.services.bigquery.model.JobConfiguration configurationPb) {
+ if (configurationPb.getCopy() != null) {
+ return (T) CopyJobConfiguration.fromPb(configurationPb);
+ } else if (configurationPb.getExtract() != null) {
+ return (T) ExtractJobConfiguration.fromPb(configurationPb);
+ } else if (configurationPb.getLoad() != null) {
+ return (T) LoadJobConfiguration.fromPb(configurationPb);
+ } else if (configurationPb.getQuery() != null) {
+ return (T) QueryJobConfiguration.fromPb(configurationPb);
+ } else {
+ // never reached
+ throw new IllegalArgumentException("Job configuration is not supported");
+ }
+ }
+}
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java
index de33c483393d..1adf7fabafc1 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java
@@ -19,23 +19,20 @@
import com.google.api.services.bigquery.model.Job;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
import java.io.Serializable;
import java.util.Objects;
/**
- * Base class for Google BigQuery Job information. Jobs are objects that manage asynchronous tasks
- * such as running queries, loading data, and exporting data. Use {@link CopyJobInfo} for a job that
- * copies an existing table. Use {@link ExtractJobInfo} for a job that exports a table to Google
- * Cloud Storage. Use {@link LoadJobInfo} for a job that loads data from Google Cloud Storage into
- * a table. Use {@link QueryJobInfo} for a job that runs a query.
+ * Google BigQuery Job information. Jobs are objects that manage asynchronous tasks such as running
+ * queries, loading data, and exporting data. Use {@link CopyJobConfiguration} for a job that
+ * copies an existing table. Use {@link ExtractJobConfiguration} for a job that exports a table to
+ * Google Cloud Storage. Use {@link LoadJobConfiguration} for a job that loads data from Google
+ * Cloud Storage into a table. Use {@link QueryJobConfiguration} for a job that runs a query.
*
* @see Jobs
- *
- * @param the statistics type
*/
-public abstract class JobInfo implements Serializable {
+public class JobInfo implements Serializable {
static final Function FROM_PB_FUNCTION =
new Function() {
@@ -44,7 +41,17 @@ public JobInfo apply(Job pb) {
return JobInfo.fromPb(pb);
}
};
- private static final long serialVersionUID = -7086529810736715842L;
+
+ private static final long serialVersionUID = -3272941007234620265L;
+
+ private final String etag;
+ private final String id;
+ private final JobId jobId;
+ private final String selfLink;
+ private final JobStatus status;
+ private final JobStatistics statistics;
+ private final String userEmail;
+ private final JobConfiguration configuration;
/**
* Specifies whether the job is allowed to create new tables.
@@ -81,35 +88,57 @@ public enum WriteDisposition {
WRITE_EMPTY
}
- private final String etag;
- private final String id;
- private final JobId jobId;
- private final String selfLink;
- private final JobStatus status;
- private final S statistics;
- private final String userEmail;
-
/**
- * Base builder for jobs.
- *
- * @param the job type
- * @param the job statistics type
- * @param the job builder
+ * A builder for {@code JobInfo} objects.
*/
- public abstract static class Builder> {
+ public abstract static class Builder {
+
+ abstract Builder etag(String etag);
+
+ abstract Builder id(String id);
+
+ /**
+ * Sets the job identity.
+ */
+ public abstract Builder jobId(JobId jobId);
+
+ abstract Builder selfLink(String selfLink);
+
+ abstract Builder status(JobStatus status);
+
+ abstract Builder statistics(JobStatistics statistics);
+
+ abstract Builder userEmail(String userEmail);
+
+ /**
+ * Sets a configuration for the {@code JobInfo} object. Use {@link CopyJobConfiguration} for a
+ * job that copies an existing table. Use {@link ExtractJobConfiguration} for a job that exports
+ * a table to Google Cloud Storage. Use {@link LoadJobConfiguration} for a job that loads data
+ * from Google Cloud Storage into a table. Use {@link QueryJobConfiguration} for a job that runs
+ * a query.
+ */
+ public abstract Builder configuration(JobConfiguration configuration);
+
+ /**
+ * Creates a {@code JobInfo} object.
+ */
+ public abstract JobInfo build();
+ }
+
+ static final class BuilderImpl extends Builder {
private String etag;
private String id;
private JobId jobId;
private String selfLink;
private JobStatus status;
- private S statistics;
+ private JobStatistics statistics;
private String userEmail;
+ private JobConfiguration configuration;
- protected Builder() {}
+ BuilderImpl() {}
- protected Builder(JobInfo jobInfo) {
+ BuilderImpl(JobInfo jobInfo) {
this.etag = jobInfo.etag;
this.id = jobInfo.id;
this.jobId = jobInfo.jobId;
@@ -117,10 +146,10 @@ protected Builder(JobInfo jobInfo) {
this.status = jobInfo.status;
this.statistics = jobInfo.statistics;
this.userEmail = jobInfo.userEmail;
-
+ this.configuration = jobInfo.configuration;
}
- protected Builder(Job jobPb) {
+ BuilderImpl(Job jobPb) {
this.etag = jobPb.getEtag();
this.id = jobPb.getId();
if (jobPb.getJobReference() != null) {
@@ -134,55 +163,64 @@ protected Builder(Job jobPb) {
this.statistics = JobStatistics.fromPb(jobPb.getStatistics());
}
this.userEmail = jobPb.getUserEmail();
+ this.configuration = JobConfiguration.fromPb(jobPb.getConfiguration());
}
- @SuppressWarnings("unchecked")
- protected B self() {
- return (B) this;
- }
-
- B etag(String etag) {
+ @Override
+ Builder etag(String etag) {
this.etag = etag;
- return self();
+ return this;
}
- B id(String id) {
+ @Override
+ Builder id(String id) {
this.id = id;
- return self();
+ return this;
}
- /**
- * Sets the job identity.
- */
- public B jobId(JobId jobId) {
+ @Override
+ public Builder jobId(JobId jobId) {
this.jobId = jobId;
- return self();
+ return this;
}
- B selfLink(String selfLink) {
+ @Override
+ Builder selfLink(String selfLink) {
this.selfLink = selfLink;
- return self();
+ return this;
}
- B status(JobStatus status) {
+ @Override
+ Builder status(JobStatus status) {
this.status = status;
- return self();
+ return this;
}
- B statistics(S statistics) {
+ @Override
+ Builder statistics(JobStatistics statistics) {
this.statistics = statistics;
- return self();
+ return this;
}
- B userEmail(String userEmail) {
+ @Override
+ Builder userEmail(String userEmail) {
this.userEmail = userEmail;
- return self();
+ return this;
}
- public abstract T build();
+ @Override
+ public Builder configuration(JobConfiguration configuration) {
+ this.configuration = configuration;
+ return this;
+ }
+
+ @Override
+ public JobInfo build() {
+ return new JobInfo(this);
+ }
}
- protected JobInfo(Builder extends JobInfo, ? extends S, ?> builder) {
+ JobInfo(BuilderImpl builder) {
this.jobId = builder.jobId;
this.etag = builder.etag;
this.id = builder.id;
@@ -190,6 +228,7 @@ protected JobInfo(Builder extends JobInfo, ? extends S, ?> builder) {
this.status = builder.status;
this.statistics = builder.statistics;
this.userEmail = builder.userEmail;
+ this.configuration = builder.configuration;
}
/**
@@ -232,8 +271,9 @@ public JobStatus status() {
/**
* Returns information about the job, including starting time and ending time of the job.
*/
- public S statistics() {
- return statistics;
+ @SuppressWarnings("unchecked")
+ public S statistics() {
+ return (S) statistics;
}
/**
@@ -244,11 +284,22 @@ public String userEmail() {
}
/**
- * Returns a builder for the job.
+ * Returns the job's configuration.
+ */
+ @SuppressWarnings("unchecked")
+ public C configuration() {
+ return (C) configuration;
+ }
+
+ /**
+ * Returns a builder for the job object.
*/
- public abstract Builder toBuilder();
+ public Builder toBuilder() {
+ return new BuilderImpl(this);
+ }
- ToStringHelper toStringHelper() {
+ @Override
+ public String toString() {
return MoreObjects.toStringHelper(this)
.add("job", jobId)
.add("status", status)
@@ -256,12 +307,9 @@ ToStringHelper toStringHelper() {
.add("userEmail", userEmail)
.add("etag", etag)
.add("id", id)
- .add("selfLink", selfLink);
- }
-
- @Override
- public String toString() {
- return toStringHelper().toString();
+ .add("selfLink", selfLink)
+ .add("configuration", configuration)
+ .toString();
}
@Override
@@ -271,7 +319,13 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {
- return obj instanceof JobInfo && Objects.equals(toPb(), ((JobInfo) obj).toPb());
+ return obj != null
+ && obj.getClass().equals(JobInfo.class)
+ && Objects.equals(toPb(), ((JobInfo) obj).toPb());
+ }
+
+ JobInfo setProjectId(String projectId) {
+ return toBuilder().configuration(configuration.setProjectId(projectId)).build();
}
Job toPb() {
@@ -289,22 +343,44 @@ Job toPb() {
if (statistics != null) {
jobPb.setStatistics(statistics.toPb());
}
+ jobPb.setConfiguration(configuration.toPb());
return jobPb;
}
- @SuppressWarnings("unchecked")
- static T fromPb(Job jobPb) {
- if (jobPb.getConfiguration().getLoad() != null) {
- return (T) LoadJobInfo.fromPb(jobPb);
- } else if (jobPb.getConfiguration().getCopy() != null) {
- return (T) CopyJobInfo.fromPb(jobPb);
- } else if (jobPb.getConfiguration().getExtract() != null) {
- return (T) ExtractJobInfo.fromPb(jobPb);
- } else if (jobPb.getConfiguration().getQuery() != null) {
- return (T) QueryJobInfo.fromPb(jobPb);
- } else {
- // never reached
- throw new IllegalArgumentException("Job configuration is not supported");
- }
+ /**
+ * Returns a builder for a {@code JobInfo} object given the job configuration. Use
+ * {@link CopyJobConfiguration} for a job that copies an existing table. Use
+ * {@link ExtractJobConfiguration} for a job that exports a table to Google Cloud Storage. Use
+ * {@link LoadJobConfiguration} for a job that loads data from Google Cloud Storage into a table.
+ * Use {@link QueryJobConfiguration} for a job that runs a query.
+ */
+ public static Builder builder(JobConfiguration configuration) {
+ return new BuilderImpl().configuration(configuration);
+ }
+
+ /**
+ * Returns a {@code JobInfo} object given the job configuration. Use {@link CopyJobConfiguration}
+ * for a job that copies an existing table. Use {@link ExtractJobConfiguration} for a job that
+ * exports a table to Google Cloud Storage. Use {@link LoadJobConfiguration} for a job that loads
+ * data from Google Cloud Storage into a table. Use {@link QueryJobConfiguration} for a job that
+ * runs a query.
+ */
+ public static JobInfo of(JobConfiguration configuration) {
+ return builder(configuration).build();
+ }
+
+ /**
+ * Returns a builder for a {@code JobInfo} object given the job identity and configuration. Use
+ * {@link CopyJobConfiguration} for a job that copies an existing table. Use
+ * {@link ExtractJobConfiguration} for a job that exports a table to Google Cloud Storage. Use
+ * {@link LoadJobConfiguration} for a job that loads data from Google Cloud Storage into a table.
+ * Use {@link QueryJobConfiguration} for a job that runs a query.
+ */
+ public static JobInfo of(JobId jobId, JobConfiguration configuration) {
+ return builder(configuration).jobId(jobId).build();
+ }
+
+ static JobInfo fromPb(Job jobPb) {
+ return new BuilderImpl(jobPb).build();
}
}
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobStatistics.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobStatistics.java
index b2d50882aabb..34e4917921ba 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobStatistics.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobStatistics.java
@@ -61,7 +61,7 @@ private ExtractStatistics(Builder builder) {
/**
* Returns the number of files per destination URI or URI pattern specified in the extract job.
* These values will be in the same order as the URIs specified by
- * {@link ExtractJobInfo#destinationUris()}.
+ * {@link ExtractJobConfiguration#destinationUris()}.
*/
public List destinationUriFileCounts() {
return destinationUriFileCounts;
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadConfiguration.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadConfiguration.java
index 18cb8ae6bedb..223a25a478e0 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadConfiguration.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadConfiguration.java
@@ -16,103 +16,26 @@
package com.google.gcloud.bigquery;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.api.services.bigquery.model.JobConfigurationLoad;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
import com.google.gcloud.bigquery.JobInfo.CreateDisposition;
import com.google.gcloud.bigquery.JobInfo.WriteDisposition;
-import java.io.Serializable;
-import java.nio.channels.SeekableByteChannel;
import java.util.List;
-import java.util.Objects;
/**
- * Google BigQuery Configuration for a load operation. A load configuration can be used to build a
- * {@link LoadJobInfo} or to load data into a table with a {@link com.google.gcloud.WriteChannel}
- * ({@link BigQuery#writer(LoadConfiguration)}).
+ * Common interface for a load configuration. A load configuration
+ * ({@link WriteChannelConfiguration}) can be used to load data into a table with a
+ * {@link com.google.gcloud.WriteChannel} ({@link BigQuery#writer(WriteChannelConfiguration)}).
+ * A load configuration ({@link LoadJobConfiguration}) can also be used to create a load job
+ * ({@link JobInfo#of(JobConfiguration)}).
*/
-public class LoadConfiguration implements Serializable {
-
- private static final long serialVersionUID = 470267591917413578L;
-
- private final TableId destinationTable;
- private final CreateDisposition createDisposition;
- private final WriteDisposition writeDisposition;
- private final FormatOptions formatOptions;
- private final Integer maxBadRecords;
- private final Schema schema;
- private final Boolean ignoreUnknownValues;
- private final List