Package org.apache.hadoop.fs.s3a.commit
Class MagicCommitPaths
java.lang.Object
org.apache.hadoop.fs.s3a.commit.MagicCommitPaths
Operations on (magic) paths.
-
Method Summary
Modifier and TypeMethodDescriptionbasePathChildren(List<String> elements) Get any child path elements under any__basepath, or an empty list if there is either: no__basepath element, or no child entries under it.static booleancontainsBasePath(List<String> elements) Does the list of magic elements contain a base path marker?static StringelementsToKey(List<String> elements) Take a list of elements and create an S3 key by joining them with "/" between each one.static StringGet the filename of a path: the last element.finalDestination(List<String> elements) Calculates the final destination of a file.static booleanisMagicPath(List<String> elements) Is a path in the magic tree?static StringlastElement(List<String> strings) Last element of a (non-empty) list.static intmagicElementIndex(List<String> elements) Get the index of the magic path element.magicPathChildren(List<String> elements) Get the child path elements under the magic path.magicPathParents(List<String> elements) Get the parent path elements of the magic path.splitPathToElements(org.apache.hadoop.fs.Path path) Take an absolute path, split it into a list of elements.
-
Method Details
-
splitPathToElements
Take an absolute path, split it into a list of elements. If empty, the path is the root path.- Parameters:
path- input path- Returns:
- a possibly empty list of elements.
- Throws:
IllegalArgumentException- if the path is invalid -relative, empty...
-
isMagicPath
Is a path in the magic tree?- Parameters:
elements- element list- Returns:
- true if a path is considered magic
-
containsBasePath
Does the list of magic elements contain a base path marker?- Parameters:
elements- element list, already stripped out from the magic tree.- Returns:
- true if a path has a base directory
-
magicElementIndex
Get the index of the magic path element.- Parameters:
elements- full path element list- Returns:
- the index.
- Throws:
IllegalArgumentException- if there is no magic element
-
magicPathParents
Get the parent path elements of the magic path. The list may be immutable or may be a view of the underlying list. Both the parameter list and the returned list MUST NOT be modified.- Parameters:
elements- full path element list- Returns:
- the parent elements; may be empty
-
magicPathChildren
Get the child path elements under the magic path. The list may be immutable or may be a view of the underlying list. Both the parameter list and the returned list MUST NOT be modified.- Parameters:
elements- full path element list- Returns:
- the child elements; may be empty
-
basePathChildren
Get any child path elements under any__basepath, or an empty list if there is either: no__basepath element, or no child entries under it. The list may be immutable or may be a view of the underlying list. Both the parameter list and the returned list MUST NOT be modified.- Parameters:
elements- full path element list- Returns:
- the child elements; may be empty
-
elementsToKey
Take a list of elements and create an S3 key by joining them with "/" between each one.- Parameters:
elements- path elements- Returns:
- a path which can be used in the AWS API
-
filename
Get the filename of a path: the last element.- Parameters:
elements- element list.- Returns:
- the filename; the last element.
-
lastElement
Last element of a (non-empty) list.- Parameters:
strings- strings in- Returns:
- the last one.
-
finalDestination
Calculates the final destination of a file. This is the parent of any "MAGIC PATH" element, and the filename of the path. That is: all intermediate child path elements are discarded. Why so? paths under the magic path include job attempt and task attempt subdirectories, which need to be skipped. If there is a__basedirectory in the children, then it becomes a base for unflattened paths, that is: all its children are pulled into the final destination.- Parameters:
elements- element list.- Returns:
- the path
-