Skip to content

Commit 66f7fcb

Browse files
committed
chore: Address code comments
1 parent 71a4513 commit 66f7fcb

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

samples/snippets/src/main/java/com/example/bigquerystorage/ReadTimestampArrow.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public void close() {
110110
public static void main(String... args) throws Exception {
111111
// Sets your Google Cloud Platform project ID.
112112
String projectId = args[0];
113-
Integer snapshotMillis = null;
113+
Long snapshotMillis = null;
114114
if (args.length > 1) {
115-
snapshotMillis = Integer.parseInt(args[1]);
115+
snapshotMillis = Long.parseLong(args[1]);
116116
}
117117

118118
try (BigQueryReadClient client = BigQueryReadClient.create()) {
@@ -142,7 +142,7 @@ public static void main(String... args) throws Exception {
142142
Timestamp t =
143143
Timestamp.newBuilder()
144144
.setSeconds(snapshotMillis / 1000)
145-
.setNanos(((snapshotMillis % 1000) * 1000000))
145+
.setNanos((int) ((snapshotMillis % 1000) * 1000000))
146146
.build();
147147
TableModifiers modifiers = TableModifiers.newBuilder().setSnapshotTime(t).build();
148148
sessionBuilder.setTableModifiers(modifiers);

samples/snippets/src/main/java/com/example/bigquerystorage/ReadTimestampAvro.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public void processRows(AvroRows avroRows) throws IOException {
7777
public static void main(String... args) throws Exception {
7878
// Sets your Google Cloud Platform project ID.
7979
String projectId = args[0];
80-
Integer snapshotMillis = null;
80+
Long snapshotMillis = null;
8181
if (args.length > 1) {
82-
snapshotMillis = Integer.parseInt(args[1]);
82+
snapshotMillis = Long.parseLong(args[1]);
8383
}
8484

8585
try (BigQueryReadClient client = BigQueryReadClient.create()) {
@@ -109,7 +109,7 @@ public static void main(String... args) throws Exception {
109109
Timestamp t =
110110
Timestamp.newBuilder()
111111
.setSeconds(snapshotMillis / 1000)
112-
.setNanos(((snapshotMillis % 1000) * 1000000))
112+
.setNanos((int) ((snapshotMillis % 1000) * 1000000))
113113
.build();
114114
TableModifiers modifiers = TableModifiers.newBuilder().setSnapshotTime(t).build();
115115
sessionBuilder.setTableModifiers(modifiers);

samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStreamTimestampWithArrow.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ public static void writeToDefaultStreamWithArrow(
124124
// One time initialization for the worker.
125125
writer.initialize(parentTable, arrowSchema);
126126
long initialRowCount = getRowCount(parentTable);
127-
BufferAllocator allocator = new RootAllocator();
128-
129-
// A writer should be used to ingest as much data as possible before teardown.
130-
// Append 100 batches.
131-
for (int i = 0; i < 100; i++) {
132-
try (VectorSchemaRoot root = VectorSchemaRoot.create(arrowSchema, allocator)) {
133-
// Each batch has 10 rows.
134-
ArrowRecordBatch batch = buildRecordBatch(root, 10);
135-
136-
// Asynchronous append.
137-
writer.append(new ArrowData(arrowSchema, batch));
127+
try (BufferAllocator allocator = new RootAllocator()) {
128+
// A writer should be used to ingest as much data as possible before teardown.
129+
// Append 100 batches.
130+
for (int i = 0; i < 100; i++) {
131+
try (VectorSchemaRoot root = VectorSchemaRoot.create(arrowSchema, allocator)) {
132+
// Each batch has 10 rows.
133+
ArrowRecordBatch batch = buildRecordBatch(root, 10);
134+
135+
// Asynchronous append.
136+
writer.append(new ArrowData(arrowSchema, batch));
137+
}
138138
}
139139
}
140140
// Final cleanup for the stream during worker teardown.

samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStreamWithArrow.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ public static void writeToDefaultStreamWithArrow(
129129
// One time initialization for the worker.
130130
writer.initialize(parentTable, arrowSchema);
131131
long initialRowCount = getRowCount(parentTable);
132-
BufferAllocator allocator = new RootAllocator();
133-
134-
// A writer should be used to ingest as much data as possible before teardown.
135-
// Append 100 batches.
136-
for (int i = 0; i < 100; i++) {
137-
try (VectorSchemaRoot root = VectorSchemaRoot.create(arrowSchema, allocator)) {
138-
// Each batch has 10 rows.
139-
ArrowRecordBatch batch = buildRecordBatch(root, 10);
140-
141-
// Asynchronous append.
142-
writer.append(new ArrowData(arrowSchema, batch));
132+
try (BufferAllocator allocator = new RootAllocator()) {
133+
// A writer should be used to ingest as much data as possible before teardown.
134+
// Append 100 batches.
135+
for (int i = 0; i < 100; i++) {
136+
try (VectorSchemaRoot root = VectorSchemaRoot.create(arrowSchema, allocator)) {
137+
// Each batch has 10 rows.
138+
ArrowRecordBatch batch = buildRecordBatch(root, 10);
139+
140+
// Asynchronous append.
141+
writer.append(new ArrowData(arrowSchema, batch));
142+
}
143143
}
144144
}
145145
// Final cleanup for the stream during worker teardown.

0 commit comments

Comments
 (0)