Skip to content

Commit

Permalink
Improve InternalHiveSplitFactory#checkBlocks error message
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Oct 28, 2020
1 parent e88c8e7 commit 039dd5f
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private Optional<InternalHiveSplit> createInternalHiveSplit(
blockBuilder.add(new InternalHiveBlock(blockStart, blockEnd, getHostAddresses(blockLocation)));
}
List<InternalHiveBlock> blocks = blockBuilder.build();
checkBlocks(blocks, start, length);
checkBlocks(path, blocks, start, length);

if (!splittable) {
// not splittable, use the hosts from the first block if it exists
Expand Down Expand Up @@ -224,14 +224,30 @@ private Optional<InternalHiveSplit> createInternalHiveSplit(
acidInfo));
}

private static void checkBlocks(List<InternalHiveBlock> blocks, long start, long length)
private static void checkBlocks(Path path, List<InternalHiveBlock> blocks, long start, long length)
{
checkArgument(length >= 0);
checkArgument(!blocks.isEmpty());
checkArgument(start == blocks.get(0).getStart());
checkArgument(start + length == blocks.get(blocks.size() - 1).getEnd());
checkArgument(start >= 0, "Split (%s) has negative start (%s)", path, start);
checkArgument(length >= 0, "Split (%s) has negative length (%s)", path, length);
checkArgument(!blocks.isEmpty(), "Split (%s) has no blocks", path);
checkArgument(
start == blocks.get(0).getStart(),
"Split (%s) start (%s) does not match first block start (%s)",
path,
start,
blocks.get(0).getStart());
checkArgument(
start + length == blocks.get(blocks.size() - 1).getEnd(),
"Split (%s) end (%s) does not match last block end (%s)",
path,
start + length,
blocks.get(blocks.size() - 1).getEnd());
for (int i = 1; i < blocks.size(); i++) {
checkArgument(blocks.get(i - 1).getEnd() == blocks.get(i).getStart());
checkArgument(
blocks.get(i - 1).getEnd() == blocks.get(i).getStart(),
"Split (%s) block end (%s) does not match next block start (%s)",
path,
blocks.get(i - 1).getEnd(),
blocks.get(i).getStart());
}
}

Expand Down

0 comments on commit 039dd5f

Please sign in to comment.