Skip to content

Commit

Permalink
Merge branch 'main' into issue-281
Browse files Browse the repository at this point in the history
  • Loading branch information
flyrain authored Oct 19, 2024
2 parents 90e4400 + 3191ea0 commit 9eab509
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
20 changes: 3 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
# add aws keys as dropwizard config
JAVA_OPTS: -Ddw.awsAccessKey=$AWS_ACCESS_KEY_ID -Ddw.awsSecretKey=$AWS_SECRET_ACCESS_KEY
volumes:
- credentials:/tmp/credentials/
- ./regtests/credentials:/tmp/credentials/

healthcheck:
test: ["CMD", "curl", "http://localhost:8182/healthcheck"]
Expand Down Expand Up @@ -66,19 +66,5 @@ services:
AWS_CROSS_REGION_BUCKET: $AWS_CROSS_REGION_BUCKET
AWS_ROLE_FOR_CROSS_REGION_BUCKET: $AWS_ROLE_FOR_CROSS_REGION_BUCKET
volumes:
- local_output:/tmp/polaris-regtests/
- credentials:/tmp/credentials/

volumes:
local_output:
driver: local
driver_opts:
o: bind
type: none
device: ./regtests/output
credentials:
driver: local
driver_opts:
o: bind
type: none
device: ./regtests/credentials
- ./regtests/output:/tmp/polaris-regtests/
- ./regtests/credentials:/tmp/credentials/
10 changes: 1 addition & 9 deletions getting-started/spark/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,4 @@ services:
AWS_REGION: us-west-2
POLARIS_HOST: polaris
volumes:
- notebooks:/home/jovyan/notebooks

volumes:
notebooks:
driver: local
driver_opts:
o: bind
type: none
device: ./notebooks/
- ./notebooks:/home/jovyan/notebooks
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ protected final String ensureTrailingSlash(String location) {
}
}

/** If a path doesn't start with `/`, this will add one */
protected final @NotNull String ensureLeadingSlash(@NotNull String location) {
if (location.startsWith("/")) {
return location;
} else {
return "/" + location;
}
}

@Override
public int hashCode() {
return location.hashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ public boolean isChildOf(@NotNull StorageLocation potentialParent) {
AzureLocation potentialAzureParent = (AzureLocation) potentialParent;
if (this.container.equals(potentialAzureParent.container)) {
if (this.storageAccount.equals(potentialAzureParent.storageAccount)) {
String slashTerminatedFilePath = ensureTrailingSlash(this.filePath);
String slashTerminatedParentFilePath = ensureTrailingSlash(potentialAzureParent.filePath);
return slashTerminatedFilePath.startsWith(slashTerminatedParentFilePath);
String formattedFilePath = ensureLeadingSlash(ensureTrailingSlash(this.filePath));
String formattedParentFilePath =
ensureLeadingSlash(ensureTrailingSlash(potentialAzureParent.filePath));
return formattedFilePath.startsWith(formattedParentFilePath);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public void testCrossSchemeComparisons() {
Assertions.assertThat(abfsLocation.isChildOf(wasbLocation)).isTrue();
}

@Test
public void testLocationComparisons() {
StorageLocation location =
AzureLocation.of("abfss://[email protected]/some_file/metadata");
StorageLocation parentLocation =
AzureLocation.of("abfss://[email protected]");
StorageLocation parentLocationTrailingSlash =
AzureLocation.of("abfss://[email protected]/");

Assertions.assertThat(location).isNotEqualTo(parentLocation);
Assertions.assertThat(location).isNotEqualTo(parentLocationTrailingSlash);

Assertions.assertThat(location.isChildOf(parentLocation)).isTrue();
Assertions.assertThat(location.isChildOf(parentLocationTrailingSlash)).isTrue();
}

@Test
public void testLocation_negative_cases() {
Assertions.assertThatThrownBy(
Expand Down

0 comments on commit 9eab509

Please sign in to comment.