jackrabbit-oak-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig <mdue...@apache.org>
Subject Re: svn commit: r1440540 [1/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorizati...
Date Thu, 31 Jan 2013 10:41:18 GMT

Hi,

Preemptively building and caching the path here is worrisome since this 
will blow up memory usage quite a bit. This is the reason the path was 
only build on access (i.e. getPath()) in the original design and in 
TreeImpl.

Michael


On 30.1.13 17:33, angela@apache.org wrote:
> +    /**
> +     * Path of this tree
> +     */
> +    private final String path;
> +
> +    /**
> +     * Underlying node state
> +     */
>       private final NodeState state;
>
> -    public ReadOnlyTree(NodeState root) {
> -        this(null, "", root);
> +    public ReadOnlyTree(NodeState rootState) {
> +        this(null, "", rootState);
>       }
>
> -    public ReadOnlyTree(ReadOnlyTree parent, String name, NodeState state) {
> +    public ReadOnlyTree(@Nullable ReadOnlyTree parent, @Nonnull String name, @Nonnull
NodeState state) {
>           this.parent = parent;
>           this.name = checkNotNull(name);
> +        this.path = buildPath(parent, name);
>           this.state = checkNotNull(state);
>           checkArgument(!name.isEmpty() || parent == null);
>       }
>
> +    private static String buildPath(ReadOnlyTree parent, String name) {
> +        if (parent == null) {
> +            return "/";
> +        } else if (parent.isRoot()) {
> +            return parent.path + name;
> +        } else {
> +            StringBuilder sb = new StringBuilder();
> +            sb.append(parent.path).append('/').append(name);
> +            return sb.toString();
> +        }
> +    }

Mime
View raw message