/** * Translates a Fiji locality group into an HColumnDescriptor. * * @param localityGroup A Fiji locality group. * @param hbaseColumnNameTranslator to convert the locality group into the HBase family. * @return The HColumnDescriptor to use for storing the data in the locality group. */ private static HColumnDescriptor toHColumnDescriptor( final LocalityGroupLayout localityGroup, final HBaseColumnNameTranslator hbaseColumnNameTranslator ) { byte[] hbaseFamilyName = hbaseColumnNameTranslator.toHBaseFamilyName(localityGroup); LocalityGroupDesc groupDesc = localityGroup.getDesc(); return new HColumnDescriptor( hbaseFamilyName, groupDesc.getMaxVersions(), groupDesc.getCompressionType().toString(), groupDesc.getInMemory(), true, // block cache groupDesc.getBlockSize() != null ? groupDesc.getBlockSize() : HColumnDescriptor.DEFAULT_BLOCKSIZE, groupDesc.getTtlSeconds(), groupDesc.getBloomType() != null ? groupDesc.getBloomType().toString() : HColumnDescriptor.DEFAULT_BLOOMFILTER, HColumnDescriptor.DEFAULT_REPLICATION_SCOPE); } }
mDesc.setFamilies(Lists.newArrayList(mDesc.getFamilies())); names.add(lgDesc.getName()); names.addAll(lgDesc.getAliases()); mNames = ImmutableSet.copyOf(names); if (!isValidName(lgDesc.getName())) { throw new InvalidLayoutException(String.format( "Invalid locality group name: '%s'.", lgDesc.getName())); if (lgDesc.getId() > 0) { mId = new ColumnId(lgDesc.getId()); if (mDesc.getTtlSeconds() <= 0) { throw new InvalidLayoutException(String.format( "Invalid TTL seconds for locality group '%s': TTL must be positive, got %d.", getName(), mDesc.getTtlSeconds())); if (mDesc.getMaxVersions() <= 0) { throw new InvalidLayoutException(String.format( "Invalid max versions for locality group '%s': max versions must be positive, got %d.", getName(), mDesc.getMaxVersions())); lgDesc.setId(mId.getId()); final Iterator<FamilyDesc> itFamilyDesc = lgDesc.getFamilies().iterator(); while (itFamilyDesc.hasNext()) { final FamilyDesc familyDesc = itFamilyDesc.next();
while (itLGDesc.hasNext()) { final LocalityGroupDesc lgDesc = itLGDesc.next(); final boolean isRename = (lgDesc.getRenamedFrom() != null); final String refLGName = isRename ? lgDesc.getRenamedFrom() : lgDesc.getName(); lgDesc.setRenamedFrom(null); if (isRename && (reference == null)) { throw new InvalidLayoutException(String.format( if (lgDesc.getDelete()) { if (lgDesc.getBlockSize() != null) { + Versions.BLOCK_SIZE_LAYOUT_VERSION); if (lgDesc.getBloomType() != null) { if (lgDesc.getBlockSize() != null && lgDesc.getBlockSize() <= 0) { throw new InvalidLayoutException("block_size must be greater than 0");
/** * 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())); } /**
int ttl = familyLayout.getLocalityGroup().getDesc().getTtlSeconds();
/** * Constructor. * * @param context Task attempt context. * @param lgLayout Layout of the locality group. * @throws IOException on I/O error. */ public LocalityGroupRecordWriter(TaskAttemptContext context, LocalityGroupLayout lgLayout) throws IOException { mLGLayout = Preconditions.checkNotNull(lgLayout); mFamily = lgLayout.getId().toString(); // These parameters might be specific to each locality group: mMaxFileSizeBytes = mConf.getLong(CONF_HREGION_MAX_FILESIZE, DEFAULT_HREGION_MAX_FILESIZE); mBlockSizeBytes = mConf.getInt(CONF_HFILE_BLOCKSIZE, DEFAULT_HFILE_BLOCKSIZE); mFamilyDir = new Path(mOutputDir, mFamily); if (!mFileSystem.exists(mFamilyDir)) { if (!mFileSystem.mkdirs(mFamilyDir)) { throw new IOException(String.format( "Unable to create output directory: %s", mFamilyDir)); } } mCompressionType = mLGLayout.getDesc().getCompressionType().toString().toLowerCase(Locale.ROOT); mWriter = openNewWriter(); }
for (final FamilyDesc family : localityGroup.getFamilies()) { if (family.getMapSchema() != null) {
int ttl = familyLayout.getLocalityGroup().getDesc().getTtlSeconds();
/** * 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); } } } } }