/** * Get the Avro validation policy for a given column. * * @param column the column for which to get the Avro validation policy. * @return the Avro validation policy for the given column. * @throws NoSuchColumnException in case the column does not exist. * @throws InvalidLayoutException in case a fully qualified column in a map family is specified. */ public AvroValidationPolicy getAvroValidationPolicy(final FijiColumnName column) throws NoSuchColumnException, InvalidLayoutException { return getColumnSchema(column).getAvroValidationPolicy(); }
/** * Set the Avro validation policy for a given column in this table. * * @param column the column whose Avro validation policy will be set. * @param policy the AvroValidationPolicy to set for the given column. * @return this builder. * @throws InvalidLayoutException in case a fully qualified column in a map family is specified. * @throws NoSuchColumnException in case the specified column does not exist. */ public TableLayoutBuilder withAvroValidationPolicy( final FijiColumnName column, final AvroValidationPolicy policy) throws NoSuchColumnException, InvalidLayoutException { getColumnSchema(column).setAvroValidationPolicy(policy); return this; }
/** * Returns a mutable list of registered schemas (READER, WRITER, WRITTEN) of the provided column. * * <p> * The list of schemas comes from a deeply nested record within the mutable table layout * descriptor. Therefore, mutating this list effectively mutates the table layout descriptor. * </p> * * @param columnName whose schema ids to list * @param schemaRegistrationType of the schemas to list: (READER, WRITER, WRITTEN). * @return The list of schema ids. * Returns empty list if schema validation was not previously enabled. * @throws NoSuchColumnException when column not found * @throws InvalidLayoutException if the column is final or non-AVRO */ private List<AvroSchema> getMutableRegisteredSchemaList( final FijiColumnName columnName, final SchemaRegistrationType schemaRegistrationType) throws NoSuchColumnException, InvalidLayoutException { Preconditions.checkNotNull(columnName); Preconditions.checkNotNull(schemaRegistrationType); final CellSchema cellSchema = getColumnSchema(columnName); // Avoid tracking schemas final or non-AVRO cells. if ((SchemaType.AVRO != cellSchema.getType()) || (SchemaStorage.FINAL == cellSchema.getStorage())) { throw new InvalidLayoutException("Final or non-AVRO column schema cannot be modified."); } final String fieldName = schemaRegistrationType.getCellSchemaFieldName(); return (List<AvroSchema>) Preconditions.checkNotNull(cellSchema.get(fieldName)); }