Author: nzamosenchuk
Date: 2012-03-29 10:54:01 -0400 (Thu, 29 Mar 2012)
New Revision: 5985
Modified:
jcr/branches/1.14.x/patch/1.14.8-GA/JCR-1727/JCR-1727.patch
Log:
JCR-1727 : using Set instead of BitSet
Modified: jcr/branches/1.14.x/patch/1.14.8-GA/JCR-1727/JCR-1727.patch
===================================================================
--- jcr/branches/1.14.x/patch/1.14.8-GA/JCR-1727/JCR-1727.patch 2012-03-29 11:45:19 UTC
(rev 5984)
+++ jcr/branches/1.14.x/patch/1.14.8-GA/JCR-1727/JCR-1727.patch 2012-03-29 14:54:01 UTC
(rev 5985)
@@ -159,21 +159,26 @@
===================================================================
---
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CommittableIndexReader.java (revision
5969)
+++
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CommittableIndexReader.java (working
copy)
-@@ -17,10 +17,13 @@
+@@ -16,12 +16,16 @@
+ */
package org.exoplatform.services.jcr.impl.core.query.lucene;
- import java.io.IOException;
-+import java.util.BitSet;
-
+-import java.io.IOException;
+-
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.FilterIndexReader;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.StaleReaderException;
+import org.apache.lucene.store.LockObtainFailedException;
++import java.io.IOException;
++import java.util.Set;
++import java.util.concurrent.CopyOnWriteArraySet;
++
/**
* Wraps an <code>IndexReader</code> and allows to commit changes without
-@@ -36,13 +39,26 @@
+ * closing the reader.
+@@ -36,13 +40,28 @@
private volatile long modCount;
/**
@@ -181,9 +186,9 @@
+ * deleted documents are stored in the memory buffer and not applied to underlying
+ * index reader.
+ */
-+ private boolean transientDeletions;
++ private final boolean transientDeletions;
+
-+ private BitSet deleted;
++ private final Set<Integer> deletedDocs;
+
+ /**
* Creates a new <code>CommittableIndexReader</code> based on
<code>in</code>.
@@ -198,73 +203,48 @@
super(in);
modCount = in.getVersion();
+ this.transientDeletions = transientDeletions;
++ // no need to initialize Set if transientDeletions = false
++ this.deletedDocs = transientDeletions? new CopyOnWriteArraySet() : null;
}
//------------------------< FilterIndexReader >-----------------------------
-@@ -57,6 +73,30 @@
+@@ -57,6 +76,36 @@
modCount++;
}
-+ /**
-+ * {@inheritDoc}
-+ */
-+ @Override
-+ public synchronized void deleteDocument(int docNum) throws StaleReaderException,
CorruptIndexException,
-+ LockObtainFailedException, IOException
-+ {
-+ // skip acquiring write lock
-+ if (transientDeletions)
-+ {
-+ if (deleted == null)
-+ {
-+ deleted = new BitSet(maxDoc());
-+ }
-+ deleted.set(docNum);
-+ modCount++; // doDelete won't be executed, so incrementing modCount
-+ }
-+ else
-+ {
-+ super.deleteDocument(docNum);
-+ }
++ /**
++ * {@inheritDoc}
++ */
++ @Override
++ public synchronized void deleteDocument(int docNum) throws StaleReaderException,
CorruptIndexException,
++ LockObtainFailedException, IOException {
++ // skip acquiring write lock
++ if (transientDeletions)
++ {
++ deletedDocs.add(docNum);
++ modCount++; // doDelete won't be executed, so incrementing modCount
++ }
++ else
++ {
++ super.deleteDocument(docNum);
++ }
++ }
++
++ @Override
++ public boolean isDeleted(int n) {
++ if (transientDeletions)
++ {
++ return deletedDocs.contains(n);
++ }
++ else
++ {
++ return super.isDeleted(n);
++ }
++ }
+
-+ }
-+
//------------------------< additional methods >----------------------------
/**
-@@ -65,4 +105,32 @@
- long getModificationCount() {
- return modCount;
- }
-+
-+ @Override
-+ public boolean isDeleted(int n)
-+ {
-+ if (transientDeletions)
-+ {
-+ if (deleted != null)
-+ {
-+ return deleted.get(n);
-+ }
-+ else
-+ {
-+ return false;
-+ }
-+ }
-+ else
-+ {
-+ return super.isDeleted(n);
-+ }
-+ }
-+
-+ /**
-+ * @return true if reader is readOnly and doesn't apply deletions
-+ */
-+ public boolean isReadOnly()
-+ {
-+ return transientDeletions;
-+ }
- }
Index:
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java
===================================================================
---
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java (revision
5969)
Show replies by date