throws InvalidLayoutException { mDesc = TableLayoutDesc.newBuilder(Preconditions.checkNotNull(desc)).build();
/** * Return the corresponding mutable family descriptor of the provided column family. * The family descriptor comes from a nested record within the mutable table layout descriptor. * Therefore, mutating this family descriptor effectively mutates the table layout descriptor. * * @param family whole family descriptor to extract * @return the family descriptor * @throws NoSuchColumnException when family not found */ private FamilyDesc getFamilyDesc(final FijiColumnName family) throws NoSuchColumnException { // Traverse through the locality groups to locate family. for (LocalityGroupDesc lgd : mDescBuilder.getLocalityGroups()) { for (FamilyDesc fd : lgd.getFamilies()) { if (fd.getName().equals(family.getFamily())) { return fd; } for (String alias : fd.getAliases()) { if (alias.equals(family.getFamily())) { return fd; } } } } throw new NoSuchColumnException(String.format( "Table '%s' has no family '%s'.", mDescBuilder.getName(), family.getFamily())); } /**
mSchemaResolver = new SchemaTableAvroResolver(mSchemaTable); mDescBuilder = TableLayoutDesc.newBuilder(tableLayoutDesc) .setReferenceLayout(tableLayoutDesc.getLayoutId()) .setLayoutId(nextLayoutId(tableLayoutDesc.getLayoutId()));
"Table '%s' has no column '%s'.", mDescBuilder.getName(), columnName));
/** * Normalizes the table layout descriptor to use schema UIDs only. * * @param descBuilder Builder for the table layout descriptor to normalize. * @param options Options describing the normalization to apply. * @throws IOException on I/O error. */ private void normalizeTableLayoutDesc(TableLayoutDesc.Builder descBuilder, LayoutOptions options) throws IOException { for (LocalityGroupDesc lgdesc : descBuilder.getLocalityGroups()) { for (FamilyDesc fdesc : lgdesc.getFamilies()) { if (fdesc.getMapSchema() != null) { normalizeCellSchema(fdesc.getMapSchema(), options); } else { for (ColumnDesc cdesc : fdesc.getColumns()) { normalizeCellSchema(cdesc.getColumnSchema(), options); } } } } }
/** * Normalizes a table layout descriptor to use schema UIDs only. * * @param desc Table layout descriptor to normalize. * @param options Options describing the normalization to apply. * @return the normalized table layout descriptor. * @throws IOException on I/O error. */ public TableLayoutDesc normalizeTableLayoutDesc(TableLayoutDesc desc, LayoutOptions options) throws IOException { final TableLayoutDesc.Builder descBuilder = TableLayoutDesc.newBuilder(desc); normalizeTableLayoutDesc(descBuilder, options); return descBuilder.build(); }
/** * Build a new table layout descriptor. * * @return a built table layout descriptor. */ public TableLayoutDesc build() { return mDescBuilder.build(); }
/** * Get the layout id. * * @return layout id */ public String getLayoutId() { return mDescBuilder.getLayoutId(); }
/** * Returns the Avro descriptor for this table layout. * @return the Avro descriptor for this table layout. */ public TableLayoutDesc getDesc() { return TableLayoutDesc.newBuilder(mDesc).build(); }
/** * Set the layout id. * * @param layoutId to set * @return this. */ public TableLayoutBuilder withLayoutId(String layoutId) { mDescBuilder.setLayoutId(layoutId); return this; }