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

CNDB-13031: change Descriptor#fileFor to use the same file system as Descriptor#directory #1613

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions src/java/org/apache/cassandra/io/sstable/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public static Component parse(String name)
}
}

/**
* @return file that uses the resolved file system as provided absolutePath URI
*/
public File getFile(String absolutePath)
{
File ret;
Expand All @@ -172,6 +175,20 @@ public File getFile(String absolutePath)
return StorageProvider.instance.withOpenOptions(ret, this);
}

/**
* @return file that uses the same file system as provided directory
*/
public File getFile(File directory, String filenamePart)

Choose a reason for hiding this comment

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

please add unit tests about this method, it is easy to forget edge cases or introduce regressions in the future

we can probably have a static method that does the path handling, so that doing unit tests is easier

{
File ret;
if (filenamePart.lastIndexOf(separator) != (filenamePart.length() - 1))
ret = directory.resolve(filenamePart + separator + name);
else
ret = directory.resolve(filenamePart + name);

return StorageProvider.instance.withOpenOptions(ret, this);
}

@Override
public String toString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/io/sstable/Descriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public String filenameFor(Component component)

public File fileFor(Component component)
{
return componentFileMap.computeIfAbsent(component, c -> component.getFile(baseFileURI));
return componentFileMap.computeIfAbsent(component, c -> component.getFile(directory, filenamePart));
}

public String baseFilename()
Expand Down
Loading