Maxwell-Guo commented on code in PR #2786: URL: https://github.com/apache/cassandra/pull/2786#discussion_r1360816994
########## src/java/org/apache/cassandra/schema/SSTableFormatParams.java: ########## @@ -0,0 +1,383 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.schema; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; +import java.util.function.Function; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +import org.slf4j.LoggerFactory; + +import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.exceptions.ConfigurationException; +import org.apache.cassandra.exceptions.SyntaxException; +import org.apache.cassandra.io.sstable.format.big.BigFormat; +import org.apache.cassandra.io.sstable.format.bti.BtiFormat; +import org.apache.cassandra.utils.BloomCalculations; + +import static java.lang.String.format; +import static org.apache.cassandra.schema.SSTableFormatParams.Option.BLOOM_FILTER_FP_CHANCE; +import static org.apache.cassandra.schema.SSTableFormatParams.Option.CRC_CHECK_CHANCE; +import static org.apache.cassandra.schema.SSTableFormatParams.Option.MAX_INDEX_INTERVAL; +import static org.apache.cassandra.schema.SSTableFormatParams.Option.MIN_INDEX_INTERVAL; +import static org.apache.cassandra.schema.SSTableFormatParams.Option.TYPE; +import static org.apache.cassandra.schema.TableParams.fail; + +/** + * This class describes the params that is used to define the sstable's + * format params when modifing the table schema. + */ +public final class SSTableFormatParams +{ + private final ImmutableMap<Option, String> options;; + + public static final String DEFAUL_BIG_TYPE = "big"; + public static final double DEFAULT_CRC_CHECK_CHANCE = 1.0; + public static final double INVALID_BLOOM_FILTER_FP_CHANCE = -1; + public static final double DEFAULT_BLOOM_FILTER_FP_CHANCE = 0.01; + public static final int DEFAULT_MAX_INDEX_INTERVAL = 2048; + public static final int DEFAULT_MIN_INDEX_INTERVAL = 128; + + private static final Map<String, SSTableFormatParams> CONFIGURATIONS = new HashMap<>(); + public static final SSTableFormatParams DEFAULT_BIG_SSTABLE = SSTableFormatParams.create(ImmutableMap.of(TYPE, DEFAUL_BIG_TYPE, + BLOOM_FILTER_FP_CHANCE, String.valueOf(DEFAULT_BLOOM_FILTER_FP_CHANCE), + CRC_CHECK_CHANCE, String.valueOf(DEFAULT_CRC_CHECK_CHANCE), + MIN_INDEX_INTERVAL, String.valueOf(DEFAULT_MIN_INDEX_INTERVAL), + MAX_INDEX_INTERVAL, String.valueOf(DEFAULT_MAX_INDEX_INTERVAL))); + private static final Map<String, SSTableFormatParams> + CONFIGURATION_DEFINITIONS = expandDefinitions(DatabaseDescriptor.getSSTableFormatOptions()); + public static final ImmutableSet<String> SSTABLE_FORMAT_TYPES = ImmutableSet.of(BigFormat.NAME, BtiFormat.NAME); + // big/bti sstable format with non-lcs default bf chance + public static Function<String, Map<String, String>> DEFAULT_FORMAT_MAP = new Function<String, Map<String, String>>() { + @Override + public Map<String, String> apply(String type) + { + return ImmutableMap.of(TYPE.getName(), type, + BLOOM_FILTER_FP_CHANCE.getName(), String.valueOf(DEFAULT_BLOOM_FILTER_FP_CHANCE), + CRC_CHECK_CHANCE.getName(), String.valueOf(DEFAULT_CRC_CHECK_CHANCE), + MIN_INDEX_INTERVAL.getName(), String.valueOf(DEFAULT_MIN_INDEX_INTERVAL), + MAX_INDEX_INTERVAL.getName(), String.valueOf(DEFAULT_MAX_INDEX_INTERVAL)); + } + }; + + // wether these deprecated properties are defined by ddl or not + private Map<Option, Object> schemaProperties = new HashMap<>(); + + public enum Option + { + TYPE("type"), + BLOOM_FILTER_FP_CHANCE("bloom_filter_fp_chance"), Review Comment: I got it, the enum here is just to list the options that can be defined by yaml and cql. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

