-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-13704. Optimised getContentSummary() #3978
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
Closed
ahmarsuhail
wants to merge
9
commits into
apache:trunk
from
ahmarsuhail:HADOOP-13704-optimised-content-summary
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
155156c
Implements optimised getContentSummary
ahmarsuhail 9d1f809
fix typos
ahmarsuhail 7bc3db0
removes unused import
ahmarsuhail 3268bac
adds in S3A contract test
ahmarsuhail ae709a6
fixes checkstyle errors
ahmarsuhail 51d5918
Updates as per review comments
ahmarsuhail fb6ce92
test getContentSummary in testListOperations
ahmarsuhail 35ae9ce
fixes checkstyle errors
ahmarsuhail 3f3e1c4
fixes checkstyle errors
ahmarsuhail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...ommon/src/test/java/org/apache/hadoop/fs/contract/AbstractContractContentSummaryTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.fs.contract; | ||
|
|
||
| import org.apache.hadoop.fs.ContentSummary; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
|
|
||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.Test; | ||
|
|
||
| import java.io.FileNotFoundException; | ||
|
|
||
| import static org.apache.hadoop.fs.contract.ContractTestUtils.touch; | ||
| import static org.apache.hadoop.test.LambdaTestUtils.intercept; | ||
|
|
||
| public abstract class AbstractContractContentSummaryTest extends AbstractFSContractTestBase { | ||
|
|
||
| @Test | ||
| public void testGetContentSummary() throws Throwable { | ||
| FileSystem fs = getFileSystem(); | ||
|
|
||
| Path parent = path("parent"); | ||
| Path nested = path(parent + "/a/b/c"); | ||
| Path filePath = path(nested + "file.txt"); | ||
|
|
||
| fs.mkdirs(parent); | ||
| fs.mkdirs(nested); | ||
| touch(getFileSystem(), filePath); | ||
|
|
||
| ContentSummary summary = fs.getContentSummary(parent); | ||
|
|
||
| Assertions.assertThat(summary.getDirectoryCount()).as("Summary " + summary).isEqualTo(4); | ||
|
|
||
| Assertions.assertThat(summary.getFileCount()).as("Summary " + summary).isEqualTo(1); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetContentSummaryIncorrectPath() throws Throwable { | ||
| FileSystem fs = getFileSystem(); | ||
|
|
||
| Path parent = path("parent"); | ||
| Path nested = path(parent + "/a"); | ||
|
|
||
| fs.mkdirs(parent); | ||
|
|
||
| intercept(FileNotFoundException.class, () -> fs.getContentSummary(nested)); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
...rc/test/java/org/apache/hadoop/fs/contract/localfs/TestLocalFSContractContentSummary.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.fs.contract.localfs; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.contract.AbstractContractContentSummaryTest; | ||
| import org.apache.hadoop.fs.contract.AbstractFSContract; | ||
|
|
||
| public class TestLocalFSContractContentSummary extends AbstractContractContentSummaryTest { | ||
|
|
||
| @Override | ||
| protected AbstractFSContract createContract(Configuration conf) { | ||
| return new LocalFSContract(conf); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...p-aws/src/test/java/org/apache/hadoop/fs/contract/s3a/ITestS3AContractContentSummary.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.fs.contract.s3a; | ||
|
|
||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.Test; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.ContentSummary; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.fs.contract.AbstractContractContentSummaryTest; | ||
| import org.apache.hadoop.fs.contract.AbstractFSContract; | ||
| import org.apache.hadoop.fs.s3a.S3AFileSystem; | ||
|
|
||
| import static org.apache.hadoop.fs.contract.ContractTestUtils.touch; | ||
|
|
||
| public class ITestS3AContractContentSummary extends AbstractContractContentSummaryTest { | ||
|
|
||
| @Test | ||
| public void testGetContentSummaryDir() throws Throwable { | ||
| describe("getContentSummary on test dir with children"); | ||
| S3AFileSystem fs = getFileSystem(); | ||
| Path baseDir = methodPath(); | ||
|
|
||
| // Nested folders created separately will return as separate objects in listFiles() | ||
| fs.mkdirs(new Path(baseDir, "a")); | ||
| fs.mkdirs(new Path(baseDir, "a/b")); | ||
| fs.mkdirs(new Path(baseDir, "a/b/a")); | ||
|
|
||
| // Will return as one object | ||
| fs.mkdirs(new Path(baseDir, "d/e/f")); | ||
|
|
||
| Path filePath = new Path(baseDir, "a/b/file"); | ||
| touch(fs, filePath); | ||
|
|
||
| // look at path to see if it is a file | ||
| // it is not: so LIST | ||
| final ContentSummary summary = fs.getContentSummary(baseDir); | ||
|
|
||
| Assertions.assertThat(summary.getDirectoryCount()).as("Summary " + summary).isEqualTo(7); | ||
| Assertions.assertThat(summary.getFileCount()).as("Summary " + summary).isEqualTo(1); | ||
| } | ||
|
|
||
| @Override | ||
| protected AbstractFSContract createContract(Configuration conf) { | ||
| return new S3AContract(conf); | ||
| } | ||
|
|
||
| @Override | ||
| public S3AFileSystem getFileSystem() { | ||
| return (S3AFileSystem) super.getFileSystem(); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.