dlmarion commented on PR #3501:
URL: https://github.com/apache/accumulo/pull/3501#issuecomment-1594619115
> > At it's core, Path is a URI. The Path constructors perform validation on
the input, then create and set the URI. Except, when you use the constructor
Path(URI), that does not occur and does not incur the cost of the validation.
If we used the Path constructors (and the validation) when writing to the
metadata table, but used Path(URI) when reading from the metadata table, then
we could still keep the Path object vs going back to String.
>
> The primary bottleneck does not appear to be he actual creation of the
Path(). It turns out it's the call to Path.getParent() that is the main problem
which is only done in our validation logic.
Right, so we call Path.getParent(), with calls new Path(String, String,
String). Here's Path.getParent:
```
/**
* Returns the parent of a path or null if at root.
* @return the parent of a path or null if at root
*/
public Path getParent() {
String path = uri.getPath();
int lastSlash = path.lastIndexOf('/');
int start = startPositionWithoutWindowsDrive(path);
if ((path.length() == start) || // empty path
(lastSlash == start && path.length() == start+1)) { // at root
return null;
}
String parent;
if (lastSlash==-1) {
parent = CUR_DIR;
} else {
parent = path.substring(0, lastSlash==start?start+1:lastSlash);
}
return new Path(uri.getScheme(), uri.getAuthority(), parent);
}
```
The issue is the last line of the method, right? Could we not create a URI
from (String, String, String) and then call Path(URI)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]