public ColumnIO getChild(int fieldIndex) { try { return children.get(fieldIndex); } catch (IndexOutOfBoundsException e) { throw new InvalidRecordException("could not get child " + fieldIndex + " from " + children, e); } }
public ColumnIO getChild(int fieldIndex) { try { return children.get(fieldIndex); } catch (IndexOutOfBoundsException e) { throw new InvalidRecordException("could not get child " + fieldIndex + " from " + children, e); } }
@Override public Type getType(String[] path, int i) { if (path.length != i) { throw new InvalidRecordException("Arrived at primitive node at index " + i + " , path invalid: " + Arrays.toString(path)); } return this; }
@Override public Type getType(String[] path, int i) { if (path.length != i) { throw new InvalidRecordException("Arrived at primitive node at index " + i + " , path invalid: " + Arrays.toString(path)); } return this; }
void checkContains(Type subType) { if (!this.name.equals(subType.name) || this.repetition != subType.repetition) { throw new InvalidRecordException(subType + " found: expected " + this); } }
/** * * @param name string name of a field * @return the index of the field with that name */ public int getFieldIndex(String name) { if (!indexByName.containsKey(name)) { throw new InvalidRecordException(name + " not found in " + this); } return indexByName.get(name); }
/** * * @param name string name of a field * @return the index of the field with that name */ public int getFieldIndex(String name) { if (!indexByName.containsKey(name)) { throw new InvalidRecordException(name + " not found in " + this); } return indexByName.get(name); }
@Override public void checkContains(Type subType) { if (!(subType instanceof MessageType)) { throw new InvalidRecordException(subType + " found: expected " + this); } checkGroupContains(subType); }
@Override public int getMaxRepetitionLevel(String[] path, int i) { if (path.length != i) { throw new InvalidRecordException("Arrived at primitive node, path invalid"); } return isRepetition(Repetition.REPEATED)? 1 : 0; }
@Override public int getMaxRepetitionLevel(String[] path, int i) { if (path.length != i) { throw new InvalidRecordException("Arrived at primitive node, path invalid"); } return isRepetition(Repetition.REPEATED)? 1 : 0; }
@Override public int getMaxDefinitionLevel(String[] path, int i) { if (path.length != i) { throw new InvalidRecordException("Arrived at primitive node, path invalid"); } return isRepetition(Repetition.REQUIRED) ? 0 : 1; }
private FieldWriter unknownType(Descriptors.FieldDescriptor fieldDescriptor) { String exceptionMsg = "Unknown type with descriptor \"" + fieldDescriptor + "\" and type \"" + fieldDescriptor.getJavaType() + "\"."; throw new InvalidRecordException(exceptionMsg); }
/** * {@inheritDoc} */ public void startField(String field, int index) { if (index <= previousField.peek()) { throw new InvalidRecordException("fields must be added in order " + field + " index " + index + " is before previous field " + previousField.peek()); } validateMissingFields(index); fields.push(index); fieldValueCount.push(0); delegate.startField(field, index); }
@Override void checkContains(Type subType) { super.checkContains(subType); if (!subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } PrimitiveType primitiveType = subType.asPrimitiveType(); if (this.primitive != primitiveType.primitive) { throw new InvalidRecordException(subType + " found: expected " + this); } }
@Override void checkContains(Type subType) { super.checkContains(subType); if (!subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } PrimitiveType primitiveType = subType.asPrimitiveType(); if (this.primitive != primitiveType.primitive) { throw new InvalidRecordException(subType + " found: expected " + this); } }
private void validateMissingFields(int index) { for (int i = previousField.peek() + 1; i < index; i++) { Type type = types.peek().asGroupType().getType(i); if (type.isRepetition(Repetition.REQUIRED)) { throw new InvalidRecordException("required field is missing " + type); } } }
void checkGroupContains(Type subType) { if (subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } List<Type> fields = subType.asGroupType().getFields(); for (Type otherType : fields) { Type thisType = this.getType(otherType.getName()); thisType.checkContains(otherType); } }
void checkGroupContains(Type subType) { if (subType.isPrimitive()) { throw new InvalidRecordException(subType + " found: expected " + this); } List<Type> fields = subType.asGroupType().getFields(); for (Type otherType : fields) { Type thisType = this.getType(otherType.getName()); thisType.checkContains(otherType); } }
ColumnIO getParent(int r) { if (getRepetitionLevel() == r && getType().isRepetition(Repetition.REPEATED)) { return this; } else if (getParent()!=null && getParent().getDefinitionLevel()>=r) { return getParent().getParent(r); } else { throw new InvalidRecordException("no parent("+r+") for "+Arrays.toString(this.getFieldPath())); } }
ColumnIO getParent(int r) { if (getRepetitionLevel() == r && getType().isRepetition(Repetition.REPEATED)) { return this; } else if (getParent()!=null && getParent().getDefinitionLevel()>=r) { return getParent().getParent(r); } else { throw new InvalidRecordException("no parent("+r+") for "+Arrays.toString(this.getFieldPath())); } }