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

GH-16468 - fix load_grid and loadGrid for S3 paths #16478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions h2o-persist-s3/src/main/java/water/persist/PersistS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ public PersistEntry[] list(String path) {
return entries;
}

@Override
public String getParent(String path) {
String[] bk = decodePath(path);
String bucket = bk[0];
String key = bk[1];
if (key.endsWith("/")) {
key = key.substring(0, key.length() - 1);
}
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("No parent exists for a bucket-only path: " + path);
}
int lastSlash = key.lastIndexOf("/");
if (lastSlash == -1) {
return "s3://" + bucket;
}
return "s3://" + bucket + "/" + key.substring(0, lastSlash);
}

@Override
public InputStream open(String path) {
String[] bk = decodePath(path);
Expand Down