12
12
See the License for the specific language governing permissions and
13
13
limitations under the License.
14
14
*/
15
+
15
16
package com .google .cloud .bigquery .samples ;
16
17
17
18
import com .google .api .client .json .GenericJson ;
@@ -44,7 +45,6 @@ public class BigqueryUtils {
44
45
* static helper methods.
45
46
*/
46
47
protected BigqueryUtils () {
47
-
48
48
}
49
49
50
50
/**
@@ -53,12 +53,11 @@ protected BigqueryUtils() {
53
53
* @param out Output stream we want to print to
54
54
*/
55
55
// [START print_rows]
56
- public static void printRows (final List <TableRow > rows , final PrintStream
57
- out ) {
56
+ public static void printRows (final List <TableRow > rows , final PrintStream out ) {
58
57
for (TableRow row : rows ) {
59
58
for (TableCell field : row .getF ()) {
60
59
out .printf ("%-50s" , field .getV ());
61
- }
60
+ }
62
61
out .println ();
63
62
}
64
63
}
@@ -73,14 +72,13 @@ public static void printRows(final List<TableRow> rows, final PrintStream
73
72
* @throws InterruptedException InterruptedException
74
73
*/
75
74
// [START poll_job]
76
- public static Job pollJob (final Bigquery .Jobs .Get request , final long
77
- interval )
75
+ public static Job pollJob (final Bigquery .Jobs .Get request , final long interval )
78
76
throws IOException , InterruptedException {
79
77
Job job = request .execute ();
80
78
while (!job .getStatus ().getState ().equals ("DONE" )) {
81
79
System .out .println ("Job is "
82
- + job .getStatus ().getState ()
83
- + " waiting " + interval + " milliseconds..." );
80
+ + job .getStatus ().getState ()
81
+ + " waiting " + interval + " milliseconds..." );
84
82
Thread .sleep (interval );
85
83
job = request .execute ();
86
84
}
@@ -97,7 +95,7 @@ public static Job pollJob(final Bigquery.Jobs.Get request, final long
97
95
*/
98
96
// [START paging]
99
97
public static <T extends GenericJson > Iterator <T > getPages (
100
- final BigqueryRequest <T > requestTemplate ) {
98
+ final BigqueryRequest <T > requestTemplate ) {
101
99
102
100
/**
103
101
* An iterator class that pages through a Bigquery request.
@@ -168,8 +166,8 @@ public static TableSchema loadSchema(final Reader schemaSource) {
168
166
TableSchema sourceSchema = new TableSchema ();
169
167
170
168
List <TableFieldSchema > fields = (new Gson ())
171
- .<List <TableFieldSchema >>fromJson (schemaSource ,
172
- (new ArrayList <TableFieldSchema >()).getClass ());
169
+ .<List <TableFieldSchema >>fromJson (schemaSource ,
170
+ (new ArrayList <TableFieldSchema >()).getClass ());
173
171
174
172
sourceSchema .setFields (fields );
175
173
@@ -186,8 +184,7 @@ public static TableSchema loadSchema(final Reader schemaSource) {
186
184
* @throws IOException Thrown if there is a network error connecting to
187
185
* Bigquery.
188
186
*/
189
- public static void listDatasets (final Bigquery bigquery , final String
190
- projectId )
187
+ public static void listDatasets (final Bigquery bigquery , final String projectId )
191
188
throws IOException {
192
189
Datasets .List datasetRequest = bigquery .datasets ().list (projectId );
193
190
DatasetList datasetList = datasetRequest .execute ();
@@ -201,5 +198,4 @@ public static void listDatasets(final Bigquery bigquery, final String
201
198
}
202
199
}
203
200
// [END list_datasets]
204
-
205
201
}
0 commit comments