Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small code quality improvements #313

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.confluent.ksql.function;

import org.apache.kafka.connect.data.Schema;
import org.apache.kafka.streams.kstream.Merger;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ public static void addFunction(KsqlFunction ksqlFunction) {
}

public static boolean isAnAggregateFunction(String functionName) {
if (ksqlAggregateFunctionMap.get(functionName) != null) {
return true;
}
return false;
return ksqlAggregateFunctionMap.get(functionName) != null;
}

public static KsqlAggregateFunction getAggregateFunction(String functionName, List<Expression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ private String getKsqlTypeInJson(final Schema schemaType) {
return "STRING";
} else if (schemaType == Schema.FLOAT64_SCHEMA) {
return "DOUBLE";
} else if (schemaType == Schema.INT64_SCHEMA) {
return "INTEGER";
} else if (schemaType == Schema.BOOLEAN_SCHEMA) {
return "BOOL";
}
Expand Down Expand Up @@ -276,8 +274,7 @@ public void writeMetastoreToFile(String filePath, MetaStore metaStore) {
addSchemas(stringBuilder, metaStore.getAllStructuredDataSources());
stringBuilder.append("}");

try {
RandomAccessFile raf = new RandomAccessFile(filePath, "rw");
try (RandomAccessFile raf = new RandomAccessFile(filePath, "rw")) {
raf.writeBytes(stringBuilder.toString());
raf.close();
} catch (IOException e) {
Expand All @@ -301,8 +298,7 @@ private String getAvroSchema(final String schemaFilePath) throws IOException {

public void writeAvroSchemaFile(final String avroSchema, final String filePath) {

try {
RandomAccessFile randomAccessFile = new RandomAccessFile(filePath, "rw");
try (RandomAccessFile randomAccessFile = new RandomAccessFile(filePath, "rw")) {
randomAccessFile.writeBytes(avroSchema);
randomAccessFile.close();
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static int getFieldIndexByName(final Schema schema, final String fieldNam
}
for (int i = 0; i < schema.fields().size(); i++) {
Field field = schema.fields().get(i);
int dotIndex = field.name().indexOf(".");
int dotIndex = field.name().indexOf('.');
if (dotIndex == -1) {
if (field.name().equals(fieldName)) {
return i;
Expand Down Expand Up @@ -189,7 +189,7 @@ public static synchronized Schema removeImplicitRowTimeRowKeyFromSchema(Schema s
SchemaBuilder schemaBuilder = SchemaBuilder.struct();
for (Field field: schema.fields()) {
String fieldName = field.name();
fieldName = fieldName.substring(fieldName.indexOf(".") + 1);
fieldName = fieldName.substring(fieldName.indexOf('.') + 1);
if (!fieldName.equalsIgnoreCase(SchemaUtil.ROWTIME_NAME)
&& !fieldName.equalsIgnoreCase(SchemaUtil.ROWKEY_NAME)) {
schemaBuilder.field(fieldName, field.schema());
Expand Down