* @throws IllegalArgumentException if the document contains an invalid set of fields.
*/
public static void checkFieldSet(DocumentPb.Document document) {
Set<Pair<String, ContentType> > noRepeatNames = Sets.newHashSet();
for (DocumentPb.Field field : document.getFieldList()) {
ContentType type = field.getValue().getType();
if (type == ContentType.NUMBER || type == ContentType.DATE) {
Pair<String, ContentType> typedField = new Pair<String, ContentType>(field.getName(), type);
if (!noRepeatNames.add(typedField)) {
throw new IllegalArgumentException(
"Invalid document " + document.getId() + ": field " + field.getName() +