Skip to content

Commit 2e74f7a

Browse files
k-ruslesnik2u
authored andcommitted
CNDB-15608 fix lint issues in affected files (#2131)
While working on CNDB-15608, IntelliJ lint complains were noticed, which are not related to the actual changes in the patch port. Thus I fix them in this separate commit to avoid unnecessary noise while working on the actual patch port. Many of the changes are align what I have already merged earlier in other PRs. Some of the changes might not match preferences from others and I am open for discussion. The changes include: - Remove unused imports - Use the formatter of the logger instead of string concatenation - Use method instead of lambda - Remove unnecessary suppression of resource warnings - Simplify Boolean conditions - Remove unnecessary modifiers in interfaces - Fix typos - Fixing links in javadoc comments - Add static modifier to nested classes - Remove class fields when not used - Remove unnecessary throws in method signatures - Use final when recommended - Remove unused method arguments - Replace single char strings with chars - Remove unnecessary null variable initialization - Replace assert true with assert equal - Change order of assert arguments to have expected value first - Remove unnecessary explicit casting
1 parent a328e81 commit 2e74f7a

25 files changed

+57
-66
lines changed

src/java/org/apache/cassandra/db/marshal/AbstractType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.cassandra.cql3.CQL3Type;
3838
import org.apache.cassandra.cql3.ColumnSpecification;
3939
import org.apache.cassandra.cql3.Term;
40+
import org.apache.cassandra.db.rows.Cell;
4041
import org.apache.cassandra.exceptions.InvalidColumnTypeException;
4142
import org.apache.cassandra.exceptions.SyntaxException;
4243
import org.apache.cassandra.io.util.DataInputPlus;

src/java/org/apache/cassandra/index/sai/IndexContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public int getIntOption(String name, int defaultValue)
614614
}
615615
catch (NumberFormatException e)
616616
{
617-
logger.error("Failed to parse index configuration " + name + " = " + value + " as integer");
617+
logger.error("Failed to parse index configuration {} = {} as integer", name, value);
618618
return defaultValue;
619619
}
620620
}
@@ -1003,7 +1003,7 @@ public long indexFileCacheSize()
10031003
public IndexFeatureSet indexFeatureSet()
10041004
{
10051005
IndexFeatureSet.Accumulator accumulator = new IndexFeatureSet.Accumulator(version);
1006-
getView().getIndexes().stream().map(SSTableIndex::indexFeatureSet).forEach(set -> accumulator.accumulate(set));
1006+
getView().getIndexes().stream().map(SSTableIndex::indexFeatureSet).forEach(accumulator::accumulate);
10071007
return accumulator.complete();
10081008
}
10091009
}

src/java/org/apache/cassandra/index/sai/SSTableContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private SSTableContext(SSTableContext copy)
6565
this.primaryKeyMapFactory = copy.primaryKeyMapFactory;
6666
}
6767

68-
@SuppressWarnings("resource")
6968
public static SSTableContext create(SSTableReader sstable, IndexComponents.ForRead perSSTableComponents)
7069
{
7170
var onDiskFormat = perSSTableComponents.onDiskFormat();

src/java/org/apache/cassandra/index/sai/StorageAttachedIndexGroup.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void rangeTombstone(RangeTombstone tombstone)
246246

247247
private void forEach(Consumer<Index.Indexer> action)
248248
{
249-
indexers.forEach(action::accept);
249+
indexers.forEach(action);
250250
}
251251
};
252252
}
@@ -336,7 +336,7 @@ public void handleNotification(INotification notification, Object sender)
336336

337337
// Avoid validation for index files just written following Memtable flush. ZCS streaming should
338338
// validate index checksum.
339-
boolean validate = notice.fromStreaming() || !notice.memtable().isPresent();
339+
boolean validate = notice.fromStreaming() || notice.memtable().isEmpty();
340340
onSSTableChanged(Collections.emptySet(), notice.added, indices, validate);
341341
}
342342
else if (notification instanceof SSTableListChangedNotification)
@@ -436,7 +436,7 @@ public int totalIndexBuildsInProgress()
436436
*/
437437
public int totalQueryableIndexCount()
438438
{
439-
return (int) indices.stream().filter(i -> baseCfs.indexManager.isIndexQueryable(i)).count();
439+
return (int) indices.stream().filter(baseCfs.indexManager::isIndexQueryable).count();
440440
}
441441

442442
/**
@@ -513,7 +513,7 @@ public void unsafeReload()
513513
public void reset()
514514
{
515515
contextManager.clear();
516-
indices.forEach(index -> index.makeIndexNonQueryable());
516+
indices.forEach(StorageAttachedIndex::makeIndexNonQueryable);
517517
onSSTableChanged(baseCfs.getLiveSSTables(), Collections.emptySet(), indices, false);
518518
}
519519
}

src/java/org/apache/cassandra/index/sai/disk/PerSSTableWriter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121

2222
import com.google.common.base.Stopwatch;
2323

24-
import org.apache.cassandra.db.DecoratedKey;
25-
import org.apache.cassandra.db.rows.Unfiltered;
2624
import org.apache.cassandra.index.sai.utils.PrimaryKey;
2725

2826
/**
2927
* Writes all SSTable-attached index token and offset structures.
3028
*/
3129
public interface PerSSTableWriter
3230
{
33-
public static final PerSSTableWriter NONE = (key) -> {};
31+
PerSSTableWriter NONE = key -> {};
3432

3533
default void startPartition(long position) throws IOException
3634
{}

src/java/org/apache/cassandra/index/sai/disk/format/IndexDescriptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public void markComplete() throws IOException
522522
{
523523
addOrGet(completionMarkerComponent()).createEmpty();
524524
sealed = true;
525-
// Until this call, the group is not attached to the parent. This create the link.
525+
// Until this call, the group is not attached to the parent. This creates the link.
526526
updateParentLink(this);
527527
}
528528

src/java/org/apache/cassandra/index/sai/disk/format/OnDiskFormat.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.cassandra.db.marshal.AbstractType;
2929
import org.apache.cassandra.index.sai.IndexContext;
3030
import org.apache.cassandra.index.sai.SSTableContext;
31+
import org.apache.cassandra.index.sai.SSTableIndex;
3132
import org.apache.cassandra.index.sai.StorageAttachedIndex;
3233
import org.apache.cassandra.index.sai.disk.PerIndexWriter;
3334
import org.apache.cassandra.index.sai.disk.PerSSTableWriter;
@@ -73,15 +74,15 @@ public interface OnDiskFormat
7374
*
7475
* @return the index feature set
7576
*/
76-
public IndexFeatureSet indexFeatureSet();
77+
IndexFeatureSet indexFeatureSet();
7778

7879
/**
7980
* Returns the {@link PrimaryKey.Factory} for the on-disk format
8081
*
8182
* @param comparator
8283
* @return the primary key factory
8384
*/
84-
public PrimaryKey.Factory newPrimaryKeyFactory(ClusteringComparator comparator);
85+
PrimaryKey.Factory newPrimaryKeyFactory(ClusteringComparator comparator);
8586

8687
/**
8788
* Returns a {@link PrimaryKeyMap.Factory} for the SSTable
@@ -92,18 +93,18 @@ public interface OnDiskFormat
9293
* @return a {@link PrimaryKeyMap.Factory} for the SSTable
9394
* @throws IOException
9495
*/
95-
public PrimaryKeyMap.Factory newPrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComponents, PrimaryKey.Factory primaryKeyFactory, SSTableReader sstable) throws IOException;
96+
PrimaryKeyMap.Factory newPrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComponents, PrimaryKey.Factory primaryKeyFactory, SSTableReader sstable) throws IOException;
9697

9798
/**
98-
* Create a new {@link SearchableIndex} for an on-disk index. This is held by the {@SSTableIndex}
99+
* Create a new {@link SearchableIndex} for an on-disk index. This is held by the {@link SSTableIndex}
99100
* and shared between queries.
100101
*
101102
* @param sstableContext The {@link SSTableContext} holding the per-SSTable information for the index
102103
* @param perIndexComponents The group of per-index sstable components to use/read for the returned index (which
103104
* also link to the underlying {@link IndexContext} for the index).
104105
* @return the created {@link SearchableIndex}.
105106
*/
106-
public SearchableIndex newSearchableIndex(SSTableContext sstableContext, IndexComponents.ForRead perIndexComponents);
107+
SearchableIndex newSearchableIndex(SSTableContext sstableContext, IndexComponents.ForRead perIndexComponents);
107108

108109
IndexSearcher newIndexSearcher(SSTableContext sstableContext,
109110
IndexContext indexContext,
@@ -117,7 +118,7 @@ IndexSearcher newIndexSearcher(SSTableContext sstableContext,
117118
* @return The {@link PerSSTableWriter} to write the per-SSTable on-disk components
118119
* @throws IOException
119120
*/
120-
public PerSSTableWriter newPerSSTableWriter(IndexDescriptor indexDescriptor) throws IOException;
121+
PerSSTableWriter newPerSSTableWriter(IndexDescriptor indexDescriptor) throws IOException;
121122

122123
/**
123124
* Create a new writer for the per-index on-disk components of an index. The {@link LifecycleNewTracker}
@@ -132,10 +133,10 @@ IndexSearcher newIndexSearcher(SSTableContext sstableContext,
132133
* @param keyCount
133134
* @return The {@link PerIndexWriter} that will write the per-index on-disk components
134135
*/
135-
public PerIndexWriter newPerIndexWriter(StorageAttachedIndex index,
136-
IndexDescriptor indexDescriptor,
137-
LifecycleNewTracker tracker,
138-
RowMapping rowMapping, long keyCount);
136+
PerIndexWriter newPerIndexWriter(StorageAttachedIndex index,
137+
IndexDescriptor indexDescriptor,
138+
LifecycleNewTracker tracker,
139+
RowMapping rowMapping, long keyCount);
139140

140141
/**
141142
* Validate the provided on-disk components (that must be for this version).
@@ -154,7 +155,7 @@ public PerIndexWriter newPerIndexWriter(StorageAttachedIndex index,
154155
*
155156
* @return The set of {@link IndexComponentType} for the per-SSTable index
156157
*/
157-
public Set<IndexComponentType> perSSTableComponentTypes();
158+
Set<IndexComponentType> perSSTableComponentTypes();
158159

159160
/**
160161
* Returns the set of {@link IndexComponentType} for the per-index part of an index.
@@ -164,12 +165,12 @@ public PerIndexWriter newPerIndexWriter(StorageAttachedIndex index,
164165
* @param indexContext The {@link IndexContext} for the index
165166
* @return The set of {@link IndexComponentType} for the per-index index
166167
*/
167-
default public Set<IndexComponentType> perIndexComponentTypes(IndexContext indexContext)
168+
default Set<IndexComponentType> perIndexComponentTypes(IndexContext indexContext)
168169
{
169170
return perIndexComponentTypes(indexContext.getValidator());
170171
}
171172

172-
public Set<IndexComponentType> perIndexComponentTypes(AbstractType<?> validator);
173+
Set<IndexComponentType> perIndexComponentTypes(AbstractType<?> validator);
173174

174175
/**
175176
* Return the number of open per-SSTable files that can be open during a query.
@@ -178,7 +179,7 @@ default public Set<IndexComponentType> perIndexComponentTypes(IndexContext index
178179
*
179180
* @return The number of open per-SSTable files
180181
*/
181-
public int openFilesPerSSTable();
182+
int openFilesPerSSTable();
182183

183184
/**
184185
* Return the number of open per-index files that can be open during a query.
@@ -188,7 +189,7 @@ default public Set<IndexComponentType> perIndexComponentTypes(IndexContext index
188189
* @param indexContext The {@link IndexContext} for the index
189190
* @return The number of open per-index files
190191
*/
191-
public int openFilesPerIndex(IndexContext indexContext);
192+
int openFilesPerIndex(IndexContext indexContext);
192193

193194
/**
194195
* Return the {@link ByteOrder} for the given {@link IndexComponentType} and {@link IndexContext}.
@@ -197,7 +198,7 @@ default public Set<IndexComponentType> perIndexComponentTypes(IndexContext index
197198
* @param context - The {@link IndexContext} for the index
198199
* @return The {@link ByteOrder} for the file associated with the {@link IndexComponentType}
199200
*/
200-
public ByteOrder byteOrderFor(IndexComponentType component, IndexContext context);
201+
ByteOrder byteOrderFor(IndexComponentType component, IndexContext context);
201202

202203
/**
203204
* Encode the given {@link ByteBuffer} into a {@link ByteComparable} object based on the provided {@link AbstractType}

src/java/org/apache/cassandra/index/sai/disk/v1/PartitionAwarePrimaryKeyFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public PrimaryKey create(DecoratedKey partitionKey, Clustering clustering)
5656
return new PartitionAwarePrimaryKey(partitionKey.getToken(), partitionKey, null);
5757
}
5858

59-
private class PartitionAwarePrimaryKey implements PrimaryKey
59+
private static class PartitionAwarePrimaryKey implements PrimaryKey
6060
{
6161
private final Token token;
6262
private DecoratedKey partitionKey;

src/java/org/apache/cassandra/index/sai/disk/v1/PartitionAwarePrimaryKeyMap.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.cassandra.index.sai.disk.v1;
2020

2121
import java.io.IOException;
22-
import java.nio.ByteBuffer;
2322

2423
import javax.annotation.concurrent.NotThreadSafe;
2524
import javax.annotation.concurrent.ThreadSafe;
@@ -106,8 +105,8 @@ public PartitionAwarePrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComp
106105
@Override
107106
public PrimaryKeyMap newPerSSTablePrimaryKeyMap()
108107
{
109-
final LongArray rowIdToToken = new LongArray.DeferredLongArray(() -> tokenReaderFactory.open());
110-
final LongArray rowIdToOffset = new LongArray.DeferredLongArray(() -> offsetReaderFactory.open());
108+
final LongArray rowIdToToken = new LongArray.DeferredLongArray(tokenReaderFactory::open);
109+
final LongArray rowIdToOffset = new LongArray.DeferredLongArray(offsetReaderFactory::open);
111110

112111
return new PartitionAwarePrimaryKeyMap(rowIdToToken, rowIdToOffset, partitioner, keyFetcher, primaryKeyFactory, sstableId);
113112
}

src/java/org/apache/cassandra/index/sai/disk/v1/PerIndexFiles.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import org.apache.cassandra.index.sai.disk.format.IndexComponents;
3030
import org.apache.cassandra.index.sai.disk.format.IndexComponentType;
31-
import org.apache.cassandra.index.sai.disk.format.Version;
3231
import org.apache.cassandra.io.util.FileHandle;
3332
import org.apache.cassandra.io.util.FileUtils;
3433

0 commit comments

Comments
 (0)