Skip to content

Commit 0637c80

Browse files
authored
Fix StreamingBuffer to allow oldestEntryTime to be null (#1141)
1 parent 8d76e73 commit 0637c80

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

gcloud-java-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public static class StreamingBuffer implements Serializable {
5353
private static final long serialVersionUID = 822027055549277843L;
5454
private final long estimatedRows;
5555
private final long estimatedBytes;
56-
private final long oldestEntryTime;
56+
private final Long oldestEntryTime;
5757

58-
StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) {
58+
StreamingBuffer(long estimatedRows, long estimatedBytes, Long oldestEntryTime) {
5959
this.estimatedRows = estimatedRows;
6060
this.estimatedBytes = estimatedBytes;
6161
this.oldestEntryTime = oldestEntryTime;
@@ -77,9 +77,9 @@ public long estimatedBytes() {
7777

7878
/**
7979
* Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since
80-
* epoch.
80+
* epoch. Returns {@code null} if the streaming buffer is empty.
8181
*/
82-
public long oldestEntryTime() {
82+
public Long oldestEntryTime() {
8383
return oldestEntryTime;
8484
}
8585

@@ -111,9 +111,13 @@ Streamingbuffer toPb() {
111111
}
112112

113113
static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) {
114+
Long oldestEntryTime = null;
115+
if (streamingBufferPb.getOldestEntryTime() != null) {
116+
oldestEntryTime = streamingBufferPb.getOldestEntryTime().longValue();
117+
}
114118
return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(),
115119
streamingBufferPb.getEstimatedBytes().longValue(),
116-
streamingBufferPb.getOldestEntryTime().longValue());
120+
oldestEntryTime);
117121
}
118122
}
119123

0 commit comments

Comments
 (0)