Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 239DE9C7B for ; Fri, 16 Dec 2011 14:33:06 +0000 (UTC) Received: (qmail 62106 invoked by uid 500); 16 Dec 2011 14:33:06 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 62022 invoked by uid 500); 16 Dec 2011 14:33:06 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 62015 invoked by uid 99); 16 Dec 2011 14:33:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 14:33:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 14:33:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C131923888D2; Fri, 16 Dec 2011 14:32:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1215155 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Date: Fri, 16 Dec 2011 14:32:43 -0000 To: commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111216143243.C131923888D2@eris.apache.org> Author: mduerig Date: Fri Dec 16 14:32:43 2011 New Revision: 1215155 URL: http://svn.apache.org/viewvc?rev=1215155&view=rev Log: Microkernel based Jackrabbit prototype (WIP) batch loading of child nodes Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1215155&r1=1215154&r2=1215155&view=diff ============================================================================== --- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java (original) +++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java Fri Dec 16 14:32:43 2011 @@ -418,8 +418,8 @@ public class NodeEntry extends Hierarchy // -> check for moved child entry in node-attic // -> check if child points to a removed/moved sns - List siblings = Collections.singletonList(entry.childNodeEntries.get(name)); - if (entry.containsAtticChild(siblings, name, index)) { + NodeEntry sibling = entry.childNodeEntries.get(name); + if (entry.containsAtticChild(sibling, name, index)) { throw new PathNotFoundException(factory.saveGetJCRPath(path)); } @@ -501,8 +501,8 @@ public class NodeEntry extends Hierarchy } // -> check for moved child entry in node-attic // -> check if child points to a removed/moved sns - List siblings = Collections.singletonList(entry.childNodeEntries.get(name)); - if (entry.containsAtticChild(siblings, name, index)) { + NodeEntry sibling = entry.childNodeEntries.get(name); + if (entry.containsAtticChild(sibling, name, index)) { throw new PathNotFoundException(factory.saveGetJCRPath(path)); } // break out of the loop and start deep loading the property @@ -616,7 +616,7 @@ public class NodeEntry extends Hierarchy try { return getNodeEntry(nodeName, index) != null; } catch (RepositoryException e) { - log.debug("Unable to determine if a child node with name " + nodeName + " exists."); + log.error("Unable to determine if a child node with name " + nodeName + " exists.", e); return false; } } @@ -650,29 +650,26 @@ public class NodeEntry extends Hierarchy * @throws RepositoryException If an unexpected error occurs. */ public NodeEntry getNodeEntry(Name nodeName, int index, boolean loadIfNotFound) throws RepositoryException { - List entries = Collections.singletonList(childNodeEntries.get(nodeName)); + if (index > Path.INDEX_DEFAULT) { + UnsupportedRepositoryOperationException e = new UnsupportedRepositoryOperationException( + "Invalid index: " + index); + log.error(e.getMessage(), e); + throw e; + } + + NodeEntry entry = childNodeEntries.get(nodeName); NodeEntry cne = null; - if (entries.size() >= index) { - // position of entry might differ from index-1 if a SNS with lower - // index has been transiently removed. - int eIndex = 1; - for (int i = 0; i < entries.size() && cne == null; i++) { - NodeEntry ne = entries.get(i); - if (EntryValidation.isValidNodeEntry(ne)) { - if (eIndex == index) { - cne = ne; - } - eIndex++; - } + if (EntryValidation.isValidNodeEntry(entry)) { + if (Path.INDEX_DEFAULT == index) { + cne = entry; } } if (cne == null && loadIfNotFound - && !containsAtticChild(entries, nodeName, index) + && !containsAtticChild(entry, nodeName, index) && !childNodeEntries.isComplete()) { - NodeId cId = getIdFactory().createNodeId(getWorkspaceId(), - getPathFactory().create(nodeName, index)); + NodeId cId = getIdFactory().createNodeId(getWorkspaceId(), getPathFactory().create(nodeName, index)); cne = loadNodeEntry(cId); } return cne; @@ -1264,37 +1261,27 @@ public class NodeEntry extends Hierarchy * been modified in a way that its original index is equal to the given * child index. * - * @param siblings + * @param sibling * @param childName * @param childIndex * @return {@code true} if there is a child entry in the attic that * matches the given name/index or if the siblings list contain a reordered * entry that matches. */ - private boolean containsAtticChild(List siblings, Name childName, int childIndex) { - // check if a matching entry exists in the attic - if (childNodeAttic.contains(childName)) { - return true; - } - // special treatment for potentially moved/reordered/removed sns - // TODO: check again + private boolean containsAtticChild(NodeEntry sibling, Name childName, int childIndex) + throws UnsupportedRepositoryOperationException { + if (childIndex > Path.INDEX_DEFAULT) { - NodeEntry siblingsInAttic = childNodeAttic.get(childName); - if (siblings.size() < childIndex && childIndex <= siblings.size() + (siblingsInAttic == null ? 0 : 1)) { - return true; - } - } - if (getStatus() == Status.EXISTING_MODIFIED) { - for (NodeEntry child : siblings) { - if (!EntryValidation.isValidNodeEntry(child) || - child.revertInfo != null && - Path.INDEX_DEFAULT == childIndex) { - - return true; - } - } + UnsupportedRepositoryOperationException e = new UnsupportedRepositoryOperationException( + "Invalid index: " + childIndex); + log.error(e.getMessage(), e); + throw e; } - return false; + + return childNodeAttic.contains(childName) || + getStatus() == Status.EXISTING_MODIFIED && + (!EntryValidation.isValidNodeEntry(sibling) || + sibling.revertInfo != null && Path.INDEX_DEFAULT == childIndex); } /**