From 0637c80cc23938e4bbfa6304005f975a319648b5 Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Tue, 9 Aug 2016 14:42:52 +0200 Subject: [PATCH] Fix StreamingBuffer to allow oldestEntryTime to be null (#1141) --- .../cloud/bigquery/StandardTableDefinition.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gcloud-java-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java b/gcloud-java-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java index ca6a533d0fe7..d6a5bd17a959 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java +++ b/gcloud-java-bigquery/src/main/java/com/google/cloud/bigquery/StandardTableDefinition.java @@ -53,9 +53,9 @@ public static class StreamingBuffer implements Serializable { private static final long serialVersionUID = 822027055549277843L; private final long estimatedRows; private final long estimatedBytes; - private final long oldestEntryTime; + private final Long oldestEntryTime; - StreamingBuffer(long estimatedRows, long estimatedBytes, long oldestEntryTime) { + StreamingBuffer(long estimatedRows, long estimatedBytes, Long oldestEntryTime) { this.estimatedRows = estimatedRows; this.estimatedBytes = estimatedBytes; this.oldestEntryTime = oldestEntryTime; @@ -77,9 +77,9 @@ public long estimatedBytes() { /** * Returns the timestamp of the oldest entry in the streaming buffer, in milliseconds since - * epoch. + * epoch. Returns {@code null} if the streaming buffer is empty. */ - public long oldestEntryTime() { + public Long oldestEntryTime() { return oldestEntryTime; } @@ -111,9 +111,13 @@ Streamingbuffer toPb() { } static StreamingBuffer fromPb(Streamingbuffer streamingBufferPb) { + Long oldestEntryTime = null; + if (streamingBufferPb.getOldestEntryTime() != null) { + oldestEntryTime = streamingBufferPb.getOldestEntryTime().longValue(); + } return new StreamingBuffer(streamingBufferPb.getEstimatedRows().longValue(), streamingBufferPb.getEstimatedBytes().longValue(), - streamingBufferPb.getOldestEntryTime().longValue()); + oldestEntryTime); } }