Minor, but can you create a util function that checks if key.getOffset() == 0 && key.getLength() == key.get().length and then just use the byte[] directly rather than copying? You can put it in ByteUtil.