Skip to content

Commit 3cbb6c7

Browse files
authored
Merge pull request #99 from trocco-io/feature/embulk-v0.1x-apply-google-java-format
enable spotless googleJavaFormat
2 parents 8f8ca1e + f1fb6d4 commit 3cbb6c7

40 files changed

+2803
-2606
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ spotless {
9292
java {
9393
importOrder()
9494
removeUnusedImports()
95-
// googleJavaFormat()
95+
googleJavaFormat()
9696
}
9797
}

src/main/java/org/embulk/output/bigquery_java/BigqueryClient.java

Lines changed: 677 additions & 621 deletions
Large diffs are not rendered by default.

src/main/java/org/embulk/output/bigquery_java/BigqueryFileWriter.java

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,83 +5,79 @@
55
import java.io.IOException;
66
import java.io.OutputStream;
77
import java.util.zip.GZIPOutputStream;
8-
98
import org.embulk.output.bigquery_java.config.PluginTask;
10-
119
import org.slf4j.Logger;
1210
import org.slf4j.LoggerFactory;
1311

1412
public class BigqueryFileWriter {
15-
private final Logger logger = LoggerFactory.getLogger(BigqueryFileWriter.class);
16-
private PluginTask task;
17-
private String compression;
18-
private OutputStream os;
19-
private long count = 0;
13+
private final Logger logger = LoggerFactory.getLogger(BigqueryFileWriter.class);
14+
private PluginTask task;
15+
private String compression;
16+
private OutputStream os;
17+
private long count = 0;
2018

21-
public BigqueryFileWriter(PluginTask task) {
22-
this.task = task;
23-
this.compression = this.task.getCompression();
24-
}
19+
public BigqueryFileWriter(PluginTask task) {
20+
this.task = task;
21+
this.compression = this.task.getCompression();
22+
}
2523

26-
public BigqueryFileWriter() {
27-
}
24+
public BigqueryFileWriter() {}
2825

29-
public void setTask(PluginTask task) {
30-
this.task = task;
31-
}
32-
33-
public void setCompression(String compression) {
34-
this.compression = compression;
35-
}
26+
public void setTask(PluginTask task) {
27+
this.task = task;
28+
}
3629

37-
public OutputStream open(String path) throws IOException {
38-
logger.info("embulk-output-bigquery: create {}", path);
30+
public void setCompression(String compression) {
31+
this.compression = compression;
32+
}
3933

40-
this.os = new FileOutputStream(path);
41-
if (this.compression.equals("GZIP")) {
42-
this.os = new GZIPOutputStream(this.os);
43-
}
44-
// embulk default page size
45-
this.os = new BufferedOutputStream(this.os, 1024 * 32);
34+
public OutputStream open(String path) throws IOException {
35+
logger.info("embulk-output-bigquery: create {}", path);
4636

47-
return this.os;
37+
this.os = new FileOutputStream(path);
38+
if (this.compression.equals("GZIP")) {
39+
this.os = new GZIPOutputStream(this.os);
4840
}
41+
// embulk default page size
42+
this.os = new BufferedOutputStream(this.os, 1024 * 32);
4943

50-
public OutputStream outputStream() throws IOException {
51-
if (this.os != null) {
52-
return this.os;
53-
}
54-
// TODO: pid, thread id format config
55-
String path = String.format("%s.%d.%d%s",
56-
this.task.getPathPrefix().get(),
57-
BigqueryUtil.getPID(),
58-
Thread.currentThread().getId(),
59-
this.task.getFileExt().get());
60-
return open(path);
61-
}
44+
return this.os;
45+
}
6246

63-
public void write(byte[] bytes) {
64-
try {
65-
outputStream().write(bytes);
66-
this.count++;
67-
} catch (Exception e) {
68-
logger.info(e.getMessage());
69-
}
47+
public OutputStream outputStream() throws IOException {
48+
if (this.os != null) {
49+
return this.os;
7050
}
71-
72-
public long getCount() {
73-
return this.count;
51+
// TODO: pid, thread id format config
52+
String path =
53+
String.format(
54+
"%s.%d.%d%s",
55+
this.task.getPathPrefix().get(),
56+
BigqueryUtil.getPID(),
57+
Thread.currentThread().getId(),
58+
this.task.getFileExt().get());
59+
return open(path);
60+
}
61+
62+
public void write(byte[] bytes) {
63+
try {
64+
outputStream().write(bytes);
65+
this.count++;
66+
} catch (Exception e) {
67+
logger.info(e.getMessage());
7468
}
75-
76-
public void close() {
77-
try {
78-
this.outputStream().flush();
79-
this.outputStream().close();
80-
} catch (Exception e) {
81-
logger.info(e.getMessage());
82-
}
69+
}
70+
71+
public long getCount() {
72+
return this.count;
73+
}
74+
75+
public void close() {
76+
try {
77+
this.outputStream().flush();
78+
this.outputStream().close();
79+
} catch (Exception e) {
80+
logger.info(e.getMessage());
8381
}
82+
}
8483
}
85-
86-
87-

0 commit comments

Comments
 (0)