/** * Deletes all cells from a group-type family with a timestamp less than or equal to a * specified timestamp. * * @param entityId The entity (row) to delete from. * @param familyLayout The family layout. * @param upToTimestamp A timestamp. * @throws IOException If there is an IO error. */ private void deleteGroupFamily( EntityId entityId, FamilyLayout familyLayout, long upToTimestamp) throws IOException { final String familyName = Preconditions.checkNotNull(familyLayout.getName()); // Delete each column in the group according to the layout. for (ColumnLayout columnLayout : familyLayout.getColumnMap().values()) { final String qualifier = columnLayout.getName(); deleteColumn(entityId, familyName, qualifier, upToTimestamp); } }
Preconditions.checkState(state == State.OPEN, "Cannot delete family group while FijiTableWriter %s is in state %s.", this, state); final String familyName = Preconditions.checkNotNull(familyLayout.getName());
columnNames.add(FijiColumnName.create(familyLayout.getName(), null))); final FijiColumnName column = FijiColumnName.create(familyLayout.getName(), columnName); if (null != columnMap.put(column, columnLayout)) { throw new InvalidLayoutException(String.format( FijiColumnName.create(familyLayout.getName(), columnLayout.getName())));
throw new InvalidLayoutException(String.format( "Invalid family '%s' with both map-type and columns", getName())); throw new InvalidLayoutException(String.format( "Descriptor for family '%s' has ID %s but reference ID is %s.", getName(), mId, reference.getId())); throw new InvalidLayoutException(String.format( "Invalid layout update for family '%s' from reference type %s to type %s.", getName(), reference.isMapType() ? "map" : "group", this.isMapType() ? "map" : "group")); throw new InvalidLayoutException(String.format( "Invalid renaming: cannot find reference family for column '%s:%s'.", getName(), refCName)); throw new InvalidLayoutException(String.format( "Invalid renaming: cannot find column '%s:%s' in reference family.", getName(), refCName)); throw new InvalidLayoutException(String.format( "Family '%s' contains duplicate column qualifier '%s'.", getName(), columnName)); throw new InvalidLayoutException(String.format( "Descriptor for family '%s' is missing columns: %s.", getName(), Joiner.on(",").join(refCIdMap.keySet())));
flayout.getName(), null, validateCellSchema(refCellSchema, cellSchema))); } else if (refFamilyLayout.isGroupType()) { "Family: %s changed from group-type to map-type.", refFamilyLayout.getName())); } else { throw new InternalFijiError(String.format( "Family: %s is neither map-type nor group-type.", refFamilyLayout.getName())); flayout.getName(), null, validateCellSchema(null, cellSchema))); flayout.getName(), columnLayout.getName(), validateCellSchema(refCellSchema, cellSchema))); "Family: %s changed from map-type to group-type.", refFamilyLayout.getName())); } else { throw new InternalFijiError(String.format( "Family: %s is neither map-type nor group-type.", refFamilyLayout.getName())); final CellSchema cellSchema = columnLayout.getDesc().getColumnSchema(); incompatabilityMessages.addAll(addColumnNamestoIncompatibilityMessages( flayout.getName(), columnLayout.getName(), validateCellSchema(null, cellSchema))); "Family: %s is neither map-type nor group-type.", flayout.getName()));
final String previous = idMap.put(fLayout.getId(), fLayout.getName()); Preconditions.checkState(previous == null, String.format("Duplicate family ID '%s' associated to '%s' and '%s'.", fLayout.getId(), fLayout.getName(), previous)); } else { unassigned.add(fLayout); if (!idMap.containsKey(fId)) { fLayout.setId(fId); idMap.put(fId, fLayout.getName()); break;
for (String key : row.getQualifiers(family.getName())) { FijiCell<Long> counter = row.getMostRecentCell(family.getName(), key); if (null != counter) { printCell(row.getEntityId(), counter, printStream); FijiCell<Long> counter = row.getMostRecentCell(family.getName(), key); if (null != counter) { printCell(row.getEntityId(), counter, printStream); row.getValues(family.getName()); for (String key : keyTimeseriesMap.keySet()) { for (Entry<Long, Object> timestampedCell : keyTimeseriesMap.get(key).entrySet()) { long timestamp = timestampedCell.getKey(); printCell(row.getEntityId(), timestamp, family.getName(), key, timestampedCell.getValue(), printStream); for (String key : entry.getValue()) { NavigableMap<Long, Object> timeseriesMap = row.getValues(family.getName(), key); for (Entry<Long, Object> timestampedCell : timeseriesMap.entrySet()) { long timestamp = timestampedCell.getKey(); printCell( row.getEntityId(), timestamp, family.getName(), key, timestampedCell.getValue(), printStream); String familyName = entry.getKey().getName(); for (ColumnLayout column : entry.getValue()) { final FijiColumnName colName = FijiColumnName.create(familyName, column.getName());
throw new NoSuchColumnException(String.format( "No column with ID %s in family %s of table %s.", qualifierID.getId(), family.getName(), mLayout.getName())); new FijiColumnName(family.getName(), qualifier.getName()); LOG.debug("Translated to Fiji group column {}.", fijiColumnName); return fijiColumnName; final FijiColumnName fijiColumnName = new FijiColumnName(family.getName(), rawQualifier); LOG.debug("Translated to Fiji map column '{}'.", fijiColumnName); return fijiColumnName;
final String familyName = familyLayout.getName(); final HBaseColumnName hbaseColumnName = mWriterLayoutCapsule.getColumnNameTranslator() .toHBaseColumnName(FijiColumnName.create(familyName));
String family = familyLayout.getName(); for (String qualifier : rowData.getQualifiers(family)) { FijiColumnName column = new FijiColumnName(family, qualifier);
if (family.isMapType()) { getPrintStream().println(FijiURI.newBuilder(table.getURI()) .addColumnName(FijiColumnName.create(family.getName())) .build()); } else { for (ColumnLayout column : family.getColumns()) { getPrintStream().println(FijiURI.newBuilder(table.getURI()) .addColumnName(FijiColumnName.create(family.getName(), column.getName())) .build());
throw new NoSuchColumnException(String.format( "No column with ID %s in family %s of table %s.", qualifierID.getId(), family.getName(), mLayout.getName())); fijiColumnName = FijiColumnName.create(family.getName(), qualifier.getName()); } else { fijiColumnName = FijiColumnName.create( family.getName(), Bytes.toString(cassandraColumnName.getQualifier()));
Preconditions.checkState(state == State.OPEN, "Cannot delete map family while FijiTableWriter %s is in state %s.", this, state); final String familyName = familyLayout.getName(); final HBaseColumnName hbaseColumnName = mWriterLayoutCapsule.getColumnNameTranslator() .toHBaseColumnName(FijiColumnName.create(familyName));
for (FamilyLayout fLayout : layout.getFamilies()) { if (fLayout.isMapType()) { columns.add(FijiColumnName.create(fLayout.getName(), null)); } else if (fLayout.isGroupType()) { for (ColumnLayout cLayout : fLayout.getColumns()) { columns.add(FijiColumnName.create(fLayout.getName(), cLayout.getName())); String.format("Family '%s' is neither map-type nor group-type.", fLayout.getName()));
final String familyName = familyLayout.getName();
/** * Deletes all cells from a group-type family with a timestamp less than or equal to a * specified timestamp. * * @param entityId The entity (row) to delete from. * @param familyLayout The family layout. * @param upToTimestamp A timestamp. * @throws IOException If there is an IO error. */ private void deleteGroupFamily( EntityId entityId, FamilyLayout familyLayout, long upToTimestamp) throws IOException { final String familyName = Preconditions.checkNotNull(familyLayout.getName()); // Delete each column in the group according to the layout. final Delete delete = new Delete(entityId.getHBaseRowKey()); for (ColumnLayout columnLayout : familyLayout.getColumnMap().values()) { final String qualifier = columnLayout.getName(); final FijiColumnName column = FijiColumnName.create(familyName, qualifier); final HBaseColumnName hbaseColumnName = mWriterLayoutCapsule.getColumnNameTranslator().toHBaseColumnName(column); delete.deleteColumns( hbaseColumnName.getFamily(), hbaseColumnName.getQualifier(), upToTimestamp); } // Buffer the delete. updateBuffer(delete); }
/** * Retrieves a list of FijiColumnNames from a FijiTableLayout including both fully qualified * columns as well as map-type families. * * @param fijiTableLayout to retrieve all of the FijiColumnNames from. * @return collection of FijiColumnNames in the specified Layout. */ private static Collection<FijiColumnName> getFijiColumns(FijiTableLayout fijiTableLayout) { // We need to do this because getColumnNames doesn't seem to get all of the columns names; List<FijiColumnName> fijiColumnNames = Lists.newArrayList(); for (FamilyLayout family : fijiTableLayout.getFamilies()) { String familyName = family.getName(); if (family.isMapType()) { // Map type column family FijiColumnName fijiColumnName = new FijiColumnName(familyName); fijiColumnNames.add(fijiColumnName); } else { for (FamilyLayout.ColumnLayout column : family.getColumns()) { String columnName = column.getName(); FijiColumnName fijiColumnName = new FijiColumnName(familyName, columnName); fijiColumnNames.add(fijiColumnName); } } } return fijiColumnNames; }
/** * Creates a new {@link HBaseNativeColumnNameTranslator} instance. * * @param layout The layout of the table to translate column names for. */ public HBaseNativeColumnNameTranslator(FijiTableLayout layout) { mLayout = layout; for (FamilyLayout family : mLayout.getFamilies()) { // Validate that all Fiji column families are the same as their respective locality groups Preconditions.checkArgument(family.getName().equals(family.getLocalityGroup().getName()), "For HBASE_NATIVE column name translation, family: '%s' must match locality group: '%s'", family.getName(), family.getLocalityGroup().getName()); // Validate all Fiji column families are group type Preconditions.checkArgument(family.isGroupType(), "For HBASE_NATIVE column name translation, family: '%s' must be a group type.", family.getName()); } }