Skip to content

Commit

Permalink
Add final to constant fields
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 5, 2024
1 parent 6712526 commit 7b38032
Show file tree
Hide file tree
Showing 200 changed files with 393 additions and 383 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum JobType {
REFRESH("refresh"),
BATCH("batch");

private String text;
private final String text;

JobType(String text) {
this.text = text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum SessionState {
DEAD("dead"),
FAIL("fail");

public static List<SessionState> END_STATE = ImmutableList.of(DEAD, FAIL);
public static final List<SessionState> END_STATE = ImmutableList.of(DEAD, FAIL);

private final String sessionState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* be registered during initialization such as in Guice Module.
*/
public class SparkParameterComposerCollection {
private Collection<GeneralSparkParameterComposer> generalComposers = new ArrayList<>();
private Map<DataSourceType, Collection<DataSourceSparkParameterComposer>> datasourceComposers =
new HashMap<>();
private final Collection<GeneralSparkParameterComposer> generalComposers = new ArrayList<>();
private final Map<DataSourceType, Collection<DataSourceSparkParameterComposer>>
datasourceComposers = new HashMap<>();

/**
* Register composers for specific DataSourceType. The registered composer is called only if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SparkSubmitParameters {
public static final String EQUALS = "=";

@Setter private String className = DEFAULT_CLASS_NAME;
private Map<String, String> config = new LinkedHashMap<>();
private final Map<String, String> config = new LinkedHashMap<>();

/** Extra parameters to append finally */
@Setter private String extraParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public static SqlBaseParser getBaseParser(String sqlQuery) {

public static class SparkSqlTableNameVisitor extends SqlBaseParserBaseVisitor<Void> {

@Getter private List<FullyQualifiedTableName> fullyQualifiedTableNames = new LinkedList<>();
@Getter
private final List<FullyQualifiedTableName> fullyQualifiedTableNames = new LinkedList<>();

public SparkSqlTableNameVisitor() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class DatasourceEmbeddedQueryIdProviderTest {
@Mock AsyncQueryRequestContext asyncQueryRequestContext;

DatasourceEmbeddedQueryIdProvider datasourceEmbeddedQueryIdProvider =
final DatasourceEmbeddedQueryIdProvider datasourceEmbeddedQueryIdProvider =
new DatasourceEmbeddedQueryIdProvider();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class SparkQueryDispatcherTest {
new GrammarElementValidatorProvider(
ImmutableMap.of(), new DefaultGrammarElementValidator()));

private DataSourceSparkParameterComposer dataSourceSparkParameterComposer =
private final DataSourceSparkParameterComposer dataSourceSparkParameterComposer =
(datasourceMetadata, sparkSubmitParameters, dispatchQueryRequest, context) -> {
sparkSubmitParameters.setConfigItem(FLINT_INDEX_STORE_AUTH_KEY, "basic");
sparkSubmitParameters.setConfigItem(FLINT_INDEX_STORE_HOST_KEY, "HOST");
Expand All @@ -139,7 +139,7 @@ public class SparkQueryDispatcherTest {
KEY_FROM_DATASOURCE_COMPOSER, VALUE_FROM_DATASOURCE_COMPOSER);
};

private GeneralSparkParameterComposer generalSparkParameterComposer =
private final GeneralSparkParameterComposer generalSparkParameterComposer =
(sparkSubmitParameters, dispatchQueryRequest, context) -> {
sparkSubmitParameters.setConfigItem(KEY_FROM_COMPOSER, VALUE_FROM_COMPOSER);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public String getId() {
}
}

ConcreteStateModel model =
final ConcreteStateModel model =
ConcreteStateModel.builder().metadata(ImmutableMap.of(METADATA_KEY, METADATA_VALUE)).build();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class SparkParameterComposerCollectionTest {
@Mock DispatchQueryRequest dispatchQueryRequest;
@Mock AsyncQueryRequestContext asyncQueryRequestContext;

DataSourceType type1 = new DataSourceType("TYPE1");
DataSourceType type2 = new DataSourceType("TYPE2");
DataSourceType type3 = new DataSourceType("TYPE3");
final DataSourceType type1 = new DataSourceType("TYPE1");
final DataSourceType type2 = new DataSourceType("TYPE2");
final DataSourceType type3 = new DataSourceType("TYPE3");

SparkParameterComposerCollection collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.opensearch.sql.datasource.model.DataSourceType;

class GrammarElementValidatorProviderTest {
S3GlueSQLGrammarElementValidator s3GlueSQLGrammarElementValidator =
final S3GlueSQLGrammarElementValidator s3GlueSQLGrammarElementValidator =
new S3GlueSQLGrammarElementValidator();
SecurityLakeSQLGrammarElementValidator securityLakeSQLGrammarElementValidator =
final SecurityLakeSQLGrammarElementValidator securityLakeSQLGrammarElementValidator =
new SecurityLakeSQLGrammarElementValidator();
DefaultGrammarElementValidator defaultGrammarElementValidator =
final DefaultGrammarElementValidator defaultGrammarElementValidator =
new DefaultGrammarElementValidator();
GrammarElementValidatorProvider grammarElementValidatorProvider =
final GrammarElementValidatorProvider grammarElementValidatorProvider =
new GrammarElementValidatorProvider(
ImmutableMap.of(
DataSourceType.S3GLUE, s3GlueSQLGrammarElementValidator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class ClusterManagerEventListener implements LocalNodeClusterManagerListe

private Cancellable flintIndexRetentionCron;
private Cancellable flintStreamingJobHouseKeeperCron;
private ClusterService clusterService;
private ThreadPool threadPool;
private Client client;
private Clock clock;
private DataSourceService dataSourceService;
private FlintIndexMetadataService flintIndexMetadataService;
private FlintIndexOpFactory flintIndexOpFactory;
private final ClusterService clusterService;
private final ThreadPool threadPool;
private final Client client;
private final Clock clock;
private final DataSourceService dataSourceService;
private final FlintIndexMetadataService flintIndexMetadataService;
private final FlintIndexOpFactory flintIndexOpFactory;
private Duration sessionTtlDuration;
private Duration resultTtlDuration;
private TimeValue streamingJobHouseKeepingInterval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
*/
@RequiredArgsConstructor
public class StateStore {
public static String SETTINGS_FILE_NAME = "query_execution_request_settings.yml";
public static String MAPPING_FILE_NAME = "query_execution_request_mapping.yml";
public static String ALL_DATASOURCE = "*";
public static final String SETTINGS_FILE_NAME = "query_execution_request_settings.yml";
public static final String MAPPING_FILE_NAME = "query_execution_request_mapping.yml";
public static final String ALL_DATASOURCE = "*";

private static final Logger LOG = LogManager.getLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ScheduledAsyncQueryJobRunner implements ScheduledJobRunner {
AsyncRestExecutor.SQL_WORKER_THREAD_POOL_NAME;
private static final Logger LOGGER = LogManager.getLogger(ScheduledAsyncQueryJobRunner.class);

private static ScheduledAsyncQueryJobRunner INSTANCE = new ScheduledAsyncQueryJobRunner();
private static final ScheduledAsyncQueryJobRunner INSTANCE = new ScheduledAsyncQueryJobRunner();

public static ScheduledAsyncQueryJobRunner getJobRunnerInstance() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.opensearch.sql.spark.utils.IDUtils;

public class AsyncQueryExecutorServiceImplSpecTest extends AsyncQueryExecutorServiceSpec {
AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
final AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();

@Disabled("batch query is unsupported")
public void withoutSessionCreateAsyncQueryThenGetResultThenCancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class AsyncQueryExecutorServiceSpec extends OpenSearchIntegTestCase {
protected StatementStorageService statementStorageService;
protected AsyncQueryScheduler asyncQueryScheduler;
protected AsyncQueryRequestContext asyncQueryRequestContext;
protected SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();
protected final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.sql.spark.transport.model.AsyncQueryResult;

public class AsyncQueryGetResultSpecTest extends AsyncQueryExecutorServiceSpec {
AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
final AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();

/** Mock Flint index and index state */
private final FlintDatasetMock mockIndex =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class OpenSearchAsyncQueryJobMetadataStorageServiceTest extends OpenSearc
private static final String MOCK_RESULT_INDEX = "resultIndex";
private static final String MOCK_QUERY_ID = "00fdo6u94n7abo0q";
private OpenSearchAsyncQueryJobMetadataStorageService openSearchJobMetadataStorageService;
private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
private final AsyncQueryRequestContext asyncQueryRequestContext =
new NullAsyncQueryRequestContext();

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

public class MockFlintSparkJob {
private FlintIndexStateModel stateModel;
private FlintIndexStateModelService flintIndexStateModelService;
private String datasource;
private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
private final FlintIndexStateModelService flintIndexStateModelService;
private final String datasource;
private final AsyncQueryRequestContext asyncQueryRequestContext =
new NullAsyncQueryRequestContext();

public MockFlintSparkJob(
FlintIndexStateModelService flintIndexStateModelService, String latestId, String datasource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public class InteractiveSessionTest extends OpenSearchIntegTestCase {
private StartJobRequest startJobRequest;
private SessionStorageService sessionStorageService;
private StatementStorageService statementStorageService;
private SessionConfigSupplier sessionConfigSupplier = () -> 600000L;
private final SessionConfigSupplier sessionConfigSupplier = () -> 600000L;
private SessionManager sessionManager;
private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
private SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();
private final AsyncQueryRequestContext asyncQueryRequestContext =
new NullAsyncQueryRequestContext();
private final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public class StatementTest extends OpenSearchIntegTestCase {

private StatementStorageService statementStorageService;
private SessionStorageService sessionStorageService;
private TestEMRServerlessClient emrsClient = new TestEMRServerlessClient();
private SessionConfigSupplier sessionConfigSupplier = () -> 600000L;
private SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();
private final TestEMRServerlessClient emrsClient = new TestEMRServerlessClient();
private final SessionConfigSupplier sessionConfigSupplier = () -> 600000L;
private final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider();

private SessionManager sessionManager;
private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext();
private final AsyncQueryRequestContext asyncQueryRequestContext =
new NullAsyncQueryRequestContext();

@Before
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@ExtendWith(MockitoExtension.class)
class FlintIndexStateModelXContentSerializerTest {

private FlintIndexStateModelXContentSerializer serializer =
private final FlintIndexStateModelXContentSerializer serializer =
new FlintIndexStateModelXContentSerializer();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

public class AwsSigningInterceptor implements Interceptor {

private OkHttpAwsV4Signer okHttpAwsV4Signer;
private final OkHttpAwsV4Signer okHttpAwsV4Signer;

private AWSCredentialsProvider awsCredentialsProvider;
private final AWSCredentialsProvider awsCredentialsProvider;

private static final Logger LOG = LogManager.getLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class BasicAuthenticationInterceptor implements Interceptor {

private String credentials;
private final String credentials;

public BasicAuthenticationInterceptor(@NonNull String username, @NonNull String password) {
this.credentials = Credentials.basic(username, password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class BasicTest {

@Rule public TemporaryFolder tempFolder = new TemporaryFolder();
@Rule public final TemporaryFolder tempFolder = new TemporaryFolder();

private GrokCompiler compiler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class DataSourceSchemaIdentifierNameResolver {

private String dataSourceName = DEFAULT_DATASOURCE_NAME;
private String schemaName = DEFAULT_SCHEMA_NAME;
private String identifierName;
private DataSourceService dataSourceService;
private final String identifierName;
private final DataSourceService dataSourceService;

private static final String DOT = ".";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
public class SymbolTable {

/** Two-dimension hash table to manage symbols with type in different namespace. */
private Map<Namespace, NavigableMap<String, ExprType>> tableByNamespace =
private final Map<Namespace, NavigableMap<String, ExprType>> tableByNamespace =
new EnumMap<>(Namespace.class);

/**
* Two-dimension hash table to manage symbols with type in different namespace. Comparing with
* tableByNamespace, orderedTable use the LinkedHashMap to keep the order of symbol.
*/
private Map<Namespace, LinkedHashMap<String, ExprType>> orderedTable =
private final Map<Namespace, LinkedHashMap<String, ExprType>> orderedTable =
new EnumMap<>(Namespace.class);

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/opensearch/sql/ast/tree/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@EqualsAndHashCode(callSuper = false)
@Getter
public class Filter extends UnresolvedPlan {
private UnresolvedExpression condition;
private final UnresolvedExpression condition;
private UnresolvedPlan child;

public Filter(UnresolvedExpression condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@EqualsAndHashCode(callSuper = false)
public class Project extends UnresolvedPlan {
@Setter private List<UnresolvedExpression> projectList;
private List<Argument> argExprList;
private final List<Argument> argExprList;
private UnresolvedPlan child;

public Project(List<UnresolvedExpression> projectList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,36 @@ public class DataSourceMetadata {

public static final String DEFAULT_RESULT_INDEX = "query_execution_result";
public static final int MAX_RESULT_INDEX_NAME_SIZE = 255;
private static String DATASOURCE_NAME_REGEX = "[@*A-Za-z]+?[*a-zA-Z_\\-0-9]*";
private static final String DATASOURCE_NAME_REGEX = "[@*A-Za-z]+?[*a-zA-Z_\\-0-9]*";
// OS doesn’t allow uppercase: https://tinyurl.com/yse2xdbx
public static final String RESULT_INDEX_NAME_PATTERN = "[a-z0-9_-]+";
public static String INVALID_RESULT_INDEX_NAME_SIZE =
public static final String INVALID_RESULT_INDEX_NAME_SIZE =
"Result index name size must contains less than "
+ MAX_RESULT_INDEX_NAME_SIZE
+ " characters.";
public static String INVALID_CHAR_IN_RESULT_INDEX_NAME =
public static final String INVALID_CHAR_IN_RESULT_INDEX_NAME =
"Result index name has invalid character. Valid characters are a-z, 0-9, -(hyphen) and"
+ " _(underscore).";
public static String INVALID_RESULT_INDEX_PREFIX =
public static final String INVALID_RESULT_INDEX_PREFIX =
"Result index must start with " + DEFAULT_RESULT_INDEX;

@JsonProperty private String name;
@JsonProperty private final String name;

@JsonProperty private String description;
@JsonProperty private final String description;

@JsonProperty
@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
private DataSourceType connector;
private final DataSourceType connector;

@JsonProperty private List<String> allowedRoles;
@JsonProperty private final List<String> allowedRoles;

@JsonProperty private Map<String, String> properties;
@JsonProperty private final Map<String, String> properties;

@JsonProperty private String resultIndex;
@JsonProperty private final String resultIndex;

@JsonProperty private DataSourceStatus status;
@JsonProperty private final DataSourceStatus status;

public static Function<String, String> DATASOURCE_TO_RESULT_INDEX =
public static final Function<String, String> DATASOURCE_TO_RESULT_INDEX =
datasourceName -> String.format("%s_%s", DEFAULT_RESULT_INDEX, datasourceName);

private DataSourceMetadata(Builder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum DataSourceStatus {
ACTIVE("active"),
DISABLED("disabled");

private String text;
private final String text;

DataSourceStatus(String text) {
this.text = text;
Expand Down
Loading

0 comments on commit 7b38032

Please sign in to comment.