Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,19 @@ private synchronized boolean readNextRecord() throws IOException {
fractionConsumedFromCurrentResponse = getFractionConsumed(currentResponse);

Preconditions.checkArgument(
totalRowCountFromCurrentResponse > 0L,
"Row count from current response (%s) must be greater than one.",
totalRowCountFromCurrentResponse >= 0L,
"Row count from current response (%s) must be greater than or equal to zero.",
totalRowCountFromCurrentResponse);
Preconditions.checkArgument(
0f <= fractionConsumedFromCurrentResponse && fractionConsumedFromCurrentResponse <= 1f,
"Fraction consumed from current response (%s) is not in the range [0.0, 1.0].",
fractionConsumedFromCurrentResponse);
Preconditions.checkArgument(
fractionConsumedFromPreviousResponse < fractionConsumedFromCurrentResponse,
"Fraction consumed from previous response (%s) is not less than fraction consumed "
+ "from current response (%s).",
fractionConsumedFromPreviousResponse,
fractionConsumedFromCurrentResponse);
fractionConsumedFromPreviousResponse <= fractionConsumedFromCurrentResponse,
"Fraction consumed from the current response (%s) has to be larger than or equal to "
+ "the fraction consumed from the previous response (%s).",
fractionConsumedFromCurrentResponse,
fractionConsumedFromPreviousResponse);
}

record = datumReader.read(record, decoder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ public void testFractionConsumed() throws Exception {
// N.B.: All floating point numbers used in this test can be represented without
// a loss of precision.
createResponse(AVRO_SCHEMA, records.subList(0, 2), 0.250),
// Some responses may contain zero results, so we must ensure that we can are resilient
// to such responses.
createResponse(AVRO_SCHEMA, Lists.newArrayList(), 0.250),
createResponse(AVRO_SCHEMA, records.subList(2, 4), 0.500),
createResponse(AVRO_SCHEMA, records.subList(4, 7), 0.875));

Expand Down