Source:
<code>private void upgradeFromOlderInternalSchema() { try { Map<TableReference, byte[]> metadataForTables = getMetadataForTables(); <START> final Collection<CfDef> updatedCfs = Lists.newArrayList(); <END> List<CfDef> knownCfs = clientPool.runWithRetry(client -> client.describe_keyspace(configManager.getConfig().keyspace()).getCf_defs()); for (CfDef clusterSideCf : knownCfs) { TableReference tableRef = tableReferenceFromCfDef(clusterSideCf); if (metadataForTables.containsKey(tableRef)) { byte[] clusterSideMetadata = metadataForTables.get(tableRef); CfDef clientSideCf = getCfForTable(tableRef, clusterSideMetadata, configManager.getConfig().gcGraceSeconds()); if (!ColumnFamilyDefinitions.isMatchingCf(clientSideCf, clusterSideCf)) { log.warn("Upgrading table to new internal Cassandra schema", UnsafeArg.of("table", tableRef)); updatedCfs.add(clientSideCf); } } else if (!hiddenTables.isHidden(tableRef)) { log.error("Found a table that did not have persisted" + " AtlasDB metadata. If you recently did a Palantir update, try waiting until" + " schema upgrades are completed on all backend CLIs/services etc and restarting" + " this service. If this error re-occurs on subsequent attempted startups, please" + " contact Palantir support.", UnsafeArg.of("table", tableRef.getQualifiedName())); } } Map<Cell, byte[]> emptyMetadataUpdate = ImmutableMap.of(); if (!updatedCfs.isEmpty()) { putMetadataAndMaybeAlterTables(true, emptyMetadataUpdate, updatedCfs); log.debug("New table-related settings were applied on startup!!"); } else { log.debug("No tables are being upgraded on startup. No updated table-related settings found."); } } catch (TException e) { log.error("Couldn't upgrade from an older internal Cassandra schema." + " New table-related settings may not have taken effect."); } }</code><technical_language>nit: presize. needed (copying cfdef references bad copying byte arrays)</technical_language>

Target:
private void upgradeFromOlderInternalSchema() { try { Map<TableReference, byte[]> metadataForTables = getMetadataForTables(); final Collection<CfDef> updatedCfs = Lists.newArrayListWithExpectedSize(metadataForTables.size()); List<CfDef> knownCfs = clientPool.runWithRetry(client -> client.describe_keyspace(configManager.getConfig().keyspace()).getCf_defs()); for (CfDef clusterSideCf : knownCfs) { TableReference tableRef = tableReferenceFromCfDef(clusterSideCf); if (metadataForTables.containsKey(tableRef)) { byte[] clusterSideMetadata = metadataForTables.get(tableRef); CfDef clientSideCf = getCfForTable(tableRef, clusterSideMetadata, configManager.getConfig().gcGraceSeconds()); if (!ColumnFamilyDefinitions.isMatchingCf(clientSideCf, clusterSideCf)) { log.warn("Upgrading table to new internal Cassandra schema", UnsafeArg.of("table", tableRef)); updatedCfs.add(clientSideCf); } } else if (!hiddenTables.isHidden(tableRef)) { log.error("Found a table that did not have persisted" + " AtlasDB metadata. If you recently did a Palantir update, try waiting until" + " schema upgrades are completed on all backend CLIs/services etc and restarting" + " this service. If this error re-occurs on subsequent attempted startups, please" + " contact Palantir support.", UnsafeArg.of("table", tableRef.getQualifiedName())); } } Map<Cell, byte[]> emptyMetadataUpdate = ImmutableMap.of(); if (!updatedCfs.isEmpty()) { putMetadataAndMaybeAlterTables(true, emptyMetadataUpdate, updatedCfs); log.info("New table-related settings were applied on startup!!"); } else { log.info("No tables are being upgraded on startup. No updated table-related settings found."); } } catch (TException e) { log.error("Couldn't upgrade from an older internal Cassandra schema." + " New table-related settings may not have taken effect."); } }