Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 51637 invoked from network); 10 Jul 2009 16:24:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jul 2009 16:24:26 -0000 Received: (qmail 61718 invoked by uid 500); 10 Jul 2009 16:24:36 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 61652 invoked by uid 500); 10 Jul 2009 16:24:36 -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 61643 invoked by uid 99); 10 Jul 2009 16:24:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jul 2009 16:24:36 +0000 X-ASF-Spam-Status: No, hits=-1998.4 required=10.0 tests=ALL_TRUSTED,FRT_OFFER2 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, 10 Jul 2009 16:24:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C9E4B238889D; Fri, 10 Jul 2009 16:24:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r793015 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ Date: Fri, 10 Jul 2009 16:24:03 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090710162403.C9E4B238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jukka Date: Fri Jul 10 16:24:02 2009 New Revision: 793015 URL: http://svn.apache.org/viewvc?rev=793015&view=rev Log: #0000 - JCR-1232: Merge UUID to NodeId Replace UUID references with NodeId alternatives from o.a.j.core.query.lucene. Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexReader.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndexReader.java jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingIndexReader.java Fri Jul 10 16:24:02 2009 @@ -25,7 +25,7 @@ import org.apache.lucene.index.TermDocs; import org.apache.lucene.index.TermEnum; import org.apache.lucene.index.CorruptIndexException; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import org.apache.commons.collections.map.LRUMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,6 @@ import java.util.BitSet; import java.util.Map; import java.util.HashMap; -import java.util.Iterator; import java.util.Collections; import java.text.NumberFormat; @@ -84,9 +83,9 @@ private final DocNumberCache cache; /** - * Maps document number to node UUID. + * Maps document number to node id. */ - private final Map docNumber2uuid; + private final Map docNumber2id; /** * A cache of TermDocs that are regularly read from the index. @@ -104,6 +103,7 @@ * when this index reader is constructed. * @throws IOException if an error occurs while reading from the index. */ + @SuppressWarnings("unchecked") CachingIndexReader(IndexReader delegatee, DocNumberCache cache, boolean initCache) @@ -126,8 +126,8 @@ cacheInitializer.run(); } // limit cache to 1% of maxDoc(), but at least 10. - this.docNumber2uuid = Collections.synchronizedMap(new LRUMap( - Math.max(10, delegatee.maxDoc() / 100))); + this.docNumber2id = Collections.synchronizedMap( + new LRUMap(Math.max(10, delegatee.maxDoc() / 100))); this.termDocsCache = new TermDocsCache(delegatee, FieldNames.PROPERTIES); } @@ -208,7 +208,7 @@ //--------------------< FilterIndexReader overwrites >---------------------- /** - * Uses the {@link #docNumber2uuid} cache for document lookups that are only + * Uses the {@link #docNumber2id} cache for document lookups that are only * interested in the {@link FieldSelectors#UUID}. * * @param n the document number. @@ -222,14 +222,14 @@ if (fieldSelector == FieldSelectors.UUID) { Integer docNum = new Integer(n); Document doc; - UUID uuid = (UUID) docNumber2uuid.get(docNum); - if (uuid == null) { + NodeId id = docNumber2id.get(docNum); + if (id == null) { doc = super.document(n, fieldSelector); - uuid = UUID.fromString(doc.get(FieldNames.UUID)); - docNumber2uuid.put(docNum, uuid); + id = new NodeId(doc.get(FieldNames.UUID)); + docNumber2id.put(docNum, id); } else { doc = new Document(); - doc.add(new Field(FieldNames.UUID, uuid.toString(), + doc.add(new Field(FieldNames.UUID, id.toString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } return doc; @@ -391,17 +391,17 @@ */ private void initializeParents(IndexReader reader) throws IOException { long time = System.currentTimeMillis(); - final Map docs = new HashMap(); + final Map docs = new HashMap(); // read UUIDs collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDocsCollector() { public void collect(Term term, TermDocs tDocs) throws IOException { - UUID uuid = UUID.fromString(term.text()); + NodeId id = new NodeId(term.text()); while (tDocs.next()) { int doc = tDocs.doc(); // skip shareable nodes if (!shareableNodes.get(doc)) { - NodeInfo info = new NodeInfo(doc, uuid); - docs.put(new Integer(doc), info); + NodeInfo info = new NodeInfo(doc, id); + docs.put(doc, info); } } } @@ -410,16 +410,16 @@ // read PARENTs collectTermDocs(reader, new Term(FieldNames.PARENT, "0"), new TermDocsCollector() { public void collect(Term term, TermDocs tDocs) throws IOException { - UUID uuid = UUID.fromString(term.text()); + NodeId id = new NodeId(term.text()); while (tDocs.next()) { Integer docId = new Integer(tDocs.doc()); NodeInfo info = (NodeInfo) docs.get(docId); if (info == null) { // shareable node, see above } else { - info.parent = uuid; + info.parent = id; docs.remove(docId); - docs.put(info.uuid, info); + docs.put(info.id, info); } } } @@ -430,10 +430,8 @@ } double foreignParents = 0; - Iterator it = docs.values().iterator(); - while (it.hasNext()) { - NodeInfo info = (NodeInfo) it.next(); - NodeInfo parent = (NodeInfo) docs.get(info.parent); + for (NodeInfo info : docs.values()) { + NodeInfo parent = docs.get(info.parent); if (parent != null) { parents[info.docId] = DocId.create(parent.docId); } else if (info.parent != null) { @@ -524,13 +522,13 @@ final int docId; - final UUID uuid; + final NodeId id; - UUID parent; + NodeId parent; - public NodeInfo(int docId, UUID uuid) { + public NodeInfo(int docId, NodeId id) { this.docId = docId; - this.uuid = uuid; + this.id = id; } } } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/CachingMultiIndexReader.java Fri Jul 10 16:24:02 2009 @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.core.query.lucene; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import org.apache.lucene.index.MultiReader; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermDocs; @@ -42,7 +42,8 @@ /** * Map of {@link OffsetReader}s, identified by creation tick. */ - private final Map readersByCreationTick = new HashMap(); + private final Map readersByCreationTick = + new HashMap(); /** * Document number cache if available. May be null. @@ -77,7 +78,7 @@ starts[i] = maxDoc; maxDoc += subReaders[i].maxDoc(); OffsetReader offsetReader = new OffsetReader(subReaders[i], starts[i]); - readersByCreationTick.put(new Long(subReaders[i].getCreationTick()), offsetReader); + readersByCreationTick.put(subReaders[i].getCreationTick(), offsetReader); } starts[subReaders.length] = maxDoc; } @@ -116,8 +117,8 @@ // check if valid: // 1) reader must be in the set of readers // 2) doc must not be deleted - OffsetReader offsetReader = (OffsetReader) readersByCreationTick.get( - new Long(e.creationTick)); + OffsetReader offsetReader = + readersByCreationTick.get(e.creationTick); if (offsetReader != null && !offsetReader.reader.isDeleted(e.doc)) { return new SingleTermDocs(e.doc + offsetReader.offset); } @@ -180,12 +181,12 @@ /** * {@inheritDoc} */ - public ForeignSegmentDocId createDocId(UUID uuid) throws IOException { - Term id = new Term(FieldNames.UUID, uuid.toString()); + public ForeignSegmentDocId createDocId(NodeId id) throws IOException { + Term term = new Term(FieldNames.UUID, id.toString()); int doc; long tick; for (int i = 0; i < subReaders.length; i++) { - TermDocs docs = subReaders[i].termDocs(id); + TermDocs docs = subReaders[i].termDocs(term); try { if (docs.next()) { doc = docs.doc(); Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheck.java Fri Jul 10 16:24:02 2009 @@ -21,7 +21,6 @@ import org.apache.jackrabbit.core.state.ItemStateException; import org.apache.jackrabbit.core.state.ChildNodeEntry; import org.apache.jackrabbit.core.id.NodeId; -import org.apache.jackrabbit.uuid.UUID; import org.apache.lucene.document.Document; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,9 +62,9 @@ private final MultiIndex index; /** - * All the document UUIDs within the index. + * All the document ids within the index. */ - private Set documentUUIDs; + private Set documentIds; /** * List of all errors. @@ -147,10 +146,10 @@ * @throws IOException if an error occurs while running the check. */ private void run() throws IOException { - // UUIDs of multiple nodes in the index - Set multipleEntries = new HashSet(); - // collect all documents UUIDs - documentUUIDs = new HashSet(); + // Ids of multiple nodes in the index + Set multipleEntries = new HashSet(); + // collect all documents ids + documentIds = new HashSet(); CachingMultiIndexReader reader = index.getIndexReader(); try { for (int i = 0; i < reader.maxDoc(); i++) { @@ -162,13 +161,13 @@ continue; } Document d = reader.document(i, FieldSelectors.UUID); - UUID uuid = UUID.fromString(d.get(FieldNames.UUID)); - if (stateMgr.hasItemState(new NodeId(uuid))) { - if (!documentUUIDs.add(uuid)) { - multipleEntries.add(uuid); + NodeId id = new NodeId(d.get(FieldNames.UUID)); + if (stateMgr.hasItemState(id)) { + if (!documentIds.add(id)) { + multipleEntries.add(id); } } else { - errors.add(new NodeDeleted(uuid)); + errors.add(new NodeDeleted(id)); } } } finally { @@ -176,8 +175,8 @@ } // create multiple entries errors - for (UUID uuid : multipleEntries) { - errors.add(new MultipleEntries(uuid)); + for (NodeId id : multipleEntries) { + errors.add(new MultipleEntries(id)); } reader = index.getIndexReader(); @@ -192,21 +191,20 @@ continue; } Document d = reader.document(i, FieldSelectors.UUID_AND_PARENT); - UUID uuid = UUID.fromString(d.get(FieldNames.UUID)); + NodeId id = new NodeId(d.get(FieldNames.UUID)); String parentUUIDString = d.get(FieldNames.PARENT); - UUID parentUUID = null; + NodeId parentId = null; if (parentUUIDString.length() > 0) { - parentUUID = UUID.fromString(parentUUIDString); + parentId = new NodeId(parentUUIDString); } - if (parentUUID == null || documentUUIDs.contains(parentUUID)) { + if (parentId == null || documentIds.contains(parentId)) { continue; } // parent is missing - NodeId parentId = new NodeId(parentUUID); if (stateMgr.hasItemState(parentId)) { - errors.add(new MissingAncestor(uuid, parentUUID)); + errors.add(new MissingAncestor(id, parentId)); } else { - errors.add(new UnknownParent(uuid, parentUUID)); + errors.add(new UnknownParent(id, parentId)); } } } finally { @@ -257,11 +255,11 @@ */ private class MissingAncestor extends ConsistencyCheckError { - private final UUID parentUUID; + private final NodeId parentId; - private MissingAncestor(UUID uuid, UUID parentUUID) { - super("Parent of " + uuid + " missing in index. Parent: " + parentUUID, uuid); - this.parentUUID = parentUUID; + private MissingAncestor(NodeId id, NodeId parentId) { + super("Parent of " + id + " missing in index. Parent: " + parentId, id); + this.parentId = parentId; } /** @@ -277,15 +275,15 @@ * @throws IOException if an error occurs while repairing. */ public void repair() throws IOException { - NodeId parentId = new NodeId(parentUUID); - while (parentId != null && !documentUUIDs.contains(parentId.getUUID())) { + NodeId ancestorId = parentId; + while (ancestorId != null && !documentIds.contains(ancestorId)) { try { - NodeState n = (NodeState) stateMgr.getItemState(parentId); + NodeState n = (NodeState) stateMgr.getItemState(ancestorId); log.info("Reparing missing node " + getPath(n)); Document d = index.createDocument(n); index.addDocument(d); - documentUUIDs.add(n.getNodeId().getUUID()); - parentId = n.getParentId(); + documentIds.add(n.getNodeId()); + ancestorId = n.getParentId(); } catch (ItemStateException e) { throw new IOException(e.toString()); } catch (RepositoryException e) { @@ -300,8 +298,8 @@ */ private class UnknownParent extends ConsistencyCheckError { - private UnknownParent(UUID uuid, UUID parentUUID) { - super("Node " + uuid + " has unknown parent: " + parentUUID, uuid); + private UnknownParent(NodeId id, NodeId parentId) { + super("Node " + id + " has unknown parent: " + parentId, id); } /** @@ -316,7 +314,7 @@ * No operation. */ public void repair() throws IOException { - log.warn("Unknown parent for " + uuid + " cannot be repaired"); + log.warn("Unknown parent for " + id + " cannot be repaired"); } } @@ -325,8 +323,8 @@ */ private class MultipleEntries extends ConsistencyCheckError { - MultipleEntries(UUID uuid) { - super("Multiple entries found for node " + uuid, uuid); + MultipleEntries(NodeId id) { + super("Multiple entries found for node " + id, id); } /** @@ -344,14 +342,14 @@ */ public void repair() throws IOException { // first remove all occurrences - index.removeAllDocuments(uuid); + index.removeAllDocuments(id); // then re-index the node try { - NodeState node = (NodeState) stateMgr.getItemState(new NodeId(uuid)); + NodeState node = (NodeState) stateMgr.getItemState(id); log.info("Re-indexing duplicate node occurrences in index: " + getPath(node)); Document d = index.createDocument(node); index.addDocument(d); - documentUUIDs.add(node.getNodeId().getUUID()); + documentIds.add(node.getNodeId()); } catch (ItemStateException e) { throw new IOException(e.toString()); } catch (RepositoryException e) { @@ -365,8 +363,8 @@ */ private class NodeDeleted extends ConsistencyCheckError { - NodeDeleted(UUID uuid) { - super("Node " + uuid + " does not longer exist.", uuid); + NodeDeleted(NodeId id) { + super("Node " + id + " does not longer exist.", id); } /** @@ -382,8 +380,8 @@ * @throws IOException if an error occurs while repairing. */ public void repair() throws IOException { - log.info("Removing deleted node from index: " + uuid); - index.removeDocument(uuid); + log.info("Removing deleted node from index: " + id); + index.removeDocument(id); } } } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ConsistencyCheckError.java Fri Jul 10 16:24:02 2009 @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.core.query.lucene; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import java.io.IOException; @@ -31,13 +31,13 @@ protected final String message; /** - * The UUID of the affected node. + * The id of the affected node. */ - protected final UUID uuid; + protected final NodeId id; - ConsistencyCheckError(String message, UUID uuid) { + ConsistencyCheckError(String message, NodeId id) { this.message = message; - this.uuid = uuid; + this.id = id; } /** Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/DocId.java Fri Jul 10 16:24:02 2009 @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.core.query.lucene; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import java.io.IOException; import java.util.BitSet; @@ -114,24 +114,24 @@ } /** - * Creates a DocId based on a node UUID. + * Creates a DocId based on a UUID. * - * @param uuid the node uuid. - * @return a DocId based on a node UUID. + * @param uuid the UUID + * @return a DocId based on the UUID. * @throws IllegalArgumentException if the uuid is malformed. */ static DocId create(String uuid) { - return create(UUID.fromString(uuid)); + return create(new NodeId(uuid)); } /** - * Creates a DocId based on a node UUID. + * Creates a DocId based on a node id. * - * @param uuid the node uuid. - * @return a DocId based on a node UUID. + * @param id the node id + * @return a DocId based on the node id */ - static DocId create(UUID uuid) { - return new UUIDDocId(uuid); + static DocId create(NodeId id) { + return new UUIDDocId(id); } /** @@ -202,19 +202,14 @@ } /** - * DocId based on a UUID. + * DocId based on a node id. */ private static final class UUIDDocId extends DocId { /** - * The least significant 64 bits of the uuid (bytes 8-15) + * The node identifier. */ - private final long lsb; - - /** - * The most significant 64 bits of the uuid (bytes 0-7) - */ - private final long msb; + private final NodeId id; /** * The previously calculated foreign segment document id. @@ -222,13 +217,12 @@ private ForeignSegmentDocId doc; /** - * Creates a DocId based on a Node uuid. + * Creates a DocId based on a node id. * - * @param uuid the Node uuid. + * @param id the node id. */ - UUIDDocId(UUID uuid) { - this.lsb = uuid.getLeastSignificantBits(); - this.msb = uuid.getMostSignificantBits(); + UUIDDocId(NodeId id) { + this.id = id; } /** @@ -243,7 +237,7 @@ } if (realDoc == -1) { // Cached doc was invalid => create new one - segDocId = reader.createDocId(new UUID(msb, lsb)); + segDocId = reader.createDocId(id); if (segDocId != null) { realDoc = reader.getDocumentNumber(segDocId); doc = segDocId; @@ -284,7 +278,7 @@ * @return a String representation for this DocId. */ public String toString() { - return "UUIDDocId(" + new UUID(msb, lsb) + ")"; + return "UUIDDocId(" + id + ")"; } } @@ -305,7 +299,7 @@ MultiUUIDDocId(String[] uuids) { this.docIds = new UUIDDocId[uuids.length]; for (int i = 0; i < uuids.length; i++) { - docIds[i] = new UUIDDocId(UUID.fromString(uuids[i])); + docIds[i] = new UUIDDocId(new NodeId(uuids[i])); } } @@ -353,7 +347,7 @@ for (int i = 0; i < docIds.length; i++) { sb.append(separator); separator = ", "; - sb.append(new UUID(docIds[i].msb, docIds[i].lsb)); + sb.append(docIds[i].id); } sb.append(")"); return sb.toString(); Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexReader.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexReader.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexReader.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/JackrabbitIndexReader.java Fri Jul 10 16:24:02 2009 @@ -18,7 +18,7 @@ import org.apache.lucene.index.FilterIndexReader; import org.apache.lucene.index.IndexReader; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import java.io.IOException; @@ -98,8 +98,8 @@ /** * {@inheritDoc} */ - public ForeignSegmentDocId createDocId(UUID uuid) throws IOException { - return reader.createDocId(uuid); + public ForeignSegmentDocId createDocId(NodeId id) throws IOException { + return reader.createDocId(id); } /** Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java Fri Jul 10 16:24:02 2009 @@ -24,7 +24,6 @@ import org.apache.jackrabbit.core.state.NodeState; import org.apache.jackrabbit.core.state.ChildNodeEntry; import org.apache.jackrabbit.uuid.Constants; -import org.apache.jackrabbit.uuid.UUID; import org.apache.jackrabbit.util.Timer; import org.apache.jackrabbit.spi.Path; import org.apache.jackrabbit.spi.PathFactory; @@ -393,7 +392,7 @@ * Atomically updates the index by removing some documents and adding * others. * - * @param remove collection of UUIDs that identify documents to + * @param remove collection of ids that identify documents to * remove * @param add collection of Documents to add. Some of the * elements in this collection may be null, to @@ -401,7 +400,7 @@ * @throws IOException if an error occurs while updating the index. */ synchronized void update( - Collection remove, Collection add) + Collection remove, Collection add) throws IOException { // make sure a reader is available during long updates if (add.size() > handler.getBufferSize()) { @@ -417,8 +416,8 @@ boolean flush = false; - for (UUID uuid : remove) { - executeAndLog(new DeleteNode(transactionId, uuid)); + for (NodeId id : remove) { + executeAndLog(new DeleteNode(transactionId, id)); } for (Document document : add) { @@ -451,39 +450,39 @@ * index. */ void addDocument(Document doc) throws IOException { - Collection empty = Collections.emptyList(); + Collection empty = Collections.emptyList(); update(empty, Collections.singleton(doc)); } /** - * Deletes the first document that matches the uuid. + * Deletes the first document that matches the id. * - * @param uuid document that match this uuid will be deleted. + * @param id document that match this id will be deleted. * @throws IOException if an error occurs while deleting the document. */ - void removeDocument(UUID uuid) throws IOException { + void removeDocument(NodeId id) throws IOException { Collection empty = Collections.emptyList(); - update(Collections.singleton(uuid), empty); + update(Collections.singleton(id), empty); } /** - * Deletes all documents that match the uuid. + * Deletes all documents that match the id. * - * @param uuid documents that match this uuid will be deleted. + * @param id documents that match this id will be deleted. * @return the number of deleted documents. * @throws IOException if an error occurs while deleting documents. */ - synchronized int removeAllDocuments(UUID uuid) throws IOException { + synchronized int removeAllDocuments(NodeId id) throws IOException { synchronized (updateMonitor) { updateInProgress = true; } int num; try { - Term idTerm = new Term(FieldNames.UUID, uuid.toString()); + Term idTerm = new Term(FieldNames.UUID, id.toString()); executeAndLog(new Start(Action.INTERNAL_TRANSACTION)); num = volatileIndex.removeDocument(idTerm); if (num > 0) { - redoLog.append(new DeleteNode(getTransactionId(), uuid)); + redoLog.append(new DeleteNode(getTransactionId(), id)); } for (int i = 0; i < indexes.size(); i++) { PersistentIndex index = (PersistentIndex) indexes.get(i); @@ -491,7 +490,7 @@ if (indexNames.contains(index.getName())) { int removed = index.removeDocument(idTerm); if (removed > 0) { - redoLog.append(new DeleteNode(getTransactionId(), uuid)); + redoLog.append(new DeleteNode(getTransactionId(), id)); } num += removed; } @@ -1068,7 +1067,7 @@ if (excludedIDs.contains(id)) { return count; } - executeAndLog(new AddNode(getTransactionId(), id.getUUID())); + executeAndLog(new AddNode(getTransactionId(), id)); if (++count % 100 == 0) { PathResolver resolver = new DefaultNamePathResolver( handler.getContext().getNamespaceRegistry()); @@ -1182,10 +1181,10 @@ * the indexing queue to the index. */ private void checkIndexingQueue(boolean transactionPresent) { - Map finished = new HashMap(); + Map finished = new HashMap(); for (Document document : indexingQueue.getFinishedDocuments()) { - UUID uuid = UUID.fromString(document.get(FieldNames.UUID)); - finished.put(uuid, document); + NodeId id = new NodeId(document.get(FieldNames.UUID)); + finished.put(id, document); } // now update index with the remaining ones if there are any @@ -1194,14 +1193,14 @@ new Long(finished.size())); // remove documents from the queue - for (UUID uuid : finished.keySet()) { - indexingQueue.removeDocument(uuid.toString()); + for (NodeId id : finished.keySet()) { + indexingQueue.removeDocument(id.toString()); } try { if (transactionPresent) { - for (UUID uuid : finished.keySet()) { - executeAndLog(new DeleteNode(getTransactionId(), uuid)); + for (NodeId id : finished.keySet()) { + executeAndLog(new DeleteNode(getTransactionId(), id)); } for (Document document : finished.values()) { executeAndLog(new AddNode(getTransactionId(), document)); @@ -1512,9 +1511,9 @@ + 2; /** - * The uuid of the node to add. + * The id of the node to add. */ - private final UUID uuid; + private final NodeId id; /** * The document to add to the index, or null if not available. @@ -1525,11 +1524,11 @@ * Creates a new AddNode action. * * @param transactionId the id of the transaction that executes this action. - * @param uuid the uuid of the node to add. + * @param id the id of the node to add. */ - AddNode(long transactionId, UUID uuid) { + AddNode(long transactionId, NodeId id) { super(transactionId, Action.TYPE_ADD_NODE); - this.uuid = uuid; + this.id = id; } /** @@ -1539,7 +1538,7 @@ * @param doc the document to add. */ AddNode(long transactionId, Document doc) { - this(transactionId, UUID.fromString(doc.get(FieldNames.UUID))); + this(transactionId, new NodeId(doc.get(FieldNames.UUID))); this.doc = doc; } @@ -1548,8 +1547,7 @@ * * @param transactionId the id of the transaction that executes this * action. - * @param arguments the arguments to this action. The uuid of the node - * to add + * @param arguments The UUID of the node to add * @return the AddNode action. * @throws IllegalArgumentException if the arguments are malformed. Not a * UUID. @@ -1560,7 +1558,7 @@ if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) { throw new IllegalArgumentException("arguments is not a uuid"); } - return new AddNode(transactionId, UUID.fromString(arguments)); + return new AddNode(transactionId, new NodeId(arguments)); } /** @@ -1571,7 +1569,7 @@ public void execute(MultiIndex index) throws IOException { if (doc == null) { try { - doc = index.createDocument(new NodeId(uuid)); + doc = index.createDocument(id); } catch (RepositoryException e) { // node does not exist anymore log.debug(e.getMessage()); @@ -1591,7 +1589,7 @@ logLine.append(' '); logLine.append(Action.ADD_NODE); logLine.append(' '); - logLine.append(uuid); + logLine.append(id); return logLine.toString(); } } @@ -1801,19 +1799,19 @@ + 2; /** - * The uuid of the node to remove. + * The id of the node to remove. */ - private final UUID uuid; + private final NodeId id; /** * Creates a new DeleteNode action. * * @param transactionId the id of the transaction that executes this action. - * @param uuid the uuid of the node to delete. + * @param id the id of the node to delete. */ - DeleteNode(long transactionId, UUID uuid) { + DeleteNode(long transactionId, NodeId id) { super(transactionId, Action.TYPE_DELETE_NODE); - this.uuid = uuid; + this.id = id; } /** @@ -1821,7 +1819,7 @@ * * @param transactionId the id of the transaction that executes this * action. - * @param arguments the uuid of the node to delete. + * @param arguments the UUID of the node to delete. * @return the DeleteNode action. * @throws IllegalArgumentException if the arguments are malformed. Not a * UUID. @@ -1831,7 +1829,7 @@ if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) { throw new IllegalArgumentException("arguments is not a uuid"); } - return new DeleteNode(transactionId, UUID.fromString(arguments)); + return new DeleteNode(transactionId, new NodeId(arguments)); } /** @@ -1840,7 +1838,7 @@ * @inheritDoc */ public void execute(MultiIndex index) throws IOException { - String uuidString = uuid.toString(); + String uuidString = id.toString(); // check if indexing queue is still working on // this node from a previous update Document doc = index.indexingQueue.removeDocument(uuidString); @@ -1874,7 +1872,7 @@ logLine.append(' '); logLine.append(Action.DELETE_NODE); logLine.append(' '); - logLine.append(uuid); + logLine.append(id); return logLine.toString(); } } Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndexReader.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndexReader.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndexReader.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndexReader.java Fri Jul 10 16:24:02 2009 @@ -17,7 +17,7 @@ package org.apache.jackrabbit.core.query.lucene; import org.apache.lucene.index.IndexReader; -import org.apache.jackrabbit.uuid.UUID; +import org.apache.jackrabbit.core.id.NodeId; import java.io.IOException; @@ -34,14 +34,14 @@ IndexReader[] getIndexReaders(); /** - * Creates a document id for the given uuid. + * Creates a document id for the given node identifier. * - * @param uuid the uuid of the node. + * @param id the id of the node. * @return a foreign segment doc id or null if there is no node - * with the given uuid. + * with the given id. * @throws IOException if an error occurs while reading from the index. */ - ForeignSegmentDocId createDocId(UUID uuid) throws IOException; + ForeignSegmentDocId createDocId(NodeId id) throws IOException; /** * Returns the document number for the passed docId. If the id Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=793015&r1=793014&r2=793015&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original) +++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Fri Jul 10 16:24:02 2009 @@ -44,7 +44,6 @@ import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory; import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree; import org.apache.jackrabbit.spi.commons.query.qom.OrderingImpl; -import org.apache.jackrabbit.uuid.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.lucene.analysis.Analyzer; @@ -327,7 +326,7 @@ private boolean autoRepair = true; /** - * The uuid resolver cache size. + * The id resolver cache size. *

* Default value is: 1000. */ @@ -570,7 +569,7 @@ } /** - * Removes the node with uuid from the search index. + * Removes the node with id from the search index. * @param id the id of the node to remove from the index. * @throws IOException if an error occurs while removing the node from * the index. @@ -584,7 +583,7 @@ * {@link MultiIndex#update(Collection, Collection)} and * transforms the two iterators to the required types. * - * @param remove uuids of nodes to remove. + * @param remove ids of nodes to remove. * @param add NodeStates to add. Calls to next() on this * iterator may return null, to indicate that a * node could not be indexed successfully. @@ -595,24 +594,24 @@ throws RepositoryException, IOException { checkOpen(); - Map aggregateRoots = new HashMap(); - Set removedUUIDs = new HashSet(); - Set addedUUIDs = new HashSet(); + Map aggregateRoots = new HashMap(); + Set removedIds = new HashSet(); + Set addedIds = new HashSet(); - Collection removeCollection = new ArrayList(); + Collection removeCollection = new ArrayList(); while (remove.hasNext()) { - UUID uuid = remove.next().getUUID(); - removeCollection.add(uuid); - removedUUIDs.add(uuid); + NodeId id = remove.next(); + removeCollection.add(id); + removedIds.add(id); } Collection addCollection = new ArrayList(); while (add.hasNext()) { NodeState state = add.next(); if (state != null) { - UUID uuid = state.getNodeId().getUUID(); - addedUUIDs.add(uuid); - removedUUIDs.remove(uuid); + NodeId id = state.getNodeId(); + addedIds.add(id); + removedIds.remove(id); retrieveAggregateRoot(state, aggregateRoots); try { @@ -630,10 +629,10 @@ // remove any aggregateRoot nodes that are new // and therefore already up-to-date - aggregateRoots.keySet().removeAll(addedUUIDs); + aggregateRoots.keySet().removeAll(addedIds); - // based on removed UUIDs get affected aggregate root nodes - retrieveAggregateRoot(removedUUIDs, aggregateRoots); + // based on removed ids get affected aggregate root nodes + retrieveAggregateRoot(removedIds, aggregateRoots); // update aggregates if there are any affected if (!aggregateRoots.isEmpty()) { @@ -728,8 +727,7 @@ } for (Integer doc : docs) { Document d = reader.document(doc, FieldSelectors.UUID); - UUID uuid = UUID.fromString(d.get(FieldNames.UUID)); - ids.add(new NodeId(uuid)); + ids.add(new NodeId(d.get(FieldNames.UUID))); } } finally { Util.closeOrRelease(reader); @@ -1305,7 +1303,7 @@ for (Fieldable fulltextField : fulltextFields) { doc.add(fulltextField); } - doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, aggregate.getNodeId().getUUID().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); + doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, aggregate.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); } } } @@ -1333,7 +1331,7 @@ value = FieldNames.createNamedValue(path, value); t.setTermBuffer(value); doc.add(new Field(field.name(), new SingletonTokenStream(t))); - doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, parent.getNodeId().getUUID().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); + doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID, parent.getNodeId().toString(), Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); } } } @@ -1347,7 +1345,7 @@ } catch (Exception e) { // do not fail if aggregate cannot be created log.warn("Exception while building indexing aggregate for" - + " node with UUID: " + state.getNodeId().getUUID(), e); + + " node with id: " + state.getNodeId(), e); } } } @@ -1390,11 +1388,10 @@ * * @param state the node state for which we want to retrieve the aggregate * root. - * @param map aggregate roots are collected in this map. Key=UUID, - * value=NodeState. + * @param map aggregate roots are collected in this map. */ protected void retrieveAggregateRoot( - NodeState state, Map map) { + NodeState state, Map map) { if (indexingConfig != null) { AggregateRule[] aggregateRules = indexingConfig.getAggregateRules(); if (aggregateRules == null) { @@ -1404,25 +1401,25 @@ for (AggregateRule aggregateRule : aggregateRules) { NodeState root = aggregateRule.getAggregateRoot(state); if (root != null) { - map.put(root.getNodeId().getUUID(), root); + map.put(root.getNodeId(), root); } } } catch (Exception e) { log.warn("Unable to get aggregate root for " - + state.getNodeId().getUUID(), e); + + state.getNodeId(), e); } } } /** - * Retrieves the root of the indexing aggregate for removedUUIDs + * Retrieves the root of the indexing aggregate for removedIds * and puts it into map. * - * @param removedUUIDs the UUIDs of removed nodes. + * @param removedIds the ids of removed nodes. * @param map aggregate roots are collected in this map */ protected void retrieveAggregateRoot( - Set removedUUIDs, Map map) { + Set removedIds, Map map) { if (indexingConfig != null) { AggregateRule[] aggregateRules = indexingConfig.getAggregateRules(); if (aggregateRules == null) { @@ -1433,21 +1430,20 @@ try { CachingMultiIndexReader reader = index.getIndexReader(); try { - Term aggregateUUIDs = + Term aggregateIds = new Term(FieldNames.AGGREGATED_NODE_UUID, ""); TermDocs tDocs = reader.termDocs(); try { ItemStateManager ism = getContext().getItemStateManager(); - for (UUID uuid : removedUUIDs) { - aggregateUUIDs = - aggregateUUIDs.createTerm(uuid.toString()); - tDocs.seek(aggregateUUIDs); + for (NodeId id : removedIds) { + aggregateIds = + aggregateIds.createTerm(id.toString()); + tDocs.seek(aggregateIds); while (tDocs.next()) { Document doc = reader.document( tDocs.doc(), FieldSelectors.UUID); - NodeId nId = new NodeId( - UUID.fromString(doc.get(FieldNames.UUID))); - map.put(nId.getUUID(), (NodeState) ism.getItemState(nId)); + NodeId nId = new NodeId(doc.get(FieldNames.UUID)); + map.put(nId, (NodeState) ism.getItemState(nId)); found++; } } @@ -1577,9 +1573,9 @@ /** * {@inheritDoc} */ - public ForeignSegmentDocId createDocId(UUID uuid) throws IOException { + public ForeignSegmentDocId createDocId(NodeId id) throws IOException { for (CachingMultiIndexReader subReader : subReaders) { - ForeignSegmentDocId doc = subReader.createDocId(uuid); + ForeignSegmentDocId doc = subReader.createDocId(id); if (doc != null) { return doc; }