Skip to content

CASSANALYTICS-104: Eliminate redundant filesystem lookups in SSTable streaming - #239

Open
lukasz-antoniak wants to merge 3 commits into
apache:trunkfrom
lukasz-antoniak:CASSANALYTICS-104
Open

CASSANALYTICS-104: Eliminate redundant filesystem lookups in SSTable streaming#239
lukasz-antoniak wants to merge 3 commits into
apache:trunkfrom
lukasz-antoniak:CASSANALYTICS-104

Conversation

@lukasz-antoniak

Copy link
Copy Markdown
Member

@lukasz-antoniak
lukasz-antoniak force-pushed the CASSANALYTICS-104 branch 2 times, most recently from 3b0267c to d49c9b5 Compare August 31, 2026 12:16
@lukasz-antoniak
lukasz-antoniak marked this pull request as ready for review September 1, 2026 05:51

@yifan-c yifan-c left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the CHANGES.txt

.map(StackTraceElement::toString)
.collect(Collectors.joining("\n"));
String errorMessage = exception.getClass().getName() + ": " + exception.getMessage()
+ "\n" + String.join("\n", stackTrace);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.join("\n", stackTrace) is equivalent to just stackTrace, right?
The stacktrace are already aggregated in the statement above.

// 4. remove the sstables once sent
Map<Path, Digest> fileDigests = sstableWriter.prepareSStablesToSend(writerContext, sstables);
SortedSSTableWriter.PreparedSSTables preparedSSTables = sstableWriter.prepareSStablesToSend(writerContext, sstables);
// retain only the SSTable data components

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment, it is stale with the removal of .filter

{
for (Path dataFile : dataFileStream)
{
if (isFileStreamed(dataFile))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StreamSession.isFileStreamed is now dead. Can you remove the code in the base class?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The effect of this method has no use. It can be deleted, along with isFileStreamed

{
for (Path componentFile : componentFileStream)
// send data component the last
if (preparedSSTable.dataFile().equals(componentFile))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can dataFile() return null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically it could, but only if data file was not generated during sstable creation (e.g. remainingSSTablesAfterClose contained some sstable files, but without Data.db). I have replaced the operands in equality check, and added preconditions check.

*/
public static class PreparedSSTables
{
private static final PreparedSSTables EMPTY = new PreparedSSTables();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EMPTY is mutable. Caller can call addIfAbsent on it and mess up the state.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you recheck now? I did not think of an easier way to fix this issue.

Comment on lines +455 to +458
public PreparedSSTable addIfAbsent(Path path)
{
String baseName = SSTables.getSSTableDescriptor(path).baseFilename;
return sstables.computeIfAbsent(baseName, (__) -> new PreparedSSTable());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the impl, getOrPrepareSSTable method name fits better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants