From e91f47b893db5a07b11c6d21299ae9a87165af7e Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Thu, 17 Dec 2015 11:51:21 +0100 Subject: [PATCH 1/2] Make checkstyle happy, fix minor issues, add better javadoc --- .../java/com/google/gcloud/bigquery/Acl.java | 36 ++++++++++--------- .../google/gcloud/bigquery/BaseTableInfo.java | 9 +++-- .../google/gcloud/bigquery/CsvOptions.java | 3 ++ .../com/google/gcloud/bigquery/DatasetId.java | 6 ++-- .../google/gcloud/bigquery/DatasetInfo.java | 4 +-- .../gcloud/bigquery/ExternalTableInfo.java | 6 ++-- .../com/google/gcloud/bigquery/Field.java | 8 ++--- .../com/google/gcloud/bigquery/JobId.java | 4 +-- .../com/google/gcloud/bigquery/JobInfo.java | 2 +- .../google/gcloud/bigquery/QueryRequest.java | 29 ++++++++++++++- .../google/gcloud/bigquery/QueryResponse.java | 7 ++-- .../com/google/gcloud/bigquery/Schema.java | 4 +-- .../com/google/gcloud/bigquery/TableId.java | 2 +- .../com/google/gcloud/bigquery/TableInfo.java | 6 ++-- .../gcloud/bigquery/UserDefinedFunction.java | 5 +-- .../com/google/gcloud/bigquery/ViewInfo.java | 14 ++++---- .../google/gcloud/bigquery/TableInfoTest.java | 6 ++-- 17 files changed, 94 insertions(+), 57 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java index 610f818e6cb9..df6beef865ca 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java @@ -48,10 +48,12 @@ public enum Role { * Can read, query, copy or export tables in the dataset. */ READER, + /** * Same as {@link #READER} plus can edit or append data in the dataset. */ WRITER, + /** * Same as {@link #WRITER} plus can update and delete the dataset. */ @@ -61,7 +63,7 @@ public enum Role { /** * Base class for BigQuery entities that can be grant access to the dataset. */ - public static abstract class Entity implements Serializable { + public abstract static class Entity implements Serializable { private static final long serialVersionUID = 8111776788607959944L; @@ -132,14 +134,14 @@ public String domain() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null || getClass() != o.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - Domain domainEntity = (Domain) o; + Domain domainEntity = (Domain) obj; return Objects.equals(type(), domainEntity.type()) && Objects.equals(domain, domainEntity.domain()); } @@ -196,14 +198,14 @@ public String identifier() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null || getClass() != o.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - Group group = (Group) o; + Group group = (Group) obj; return Objects.equals(type(), group.type()) && Objects.equals(identifier, group.identifier); } @@ -288,14 +290,14 @@ public String email() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null || getClass() != o.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - User user = (User) o; + User user = (User) obj; return Objects.equals(type(), user.type()) && Objects.equals(email, user.email); } @@ -341,14 +343,14 @@ public TableId id() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null || getClass() != o.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - View view = (View) o; + View view = (View) obj; return Objects.equals(type(), view.type()) && Objects.equals(id, view.id); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java index 8845179b31c5..eedb78381b59 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java @@ -24,6 +24,7 @@ import com.google.api.services.bigquery.model.Table; 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.math.BigInteger; @@ -63,12 +64,14 @@ public enum Type { * A normal BigQuery table. */ TABLE, + /** * A virtual table defined by a SQL query. * * @see Views */ VIEW, + /** * A BigQuery table backed by external data. * @@ -137,7 +140,7 @@ public boolean equals(Object obj) { && Objects.equals(toPb(), ((StreamingBuffer) obj).toPb()); } - public Streamingbuffer toPb() { + Streamingbuffer toPb() { return new Streamingbuffer() .setEstimatedBytes(BigInteger.valueOf(estimatedBytes)) .setEstimatedRows(BigInteger.valueOf(estimatedRows)) @@ -165,7 +168,7 @@ static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) { private final Long expirationTime; private final Long lastModifiedTime; - public static abstract class Builder> { + public abstract static class Builder> { private String etag; private String id; @@ -429,7 +432,7 @@ public Long lastModifiedTime() { */ public abstract Builder toBuilder(); - protected MoreObjects.ToStringHelper toStringHelper() { + ToStringHelper toStringHelper() { return MoreObjects.toStringHelper(this) .add("tableId", tableId) .add("type", type) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java index 40655e2c0c36..274ef5678a8a 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CsvOptions.java @@ -190,6 +190,9 @@ public Integer skipLeadingRows() { return skipLeadingRows; } + /** + * Returns a builder for the {@code CsvOptions} object. + */ public Builder toBuilder() { return new Builder() .allowJaggedRows(allowJaggedRows) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetId.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetId.java index b0da5603d929..942322ea51d3 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetId.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetId.java @@ -34,7 +34,7 @@ public class DatasetId implements Serializable { private final String dataset; /** - * Returns project's user-defined id + * Returns project's user-defined id. */ public String project() { return project; @@ -81,11 +81,11 @@ public String toString() { return toPb().toString(); } - public DatasetReference toPb() { + DatasetReference toPb() { return new DatasetReference().setProjectId(project).setDatasetId(dataset); } - public static DatasetId fromPb(DatasetReference datasetRef) { + static DatasetId fromPb(DatasetReference datasetRef) { return new DatasetId( datasetRef.getProjectId(), datasetRef.getDatasetId()); diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java index 773c314f8060..95897ba3a801 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/DatasetInfo.java @@ -384,8 +384,8 @@ static DatasetInfo fromPb(Dataset datasetPb) { builder.acl(Lists.transform(datasetPb.getAccess(), new Function() { @Override - public Acl apply(Dataset.Access f) { - return Acl.fromPb(f); + public Acl apply(Dataset.Access accessPb) { + return Acl.fromPb(accessPb); } })); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java index 775a0294db77..4bdd1e4159db 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.api.services.bigquery.model.Table; -import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; /** * Google BigQuery External Table information. BigQuery's external tables are tables whose data @@ -100,7 +100,7 @@ private ExternalTableInfo(Builder builder) { */ public ExternalDataConfiguration configuration() { return configuration; - }; + } /** * Returns information on the table's streaming buffer if any exists. Returns {@code null} if no @@ -119,7 +119,7 @@ public Builder toBuilder() { } @Override - protected MoreObjects.ToStringHelper toStringHelper() { + ToStringHelper toStringHelper() { return super.toStringHelper() .add("configuration", configuration) .add("streamingBuffer", streamingBuffer); diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Field.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Field.java index 54fdb9f50329..55fae44c5eed 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Field.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Field.java @@ -32,10 +32,10 @@ import java.util.Objects; /** - * Google BigQuery Table field. A table field has a name, a value, a mode and possibly a description. - * Supported types are: {@link Type#integer()}, {@link Type#bool()}, {@link Type#string()}, - * {@link Type#floatingPoint()}, {@link Type#timestamp()} and {@link Type#record(Field...)}. One or - * more fields form a table's schema. + * Google BigQuery Table field. A table field has a name, a value, a mode and possibly a + * description. Supported types are: {@link Type#integer()}, {@link Type#bool()}, + * {@link Type#string()}, {@link Type#floatingPoint()}, {@link Type#timestamp()} and + * {@link Type#record(Field...)}. One or more fields form a table's schema. */ public class Field implements Serializable { diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobId.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobId.java index 43f54a0502aa..898c894f9a21 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobId.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobId.java @@ -47,9 +47,9 @@ public String job() { return job; } - private JobId(String project, String dataset) { + private JobId(String project, String job) { this.project = project; - this.job = dataset; + this.job = job; } /** 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 317f7cc0bde5..6d7efc147d25 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 @@ -241,7 +241,7 @@ public String userEmail() { ToStringHelper toStringHelper() { return MoreObjects.toStringHelper(this) - .add("jobId", jobId) + .add("job", jobId) .add("status", status) .add("statistics", statistics) .add("userEmail", userEmail) diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java index d64994e69c76..5ef68d7b9e15 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java @@ -27,7 +27,34 @@ * Google Cloud BigQuery Query Request. This class can be used to run a BigQuery SQL query and * return results if the query completes within a specified timeout. The query results are saved to * a temporary table that is deleted approximately 24 hours after the query is run. The query is run - * through a BigQuery Job whose identity can be accessed via {@link QueryResponse#jobId()}. + * through a BigQuery Job whose identity can be accessed via {@link QueryResponse#jobId()}. If the + * query does not complete within the provided {@link Builder#maxWaitTime(Long)} the response + * returned by {@link BigQuery#query(QueryRequest)} will have {@link QueryResponse#jobComplete()} + * set to {@code false} and {@link QueryResponse#result()} set to {@code null}. To obtain query + * results you can use {@link BigQuery#getQueryResults(JobId, BigQuery.QueryResultsOption...)} until + * {@link QueryResponse#jobComplete()} returns {@code true}. + * + *

Example usage of a query request: + *

    {@code
+ *    QueryRequest request = QueryRequest.builder("SELECT field FROM table")
+ *      .defaultDataset(DatasetId.of("dataset"))
+ *      .maxWaitTime(60000L)
+ *      .maxResults(1000L)
+ *      .build();
+ *    QueryResponse response = bigquery.query(request);
+ *    while (!response.jobComplete()) {
+ *      Thread.sleep(1000);
+ *      response = bigquery.getQueryResults(response.jobId());
+ *    }
+ *    List executionErrors = response.executionErrors();
+ *    // look for errors in executionErrors
+ *    QueryResult result = response.result();
+ *    Iterator> rowIterator = result.iterateAll();
+ *    while(rowIterator.hasNext()) {
+ *      List row = rowIterator.next();
+ *      // do something with row
+ *    }
+ * }
* * @see Query * @see Query Reference diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java index b7bd5dc0efd0..8ef8351d9e1a 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryResponse.java @@ -24,15 +24,16 @@ import java.util.Objects; /** - * Google Cloud BigQuery Query Response. This class contains the results of a Query Job or of a - * Query Request. + * Google Cloud BigQuery Query Response. This class contains the results of a Query Job + * ({@link BigQuery#getQueryResults(JobId, BigQuery.QueryResultsOption...)}) or of a + * Query Request ({@link BigQuery#query(QueryRequest)}). * *

Example usage of a query response: *

    {@code
  *    QueryResponse response = bigquery.query(request);
  *    while (!response.jobComplete()) {
- *      response = bigquery.getQueryResults(response.jobId());
  *      Thread.sleep(1000);
+ *      response = bigquery.getQueryResults(response.jobId());
  *    }
  *    List executionErrors = response.executionErrors();
  *    // look for errors in executionErrors
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Schema.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Schema.java
index 0ac6e1b84ade..787bb0d7f35f 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Schema.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Schema.java
@@ -96,8 +96,8 @@ public Schema build() {
   }
 
   private Schema(Builder builder) {
-    this.fields = builder.fields != null ? ImmutableList.copyOf(builder.fields) :
-        ImmutableList.of();
+    this.fields = builder.fields != null ? ImmutableList.copyOf(builder.fields)
+        : ImmutableList.of();
   }
 
   /**
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableId.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableId.java
index 6747dbf9923f..7a4e0bbb38b4 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableId.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableId.java
@@ -50,7 +50,7 @@ public TableReference apply(TableId tableId) {
   private final String table;
 
   /**
-   * Returns project's user-defined id
+   * Returns project's user-defined id.
    */
   public String project() {
     return project;
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
index 6594a3f25a67..74dc487825c6 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
@@ -17,7 +17,7 @@
 package com.google.gcloud.bigquery;
 
 import com.google.api.services.bigquery.model.Table;
-import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 
 /**
  * A Google BigQuery Table information. A BigQuery table is a standard, two-dimensional table with
@@ -110,7 +110,7 @@ public static Builder builder(TableId tableId, Schema schema) {
   }
 
   /**
-   * Creates BigQuery table given its type
+   * Creates BigQuery table given its type.
    *
    * @param tableId table id
    * @param schema the schema of the table
@@ -128,7 +128,7 @@ public Builder toBuilder() {
   }
 
   @Override
-  protected MoreObjects.ToStringHelper toStringHelper() {
+  ToStringHelper toStringHelper() {
     return super.toStringHelper()
         .add("location", location)
         .add("streamingBuffer", streamingBuffer);
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/UserDefinedFunction.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/UserDefinedFunction.java
index 931c1eaf024a..2135e0ddc941 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/UserDefinedFunction.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/UserDefinedFunction.java
@@ -13,7 +13,8 @@
  * and produces zero or more rows as output. The output can potentially have a different schema than
  * the input.
  *
- * @see User-Defined Functions
+ * @see User-Defined Functions
+ *     
  */
 public abstract class UserDefinedFunction implements Serializable {
 
@@ -137,7 +138,7 @@ public static UserDefinedFunction fromUri(String functionDefinition) {
     return new UriFunction(functionDefinition);
   }
 
-  public static UserDefinedFunction fromPb(
+  static UserDefinedFunction fromPb(
       com.google.api.services.bigquery.model.UserDefinedFunctionResource pb) {
     if (pb.getInlineCode() != null) {
       return new InlineFunction(pb.getInlineCode());
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java
index 01e07663b363..771a7a679c11 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java
@@ -20,7 +20,7 @@
 
 import com.google.api.services.bigquery.model.Table;
 import com.google.api.services.bigquery.model.ViewDefinition;
-import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 
@@ -76,8 +76,8 @@ public Builder query(String query) {
     /**
      * Sets user defined functions that can be used by {@link #query()}.
      *
-     * @see User-Defined Functions
-     *     
+     * @see User-Defined
+     *     Functions
      */
     public Builder userDefinedFunctions(List userDefinedFunctions) {
       this.userDefinedFunctions = ImmutableList.copyOf(checkNotNull(userDefinedFunctions));
@@ -87,8 +87,8 @@ public Builder userDefinedFunctions(List userDefinedFunctio
     /**
      * Sets user defined functions that can be used by {@link #query()}.
      *
-     * @see User-Defined Functions
-     *     
+     * @see User-Defined
+     *     Functions
      */
     public Builder userDefinedFunctions(UserDefinedFunction... userDefinedFunctions) {
       this.userDefinedFunctions = ImmutableList.copyOf(userDefinedFunctions);
@@ -115,7 +115,7 @@ private ViewInfo(Builder builder) {
    */
   public String query() {
     return query;
-  };
+  }
 
   /**
    * Returns user defined functions that can be used by {@link #query()}. Returns {@code null} if
@@ -137,7 +137,7 @@ public Builder toBuilder() {
   }
 
   @Override
-  protected MoreObjects.ToStringHelper toStringHelper() {
+  ToStringHelper toStringHelper() {
     return super.toStringHelper()
         .add("query", query)
         .add("userDefinedFunctions", userDefinedFunctions);
diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
index f9e073906578..e32ee2516b6b 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
@@ -98,8 +98,8 @@ public class TableInfoTest {
           .selfLink(SELF_LINK)
           .streamingBuffer(STREAMING_BUFFER)
           .build();
-  private static List USER_DEFINED_FUNCTIONS = ImmutableList.of(
-      UserDefinedFunction.inline("Function"), UserDefinedFunction.fromUri("URI"));
+  private static final List USER_DEFINED_FUNCTIONS =
+      ImmutableList.of(UserDefinedFunction.inline("Function"), UserDefinedFunction.fromUri("URI"));
   private static final ViewInfo VIEW_INFO =
       ViewInfo.builder(TABLE_ID, VIEW_QUERY, USER_DEFINED_FUNCTIONS)
           .creationTime(CREATION_TIME)
@@ -190,7 +190,7 @@ public void testBuilder() {
 
   @Test
   public void testToAndFromPb() {
-    assertTrue(BaseTableInfo.fromPb(TABLE_INFO.toPb()) instanceof BaseTableInfo);
+    assertTrue(BaseTableInfo.fromPb(TABLE_INFO.toPb()) instanceof TableInfo);
     compareTableInfo(TABLE_INFO, BaseTableInfo.fromPb(TABLE_INFO.toPb()));
     assertTrue(BaseTableInfo.fromPb(VIEW_INFO.toPb()) instanceof ViewInfo);
     compareViewInfo(VIEW_INFO, BaseTableInfo.fromPb(VIEW_INFO.toPb()));

From f569bddb8405cd485ce57206574af1f1eedc899b Mon Sep 17 00:00:00 2001
From: Marco Ziccardi 
Date: Thu, 17 Dec 2015 12:05:05 +0100
Subject: [PATCH 2/2] Move StreamingBuffer to TableInfo, remove streamingBuffer
 from ExternalTableInfo

---
 .../google/gcloud/bigquery/BaseTableInfo.java | 74 -----------------
 .../gcloud/bigquery/ExternalTableInfo.java    | 35 ++------
 .../google/gcloud/bigquery/QueryRequest.java  |  3 +-
 .../com/google/gcloud/bigquery/TableInfo.java | 79 +++++++++++++++++++
 .../google/gcloud/spi/DefaultBigQueryRpc.java |  4 +-
 .../google/gcloud/bigquery/OptionTest.java    |  2 +-
 .../gcloud/bigquery/QueryResultTest.java      |  4 +-
 .../gcloud/bigquery/SerializationTest.java    |  5 +-
 .../google/gcloud/bigquery/TableInfoTest.java |  6 +-
 9 files changed, 94 insertions(+), 118 deletions(-)

diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java
index eedb78381b59..16d2af6f4580 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java
@@ -20,7 +20,6 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import com.google.api.client.util.Data;
-import com.google.api.services.bigquery.model.Streamingbuffer;
 import com.google.api.services.bigquery.model.Table;
 import com.google.common.base.Function;
 import com.google.common.base.MoreObjects;
@@ -81,79 +80,6 @@ public enum Type {
     EXTERNAL
   }
 
-  /**
-   * Google BigQuery Table's Streaming Buffer information. This class contains information on a
-   * table's streaming buffer as the estimated size in number of rows/bytes.
-   */
-  public static class StreamingBuffer implements Serializable {
-
-    private static final long serialVersionUID = -6713971364725267597L;
-    private final long estimatedRows;
-    private final long estimatedBytes;
-    private final long oldestEntryTime;
-
-    StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) {
-      this.estimatedRows = estimatedRows;
-      this.estimatedBytes = estimatedBytes;
-      this.oldestEntryTime = oldestEntryTime;
-    }
-
-    /**
-     * Returns a lower-bound estimate of the number of rows currently in the streaming buffer.
-     */
-    public long estimatedRows() {
-      return estimatedRows;
-    }
-
-    /**
-     * Returns a lower-bound estimate of the number of bytes currently in the streaming buffer.
-     */
-    public long estimatedBytes() {
-      return estimatedBytes;
-    }
-
-    /**
-     * Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since
-     * epoch.
-     */
-    public long oldestEntryTime() {
-      return oldestEntryTime;
-    }
-
-    @Override
-    public String toString() {
-      return MoreObjects.toStringHelper(this)
-          .add("estimatedRows", estimatedRows)
-          .add("estimatedBytes", estimatedBytes)
-          .add("oldestEntryTime", oldestEntryTime)
-          .toString();
-    }
-
-    @Override
-    public int hashCode() {
-      return Objects.hash(estimatedRows, estimatedBytes, oldestEntryTime);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-      return obj instanceof StreamingBuffer
-          && Objects.equals(toPb(), ((StreamingBuffer) obj).toPb());
-    }
-
-    Streamingbuffer toPb() {
-      return new Streamingbuffer()
-          .setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
-          .setEstimatedRows(BigInteger.valueOf(estimatedRows))
-          .setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
-    }
-
-    static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
-      return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(),
-          streamingBufferPb.getEstimatedBytes().longValue(),
-          streamingBufferPb.getOldestEntryTime().longValue());
-    }
-  }
-
   private final String etag;
   private final String id;
   private final String selfLink;
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java
index 4bdd1e4159db..177f8a7db2b8 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java
@@ -26,27 +26,24 @@
  * reside outside of BigQuery but can be queried as normal BigQuery tables. External tables are
  * experimental and might be subject to change or removed.
  *
- * @see Federated Data
- *     Sources
+ * @see Federated Data Sources
+ *     
  */
 public class ExternalTableInfo extends BaseTableInfo {
 
   private static final long serialVersionUID = -5893406738246214865L;
 
   private final ExternalDataConfiguration configuration;
-  private final StreamingBuffer streamingBuffer;
 
   public static final class Builder extends BaseTableInfo.Builder {
 
     private ExternalDataConfiguration configuration;
-    private StreamingBuffer streamingBuffer;
 
     private Builder() {}
 
     private Builder(ExternalTableInfo tableInfo) {
       super(tableInfo);
       this.configuration = tableInfo.configuration;
-      this.streamingBuffer = tableInfo.streamingBuffer;
     }
 
     protected Builder(Table tablePb) {
@@ -55,9 +52,6 @@ protected Builder(Table tablePb) {
         this.configuration =
             ExternalDataConfiguration.fromPb(tablePb.getExternalDataConfiguration());
       }
-      if (tablePb.getStreamingBuffer() != null) {
-        this.streamingBuffer = StreamingBuffer.fromPb(tablePb.getStreamingBuffer());
-      }
     }
 
     /**
@@ -71,11 +65,6 @@ public Builder configuration(ExternalDataConfiguration configuration) {
       return self();
     }
 
-    Builder streamingBuffer(StreamingBuffer streamingBuffer) {
-      this.streamingBuffer = streamingBuffer;
-      return self();
-    }
-
     /**
      * Creates a {@code ExternalTableInfo} object.
      */
@@ -88,28 +77,19 @@ public ExternalTableInfo build() {
   private ExternalTableInfo(Builder builder) {
     super(builder);
     this.configuration = builder.configuration;
-    this.streamingBuffer = builder.streamingBuffer;
   }
 
   /**
    * Returns the data format, location and other properties of a table stored outside of BigQuery.
    * This property is experimental and might be subject to change or removed.
    *
-   * @see Federated Data
-   *     Sources
+   * @see Federated Data Sources
+   *     
    */
   public ExternalDataConfiguration configuration() {
     return configuration;
   }
 
-  /**
-   * Returns information on the table's streaming buffer if any exists. Returns {@code null} if no
-   * streaming buffer exists.
-   */
-  public StreamingBuffer streamingBuffer() {
-    return streamingBuffer;
-  }
-
   /**
    * Returns a builder for the {@code ExternalTableInfo} object.
    */
@@ -120,18 +100,13 @@ public Builder toBuilder() {
 
   @Override
   ToStringHelper toStringHelper() {
-    return super.toStringHelper()
-        .add("configuration", configuration)
-        .add("streamingBuffer", streamingBuffer);
+    return super.toStringHelper().add("configuration", configuration);
   }
 
   @Override
   Table toPb() {
     Table tablePb = super.toPb();
     tablePb.setExternalDataConfiguration(configuration.toPb());
-    if (streamingBuffer != null) {
-      tablePb.setStreamingBuffer(streamingBuffer.toPb());
-    }
     return tablePb;
   }
 
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
index 5ef68d7b9e15..0c0cf3de761d 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryRequest.java
@@ -28,7 +28,7 @@
  * return results if the query completes within a specified timeout. The query results are saved to
  * a temporary table that is deleted approximately 24 hours after the query is run. The query is run
  * through a BigQuery Job whose identity can be accessed via {@link QueryResponse#jobId()}. If the
- * query does not complete within the provided {@link Builder#maxWaitTime(Long)} the response
+ * query does not complete within the provided {@link Builder#maxWaitTime(Long)}, the response
  * returned by {@link BigQuery#query(QueryRequest)} will have {@link QueryResponse#jobComplete()}
  * set to {@code false} and {@link QueryResponse#result()} set to {@code null}. To obtain query
  * results you can use {@link BigQuery#getQueryResults(JobId, BigQuery.QueryResultsOption...)} until
@@ -36,6 +36,7 @@
  *
  * 

Example usage of a query request: *

    {@code
+ *    // Substitute "field", "table" and "dataset" with real field, table and dataset identifiers
  *    QueryRequest request = QueryRequest.builder("SELECT field FROM table")
  *      .defaultDataset(DatasetId.of("dataset"))
  *      .maxWaitTime(60000L)
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
index 74dc487825c6..7b47f4df8f19 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java
@@ -16,9 +16,15 @@
 
 package com.google.gcloud.bigquery;
 
+import com.google.api.services.bigquery.model.Streamingbuffer;
 import com.google.api.services.bigquery.model.Table;
+import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Objects;
+
 /**
  * A Google BigQuery Table information. A BigQuery table is a standard, two-dimensional table with
  * individual records organized in rows, and a data type assigned to each column (also called a
@@ -34,6 +40,79 @@ public class TableInfo extends BaseTableInfo {
   private final String location;
   private final StreamingBuffer streamingBuffer;
 
+  /**
+   * Google BigQuery Table's Streaming Buffer information. This class contains information on a
+   * table's streaming buffer as the estimated size in number of rows/bytes.
+   */
+  public static class StreamingBuffer implements Serializable {
+
+    private static final long serialVersionUID = -6713971364725267597L;
+    private final long estimatedRows;
+    private final long estimatedBytes;
+    private final long oldestEntryTime;
+
+    StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) {
+      this.estimatedRows = estimatedRows;
+      this.estimatedBytes = estimatedBytes;
+      this.oldestEntryTime = oldestEntryTime;
+    }
+
+    /**
+     * Returns a lower-bound estimate of the number of rows currently in the streaming buffer.
+     */
+    public long estimatedRows() {
+      return estimatedRows;
+    }
+
+    /**
+     * Returns a lower-bound estimate of the number of bytes currently in the streaming buffer.
+     */
+    public long estimatedBytes() {
+      return estimatedBytes;
+    }
+
+    /**
+     * Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since
+     * epoch.
+     */
+    public long oldestEntryTime() {
+      return oldestEntryTime;
+    }
+
+    @Override
+    public String toString() {
+      return MoreObjects.toStringHelper(this)
+          .add("estimatedRows", estimatedRows)
+          .add("estimatedBytes", estimatedBytes)
+          .add("oldestEntryTime", oldestEntryTime)
+          .toString();
+    }
+
+    @Override
+    public int hashCode() {
+      return Objects.hash(estimatedRows, estimatedBytes, oldestEntryTime);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+      return obj instanceof StreamingBuffer
+          && Objects.equals(toPb(), ((StreamingBuffer) obj).toPb());
+    }
+
+    Streamingbuffer toPb() {
+      return new Streamingbuffer()
+          .setEstimatedBytes(BigInteger.valueOf(estimatedBytes))
+          .setEstimatedRows(BigInteger.valueOf(estimatedRows))
+          .setOldestEntryTime(BigInteger.valueOf(oldestEntryTime));
+    }
+
+    static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
+      return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(),
+          streamingBufferPb.getEstimatedBytes().longValue(),
+          streamingBufferPb.getOldestEntryTime().longValue());
+    }
+  }
+
   public static final class Builder extends BaseTableInfo.Builder {
 
     private String location;
diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java
index ffaa787fb1d8..74d1c038a6bc 100644
--- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java
+++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/spi/DefaultBigQueryRpc.java
@@ -122,8 +122,8 @@ public Tuple> listDatasets(Map options)
           .execute();
       Iterable datasets = datasetsList.getDatasets();
       return Tuple.of(datasetsList.getNextPageToken(),
-          Iterables.transform(datasets != null ? datasets :
-              ImmutableList.of(),
+          Iterables.transform(datasets != null ? datasets
+              : ImmutableList.of(),
               new Function() {
                 @Override
                 public Dataset apply(DatasetList.Datasets datasetPb) {
diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java
index d337f5a67849..225fc284b203 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/OptionTest.java
@@ -31,7 +31,7 @@ public void testOption() {
     assertEquals("token", option.value());
   }
 
-  @Test(expected=NullPointerException.class)
+  @Test(expected = NullPointerException.class)
   public void testNullRpcOption() {
     new Option(null, "token");
   }
diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryResultTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryResultTest.java
index db2432753b52..b6810ed93143 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryResultTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/QueryResultTest.java
@@ -16,14 +16,14 @@
 
 package com.google.gcloud.bigquery;
 
+import static org.junit.Assert.assertEquals;
+
 import com.google.common.collect.ImmutableList;
 
 import org.junit.Test;
 
 import java.util.List;
 
-import static org.junit.Assert.assertEquals;
-
 public class QueryResultTest {
 
   private static final String CURSOR = "cursor";
diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java
index 3766ef493064..bbd244367a20 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java
@@ -23,6 +23,7 @@
 import com.google.common.collect.ImmutableMap;
 import com.google.gcloud.AuthCredentials;
 import com.google.gcloud.RetryParams;
+import com.google.gcloud.bigquery.TableInfo.StreamingBuffer;
 
 import org.junit.Test;
 
@@ -94,8 +95,7 @@ public class SerializationTest {
           .description("FieldDescription3")
           .build();
   private static final Schema TABLE_SCHEMA = Schema.of(FIELD_SCHEMA1, FIELD_SCHEMA2, FIELD_SCHEMA3);
-  private static final BaseTableInfo.StreamingBuffer STREAMING_BUFFER =
-      new BaseTableInfo.StreamingBuffer(1L, 2L, 3L);
+  private static final StreamingBuffer STREAMING_BUFFER = new StreamingBuffer(1L, 2L, 3L);
   private static final List SOURCE_URIS = ImmutableList.of("uri1", "uri2");
   private static final ExternalDataConfiguration EXTERNAL_DATA_CONFIGURATION =
       ExternalDataConfiguration.builder(SOURCE_URIS, TABLE_SCHEMA, CSV_OPTIONS)
@@ -128,7 +128,6 @@ public class SerializationTest {
           .description(DESCRIPTION)
           .etag(ETAG)
           .id(ID)
-          .streamingBuffer(STREAMING_BUFFER)
           .build();
   private static final JobStatistics JOB_STATISTICS = JobStatistics.builder()
           .creationTime(1L)
diff --git a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
index e32ee2516b6b..c636a31ad1ff 100644
--- a/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
+++ b/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/TableInfoTest.java
@@ -20,7 +20,7 @@
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableList;
-import com.google.gcloud.bigquery.BaseTableInfo.StreamingBuffer;
+import com.google.gcloud.bigquery.TableInfo.StreamingBuffer;
 
 import org.junit.Test;
 
@@ -46,7 +46,6 @@ public class TableInfoTest {
   private static final Schema TABLE_SCHEMA = Schema.of(FIELD_SCHEMA1, FIELD_SCHEMA2, FIELD_SCHEMA3);
   private static final String VIEW_QUERY = "VIEW QUERY";
   private static final List SOURCE_URIS = ImmutableList.of("uri1", "uri2");
-  private static final String SOURCE_FORMAT = "CSV";
   private static final Integer MAX_BAD_RECORDS = 42;
   private static final Boolean IGNORE_UNKNOWN_VALUES = true;
   private static final String COMPRESSION = "GZIP";
@@ -96,7 +95,6 @@ public class TableInfoTest {
           .numBytes(NUM_BYTES)
           .numRows(NUM_ROWS)
           .selfLink(SELF_LINK)
-          .streamingBuffer(STREAMING_BUFFER)
           .build();
   private static final List USER_DEFINED_FUNCTIONS =
       ImmutableList.of(UserDefinedFunction.inline("Function"), UserDefinedFunction.fromUri("URI"));
@@ -184,7 +182,6 @@ public void testBuilder() {
     assertEquals(NUM_BYTES, EXTERNAL_TABLE_INFO.numBytes());
     assertEquals(NUM_ROWS, EXTERNAL_TABLE_INFO.numRows());
     assertEquals(SELF_LINK, EXTERNAL_TABLE_INFO.selfLink());
-    assertEquals(STREAMING_BUFFER, EXTERNAL_TABLE_INFO.streamingBuffer());
     assertEquals(BaseTableInfo.Type.EXTERNAL, EXTERNAL_TABLE_INFO.type());
   }
 
@@ -235,6 +232,5 @@ private void compareExternalTableInfo(ExternalTableInfo expected, ExternalTableI
     compareBaseTableInfo(expected, value);
     assertEquals(expected, value);
     assertEquals(expected.configuration(), value.configuration());
-    assertEquals(expected.streamingBuffer(), value.streamingBuffer());
   }
 }