Source:
<code>private void maybeUseTWCS(Session session, String keyspace) { String cassandraVersion = getCassandraVersion(session); String getCompactionClass; ResultSet resultSet; <START> if (cassandraVersion.startsWith("2")) { <END> getCompactionClass = "SELECT compaction_strategy_class FROM system.schema_columnfamilies WHERE " + "keyspace_name = '" + keyspace + "' AND columnfamily_name = 'data'"; resultSet = session.execute(getCompactionClass); if (resultSet.isExhausted()) { logger.warn("Unable to determine the compaction strategy for the data table due to empty result set"); return; } if (resultSet.one().getString(0).equals(TWCS_CLASS)) { return; } if (resultSet.one().getString(0).equals(TWCS_CLASS)) { return; } } else { getCompactionClass = "SELECT compaction FROM system_schema.tables WHERE keyspace_name = '" + keyspace + "' AND table_name = 'data'"; resultSet = session.execute(getCompactionClass); if (resultSet.isExhausted()) { logger.warn("Unable to determine the compaction strategy for the data table due to empty result set"); return; } Map<String, String> compactionProps = resultSet.one().getMap(0, String.class, String.class); if (compactionProps.get("class").equals(TWCS_CLASS)) { return; } } try { String updateCompaction = "ALTER TABLE " + keyspace + ".data WITH compaction = {'class': '" + TWCS_CLASS + "', 'compaction_window_unit': 'DAYS', 'compaction_window_size': 1}"; session.execute(updateCompaction); logger.infof("The compaction strategy for the data table has been updated to %s", TWCS_CLASS); } catch (Exception e) { logger.warn("Failed to update compaction strategy for the data table", e); } }</code><technical_language>this bite Cassandra 20 is released</technical_language>

Target:
private void maybeUseTWCS(Session session, String keyspace) { String cassandraVersion = getCassandraVersion(session); String getCompactionClass; ResultSet resultSet; if (cassandraVersion.startsWith("2")) { getCompactionClass = "SELECT compaction_strategy_class FROM system.schema_columnfamilies WHERE " + "keyspace_name = '" + keyspace + "' AND columnfamily_name = 'data'"; resultSet = session.execute(getCompactionClass); if (resultSet.isExhausted()) { logger.warn("Unable to determine the compaction strategy for the data table due to empty result set"); return; } if (resultSet.one().getString(0).equals(TWCS_CLASS)) { return; } } else { getCompactionClass = "SELECT compaction FROM system_schema.tables WHERE keyspace_name = '" + keyspace + "' AND table_name = 'data'"; resultSet = session.execute(getCompactionClass); if (resultSet.isExhausted()) { logger.warn("Unable to determine the compaction strategy for the data table due to empty result set"); return; } Map<String, String> compactionProps = resultSet.one().getMap(0, String.class, String.class); if (compactionProps.get("class").equals(TWCS_CLASS)) { return; } } try { String updateCompaction = "ALTER TABLE " + keyspace + ".data WITH compaction = {'class': '" + TWCS_CLASS + "', 'compaction_window_unit': 'DAYS', 'compaction_window_size': 1}"; session.execute(updateCompaction); logger.infof("The compaction strategy for the data table has been updated to %s", TWCS_CLASS); } catch (Exception e) { logger.warn("Failed to update compaction strategy for the data table", e); } }