/** @return whether this is a group-type family. */ public boolean isGroupType() { return mDesc.getMapSchema() == null; }
/** @return the primary name for the family. */ public String getName() { return mDesc.getName(); }
/** @return the Avro descriptor for this family. */ public FamilyDesc getDesc() { return FamilyDesc.newBuilder(mDesc).build(); }
mDesc.setColumns(Lists.newArrayList(mDesc.getColumns())); if (!mDesc.getColumns().isEmpty() && (null != mDesc.getMapSchema())) { throw new InvalidLayoutException(String.format( "Invalid family '%s' with both map-type and columns", familyNames.add(familyDesc.getName()); familyNames.addAll(familyDesc.getAliases()); mNames = ImmutableSet.copyOf(familyNames); if (!isValidName(familyDesc.getName())) { throw new InvalidLayoutException(String.format( "Invalid family name: '%s'.", familyDesc.getName())); if (familyDesc.getId() > 0) { mId = new ColumnId(familyDesc.getId()); familyDesc.setId(mId.getId()); (null != reference) ? reference.getDesc().getMapSchema() : null; validateCellSchema(mLayoutVersion, mDesc.getMapSchema(), referenceSchema); final Iterator<ColumnDesc> itColumnDesc = familyDesc.getColumns().iterator(); while (itColumnDesc.hasNext()) { final ColumnDesc columnDesc = itColumnDesc.next(); throw new InvalidLayoutException(String.format( "Deleted column '%s:%s' does not exist in reference layout.", mDesc.getName(), refCName));
if (family.getMapSchema() != null) { if (family.getMapSchema().getType() == SchemaType.COUNTER) { throw new IllegalArgumentException(String.format( "Fiji Cassandra does not support counter map type families. Family: %s, table: %s.", layout.getName(), family.getName())); for (final ColumnDesc column : family.getColumns()) { if (column.getColumnSchema().getType() == SchemaType.COUNTER) { throw new IllegalArgumentException(String.format( "Fiji Cassandra does not support counter columns." + " Table: %s, family: %s, column: %s.", layout.getName(), family.getName(), column.getName()));
/** * 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); } } } } }
while (itFamilyDesc.hasNext()) { final FamilyDesc familyDesc = itFamilyDesc.next(); final boolean isRename = (familyDesc.getRenamedFrom() != null); final String refFName = isRename ? familyDesc.getRenamedFrom() : familyDesc.getName(); familyDesc.setRenamedFrom(null); if (isRename && (reference == null)) { throw new InvalidLayoutException(String.format( if (familyDesc.getDelete()) { if (refFId == null) { throw new InvalidLayoutException(String.format(
/** * 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())); } /**
/** * Assigns the ID of this family. * * @param cid the ID of the family. * @return this column. */ private FamilyLayout setId(ColumnId cid) { Preconditions.checkArgument(cid.getId() >= 1); Preconditions.checkState(null == mId); mId = cid; mDesc.setId(cid.getId()); return this; }
if (null != soughtFd.getMapSchema()) { if (groupType) { throw new InvalidLayoutException("A fully qualified map-type column name was provided."); } else { return soughtFd.getMapSchema(); for (ColumnDesc cd : soughtFd.getColumns()) { if (cd.getName().equals(columnName.getQualifier())) { return cd.getColumnSchema();
/** * Reports the raw specification record for the specified column. * * <p> Note: in most cases, you should use {@link #getCellSpec(FijiColumnName)}. </p> * * @param columnName Column to reports the raw specification record of. * @return the raw specification record for the specified column. * @throws NoSuchColumnException if the column does not exist. */ public CellSchema getCellSchema(FijiColumnName columnName) throws NoSuchColumnException { final FamilyLayout fLayout = mFamilyMap.get(columnName.getFamily()); if (fLayout == null) { throw new NoSuchColumnException(String.format( "Table '%s' has no family '%s'.", getName(), columnName.getFamily())); } if (fLayout.isMapType()) { return CellSchema.newBuilder(fLayout.getDesc().getMapSchema()).build(); } // Group-type family: Preconditions.checkArgument(columnName.isFullyQualified(), String.format("Cannot get CellFormat for entire group-type family: '%s'.", columnName)); final FamilyLayout.ColumnLayout cLayout = fLayout.getColumnMap().get(columnName.getQualifier()); if (cLayout == null) { throw new NoSuchColumnException(String.format( "Table '%s' has no column '%s'.", getName(), columnName)); } return CellSchema.newBuilder(cLayout.getDesc().getColumnSchema()).build(); }
if (family.getDesc().getMapSchema().getType() == SchemaType.COUNTER) {
final CellSchema cellSchema = flayout.getDesc().getMapSchema(); if (refFamilyLayout.isMapType()) { final CellSchema refCellSchema = refFamilyLayout.getDesc().getMapSchema();