Skip to content
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 @@ -38,13 +38,12 @@ public interface PrimaryKeyMap extends Closeable
* A factory for creating {@link PrimaryKeyMap} instances. Implementations of this
* interface are expected to be threadsafe.
*/
public interface Factory extends Closeable
interface Factory extends Closeable
{
/**
* Creates a new {@link PrimaryKeyMap} instance
*
* @return a {@link PrimaryKeyMap}
* @throws IOException
*/
PrimaryKeyMap newPerSSTablePrimaryKeyMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ interface ForWrite extends ForRead
* componentName will produce the same file.
* @param componentName - unique name within the per index components
* @return a temprory file for use during index construction
* @throws IOException
*/
File tmpFileFor(String componentName) throws IOException;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public IndexComponent.ForWrite getForWrite(IndexComponentType component)
}

@Override
public File tmpFileFor(String componentName) throws IOException
public File tmpFileFor(String componentName)
{
String name = context != null ? String.format("%s_%s_%s", buildId, context.getColumnName(), componentName)
: String.format("%s_%s", buildId, componentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public interface OnDiskFormat
/**
* Returns the {@link PrimaryKey.Factory} for the on-disk format
*
* @param comparator
* @return the primary key factory
*/
PrimaryKey.Factory newPrimaryKeyFactory(ClusteringComparator comparator);
Expand All @@ -91,7 +90,6 @@ public interface OnDiskFormat
* @param primaryKeyFactory The {@link PrimaryKey.Factory} corresponding to the provided {@code perSSTableComponents}.
* @param sstable The {@link SSTableReader} associated with the per-sstable components
* @return a {@link PrimaryKeyMap.Factory} for the SSTable
* @throws IOException
*/
PrimaryKeyMap.Factory newPrimaryKeyMapFactory(IndexComponents.ForRead perSSTableComponents, PrimaryKey.Factory primaryKeyFactory, SSTableReader sstable) throws IOException;

Expand All @@ -116,7 +114,6 @@ IndexSearcher newIndexSearcher(SSTableContext sstableContext,
*
* @param indexDescriptor The {@link IndexDescriptor} for the SSTable
* @return The {@link PerSSTableWriter} to write the per-SSTable on-disk components
* @throws IOException
*/
PerSSTableWriter newPerSSTableWriter(IndexDescriptor indexDescriptor) throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class MonotonicBlockPackedReader implements LongArray.Factory
private final PackedLongValues minValues;
private final float[] averages;

@SuppressWarnings("resource")
public MonotonicBlockPackedReader(FileHandle file, NumericValuesMeta meta) throws IOException
{
this.valueCount = meta.valueCount;
Expand Down Expand Up @@ -83,7 +82,6 @@ public MonotonicBlockPackedReader(FileHandle file, NumericValuesMeta meta) throw
}

@Override
@SuppressWarnings("resource")
public LongArray open()
{
var indexInput = IndexFileUtils.instance.openInput(file);
Expand All @@ -96,7 +94,7 @@ long delta(int block, int idx)
}

@Override
public void close() throws IOException
public void close()
{
indexInput.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ public String toString()
token,
partitionKey,
clustering == null ? null : clustering.kind(),
clustering == null ? null :String.join(",", Arrays.stream(clustering.getBufferArray())
.map(ByteBufferUtil::bytesToHex)
.collect(Collectors.toList())));
clustering == null ? null : Arrays.stream(clustering.getBufferArray())
.map(ByteBufferUtil::bytesToHex)
.collect(Collectors.joining(",")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
package org.apache.cassandra.index.sai.disk.v2;

import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.ByteOrder;
import java.util.EnumSet;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.cassandra.db.ClusteringComparator;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.index.sai.IndexContext;
Expand All @@ -49,8 +45,6 @@
*/
public class V2OnDiskFormat extends V1OnDiskFormat
{
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private static final Set<IndexComponentType> PER_SSTABLE_COMPONENTS = EnumSet.of(IndexComponentType.GROUP_COMPLETION_MARKER,
IndexComponentType.GROUP_META,
IndexComponentType.TOKEN_VALUES,
Expand Down
1 change: 0 additions & 1 deletion src/java/org/apache/cassandra/io/sstable/SSTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ public static void writeTOC(File tocFile, Collection<Component> components, File
/**
* Appends new component names to the TOC component.
*/
@SuppressWarnings("resource")
protected static void appendTOC(Descriptor descriptor, Collection<Component> components)
{
File tocFile = descriptor.fileFor(Component.TOC);
Expand Down
3 changes: 0 additions & 3 deletions src/java/org/apache/cassandra/schema/TableMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import com.google.common.base.MoreObjects;
import com.google.common.collect.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.cassandra.auth.DataResource;
import org.apache.cassandra.config.DatabaseDescriptor;
Expand Down Expand Up @@ -56,7 +54,6 @@
@Unmetered
public class TableMetadata implements SchemaElement
{
private static final Logger logger = LoggerFactory.getLogger(TableMetadata.class);

// Please note that currently the only one truly useful flag is COUNTER, as the rest of the flags were about
// differencing between CQL tables and the various types of COMPACT STORAGE tables (pre-4.0). As those "compact"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -119,7 +117,7 @@ public void teardown() throws IOException, ExecutionException, InterruptedExcept
* index from scratch each time.
*/
@Benchmark
public void compactVectorIndex() throws Throwable
public void compactVectorIndex()
{
compact();
}
Expand Down
4 changes: 1 addition & 3 deletions test/unit/org/apache/cassandra/index/sai/SAITester.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ protected void simulateNodeRestart()
protected void simulateNodeRestart(boolean wait)
{
ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable());
cfs.indexManager.listIndexes().forEach(index -> {
((StorageAttachedIndexGroup)cfs.indexManager.getIndexGroup(index)).reset();
});
cfs.indexManager.listIndexes().forEach(index -> ((StorageAttachedIndexGroup)cfs.indexManager.getIndexGroup(index)).reset());
cfs.indexManager.listIndexes().forEach(cfs.indexManager::buildIndex);
cfs.indexManager.executePreJoinTasksBlocking(true);
if (wait)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ private void insertData2()
}

@Test
public void queryFromMemtable() throws Throwable
public void queryFromMemtable()
{
insertData1();
insertData2();
runQueries();
}

@Test
public void queryFromSingleSSTable() throws Throwable
public void queryFromSingleSSTable()
{
insertData1();
insertData2();
Expand All @@ -68,7 +68,7 @@ public void queryFromSingleSSTable() throws Throwable
}

@Test
public void queryFromMultipleSSTables() throws Throwable
public void queryFromMultipleSSTables()
{
insertData1();
flush();
Expand All @@ -78,7 +78,7 @@ public void queryFromMultipleSSTables() throws Throwable
}

@Test
public void queryFromMemtableAndSSTables() throws Throwable
public void queryFromMemtableAndSSTables()
{
insertData1();
flush();
Expand All @@ -87,7 +87,7 @@ public void queryFromMemtableAndSSTables() throws Throwable
}

@Test
public void queryFromCompactedSSTable() throws Throwable
public void queryFromCompactedSSTable()
{
insertData1();
flush();
Expand All @@ -101,7 +101,7 @@ private Object[] expectedRow(int index) {
return row(index, Integer.toString(index), index);
}

private void runQueries() throws Throwable
private void runQueries()
{
assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE pk1 = 2"),
expectedRow(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private void validatePostingsStructureAndOrdinalToVectorMapping(String indexName
for (long i = segment.metadata.minSSTableRowId; i <= segment.metadata.maxSSTableRowId; i++)
{
var primaryKey = pkm.primaryKeyFromRowId(i);
assertTrue("The subsequent logic assumes that we have no clustering columns", !primaryKey.hasClustering());
assertFalse("The subsequent logic assumes that we have no clustering columns", primaryKey.hasClustering());
try (var sstableIter = segment.sstableContext
.sstable()
.iterator(primaryKey.partitionKey(), Slices.ALL, columnFilter, false, SSTableReadsListener.NOOP_LISTENER))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static List<Object[]> startupScenarios()
}

@Test
public void startupOrderingTest() throws Throwable
public void startupOrderingTest()
{
populator.populate(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void testNoInitialBuildWithSAI()
assertTrue(sstableContext.contains(secondSSTable));

// SAI#canFlushFromMemtableIndex should be true
StorageAttachedIndex sai = (StorageAttachedIndex) group.getIndexes().iterator().next();
StorageAttachedIndex sai = group.getIndexes().iterator().next();
assertTrue(sai.canFlushFromMemtableIndex());

// flush another memtable: it should be flushed with MemtableIndexWriter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,25 @@ public void shouldZeroMemoryAfterConcurrentIndexFailures() throws Throwable
assertEquals("Segment buffer memory tracker should start at zero!", 0L, getSegmentBufferUsedBytes());
assertEquals("There should be no segment builders in progress.", 0L, getColumnIndexBuildsInProgress());

execute("INSERT INTO " + KEYSPACE + "." + table1 + "(id1, v1, v2) VALUES ('0', 0, '0')");
execute("INSERT INTO " + KEYSPACE + '.' + table1 + "(id1, v1, v2) VALUES ('0', 0, '0')");
flush(KEYSPACE, table1);
execute("INSERT INTO " + KEYSPACE + "." + table1 + "(id1, v1, v2) VALUES ('1', 1, '1')");
execute("INSERT INTO " + KEYSPACE + '.' + table1 + "(id1, v1, v2) VALUES ('1', 1, '1')");
flush(KEYSPACE, table1);
Collection<SSTableReader> sstablesTable1 = getColumnFamilyStore(KEYSPACE, table1).getLiveSSTables();

execute("INSERT INTO " + KEYSPACE + "." + table2 + "(id1, v1, v2) VALUES ('0', 0, '0')");
execute("INSERT INTO " + KEYSPACE + '.' + table2 + "(id1, v1, v2) VALUES ('0', 0, '0')");
flush(KEYSPACE, table2);
execute("INSERT INTO " + KEYSPACE + "." + table2 + "(id1, v1, v2) VALUES ('1', 1, '1')");
execute("INSERT INTO " + KEYSPACE + '.' + table2 + "(id1, v1, v2) VALUES ('1', 1, '1')");
flush(KEYSPACE, table2);
Collection<SSTableReader> sstablesTable2 = getColumnFamilyStore(KEYSPACE, table2).getLiveSSTables();

// Start compaction against both tables/indexes and verify that they are aborted safely:
verifyCompactionIndexBuilds(2, segmentFlushFailure, table1, table2);

executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + "." + table1));
executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + '.' + table1));
assertThat(getColumnFamilyStore(KEYSPACE, table1).getLiveSSTables()).isEqualTo(sstablesTable1);

executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + "." + table2));
executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + '.' + table2));
assertThat(getColumnFamilyStore(KEYSPACE, table2).getLiveSSTables()).isEqualTo(sstablesTable2);
}

Expand All @@ -258,25 +258,25 @@ public void shouldLeaveOnlyFailedIndexNonQueryable() throws Throwable
assertEquals("Segment buffer memory tracker should start at zero!", 0L, getSegmentBufferUsedBytes());
assertEquals("There should be no segment builders in progress.", 0L, getColumnIndexBuildsInProgress());

execute("INSERT INTO " + KEYSPACE + "." + table1 + "(id1, v1, v2) VALUES ('0', 0, '0')");
execute("INSERT INTO " + KEYSPACE + '.' + table1 + "(id1, v1, v2) VALUES ('0', 0, '0')");
flush(KEYSPACE, table1);
execute("INSERT INTO " + KEYSPACE + "." + table1 + "(id1, v1, v2) VALUES ('1', 1, '1')");
execute("INSERT INTO " + KEYSPACE + '.' + table1 + "(id1, v1, v2) VALUES ('1', 1, '1')");
flush(KEYSPACE, table1);
Collection<SSTableReader> sstablesTable1 = getColumnFamilyStore(KEYSPACE, table1).getLiveSSTables();

execute("INSERT INTO " + KEYSPACE + "." + table2 + "(id1, v1, v2) VALUES ('0', 0, '0')");
execute("INSERT INTO " + KEYSPACE + '.' + table2 + "(id1, v1, v2) VALUES ('0', 0, '0')");
flush(KEYSPACE, table2);
execute("INSERT INTO " + KEYSPACE + "." + table2 + "(id1, v1, v2) VALUES ('1', 1, '1')");
execute("INSERT INTO " + KEYSPACE + '.' + table2 + "(id1, v1, v2) VALUES ('1', 1, '1')");
flush(KEYSPACE, table2);

// Start compaction against both tables/indexes, and verify only the numeric index is aborted:
verifyCompactionIndexBuilds(1, kdTreeSegmentFlushFailure, table1, table2);

// index is still queryable and sstables remain the same
executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + "." + table1));
executeNet(String.format("SELECT * FROM %s WHERE v1 = 0", KEYSPACE + '.' + table1));
assertThat(getColumnFamilyStore(KEYSPACE, table1).getLiveSSTables()).isEqualTo(sstablesTable1);

ResultSet rows = executeNet(String.format("SELECT * FROM %s WHERE v2 = '0'", KEYSPACE + "." + table2));
ResultSet rows = executeNet(String.format("SELECT * FROM %s WHERE v2 = '0'", KEYSPACE + '.' + table2));
assertEquals(1, rows.all().size());

// table2 succeeded compaction
Expand Down