Github user mikemccand commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/503#discussion_r235350971
--- Diff:
lucene/core/src/java/org/apache/lucene/index/FrozenBufferedUpdates.java ---
@@ -214,150 +216,174 @@ public FrozenBufferedUpdates(InfoStream infoStream,
BufferedUpdates updates, Seg
/** Translates a frozen packet of delete term/query, or doc values
* updates, into their actual docIDs in the index, and applies the
change. This is a heavy
- * operation and is done concurrently by incoming indexing threads. */
+ * operation and is done concurrently by incoming indexing threads.
+ * This method will return immediately without blocking if another
thread is currently
+ * applying the package. In order to ensure the packet has been
applied, {@link #forceApply(IndexWriter)}
+ * must be called.
+ * */
@SuppressWarnings("try")
- public synchronized void apply(IndexWriter writer) throws IOException {
- if (applied.getCount() == 0) {
- // already done
- return;
+ boolean tryApply(IndexWriter writer) throws IOException {
+ if (applyLock.tryLock()) {
+ try {
+ return forceApply(writer);
+ } finally {
+ applyLock.unlock();
+ }
}
+ return false;
+ }
- long startNS = System.nanoTime();
+ /** Translates a frozen packet of delete term/query, or doc values
+ * updates, into their actual docIDs in the index, and applies the
change. This is a heavy
+ * operation and is done concurrently by incoming indexing threads.
+ * */
+ boolean forceApply(IndexWriter writer) throws IOException {
--- End diff --
Can we make this `void`? It always just `return true` now right?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]