test_class.declarator: temporaryFolder = new TemporaryFolder(new File("target"))
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target"));
test_class.type: TemporaryFolder
test_class.var_name: temporaryFolder
test_class.declarator: root = INITIAL_CONTENT
test_class.modifier: private
test_class.original_string: private NodeState root = INITIAL_CONTENT;
test_class.type: NodeState
test_class.var_name: root
test_class.declarator: builder = root.builder()
test_class.modifier: private
test_class.original_string: private NodeBuilder builder = root.builder();
test_class.type: NodeBuilder
test_class.var_name: builder
test_class.declarator: asyncHook
test_class.modifier: private
test_class.original_string: private EditorHook asyncHook;
test_class.type: EditorHook
test_class.var_name: asyncHook
test_class.declarator: syncHook
test_class.modifier: private
test_class.original_string: private EditorHook syncHook;
test_class.type: EditorHook
test_class.var_name: syncHook
test_class.declarator: info
test_class.modifier: private
test_class.original_string: private CommitInfo info;
test_class.type: CommitInfo
test_class.var_name: info
test_class.declarator: tracker = new IndexTracker()
test_class.modifier: private
test_class.original_string: private IndexTracker tracker = new IndexTracker();
test_class.type: IndexTracker
test_class.var_name: tracker
test_class.declarator: indexFactory
test_class.modifier: private
test_class.original_string: private NRTIndexFactory indexFactory;
test_class.type: NRTIndexFactory
test_class.var_name: indexFactory
test_class.declarator: clock = new Clock.Virtual()
test_class.modifier: private
test_class.original_string: private Clock clock = new Clock.Virtual();
test_class.type: Clock
test_class.var_name: clock
test_class.declarator: refreshDelta = TimeUnit.SECONDS.toMillis(1)
test_class.modifier: private
test_class.original_string: private long refreshDelta = TimeUnit.SECONDS.toMillis(1);
test_class.type: long
test_class.var_name: refreshDelta
test_class.file: oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DocumentQueueTest.java
test_class.identifier: DocumentQueueTest
test_case.body: @Test
      public void updateDocument() throws Exception{
          IndexTracker tracker = createTracker();
          NodeState indexed = createAndPopulateAsyncIndex(FulltextIndexConstants.IndexingMode.NRT);
          tracker.update(indexed);
          DocumentQueue queue = new DocumentQueue(2, tracker, sameThreadExecutor());
  
          Document d1 = new Document();
          d1.add(newPathField("/a/b"));
          d1.add(new StringField("foo", "a", Field.Store.NO));
          queue.add(LuceneDoc.forUpdate("/oak:index/fooIndex", "/a/b", d1));
  
          List<NRTIndex> indexes = indexFactory.getIndexes("/oak:index/fooIndex");
          NRTIndex index = indexes.get(indexes.size() - 1);
          assertEquals(1, index.getPrimaryReaderForTest().numDocs());
      }
test_case.class_method_signature: DocumentQueueTest.updateDocument()
test_case.full_signature: @Test public void updateDocument()
test_case.identifier: updateDocument
test_case.invocations: createTracker createAndPopulateAsyncIndex update sameThreadExecutor add newPathField add add forUpdate getIndexes get size assertEquals numDocs getPrimaryReaderForTest
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void updateDocument()
focal_class.declarator: PERF_LOGGER =
              new PerfLogger(LoggerFactory.getLogger(DocumentQueue.class.getName() + ".perf"))
focal_class.modifier: private static final
focal_class.original_string: private static final PerfLogger PERF_LOGGER =
              new PerfLogger(LoggerFactory.getLogger(DocumentQueue.class.getName() + ".perf"));
focal_class.type: PerfLogger
focal_class.var_name: PERF_LOGGER
focal_class.declarator: STOP = LuceneDoc.forUpdate("", "", Collections.<IndexableField>emptyList())
focal_class.modifier: private static final
focal_class.original_string: private static final LuceneDoc STOP = LuceneDoc.forUpdate("", "", Collections.<IndexableField>emptyList());
focal_class.type: LuceneDoc
focal_class.var_name: STOP
focal_class.declarator: log = LoggerFactory.getLogger(getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(getClass());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: tracker
focal_class.modifier: private final
focal_class.original_string: private final IndexTracker tracker;
focal_class.type: IndexTracker
focal_class.var_name: tracker
focal_class.declarator: docsQueue
focal_class.modifier: private final
focal_class.original_string: private final BlockingQueue<LuceneDoc> docsQueue;
focal_class.type: BlockingQueue<LuceneDoc>
focal_class.var_name: docsQueue
focal_class.declarator: executor
focal_class.modifier: private final
focal_class.original_string: private final Executor executor;
focal_class.type: Executor
focal_class.var_name: executor
focal_class.declarator: queueSizeStats
focal_class.modifier: private final
focal_class.original_string: private final CounterStats queueSizeStats;
focal_class.type: CounterStats
focal_class.var_name: queueSizeStats
focal_class.declarator: added
focal_class.modifier: private final
focal_class.original_string: private final MeterStats added;
focal_class.type: MeterStats
focal_class.var_name: added
focal_class.declarator: dropped
focal_class.modifier: private final
focal_class.original_string: private final MeterStats dropped;
focal_class.type: MeterStats
focal_class.var_name: dropped
focal_class.declarator: locks = Striped.lock(64)
focal_class.modifier: private final
focal_class.original_string: private final Striped<Lock> locks = Striped.lock(64);
focal_class.type: Striped<Lock>
focal_class.var_name: locks
focal_class.declarator: delegate = (t, e) -> {}
focal_class.modifier: private
focal_class.original_string: private UncaughtExceptionHandler delegate = (t, e) -> {};
focal_class.type: UncaughtExceptionHandler
focal_class.var_name: delegate
focal_class.declarator: queueOfferTimeoutMillis
focal_class.modifier: private final
focal_class.original_string: private final long queueOfferTimeoutMillis;
focal_class.type: long
focal_class.var_name: queueOfferTimeoutMillis
focal_class.declarator: stopped
focal_class.modifier: private volatile
focal_class.original_string: private volatile boolean stopped;
focal_class.type: boolean
focal_class.var_name: stopped
focal_class.declarator: exceptionHandler = new UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(Thread t, Throwable e) {
              log.error("Uncaught exception", e);
          }
      }
focal_class.modifier: private final
focal_class.original_string: private final UncaughtExceptionHandler exceptionHandler = new UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(Thread t, Throwable e) {
              log.error("Uncaught exception", e);
          }
      };
focal_class.type: UncaughtExceptionHandler
focal_class.var_name: exceptionHandler
focal_class.declarator: currentTask = NotifyingFutureTask.completed()
focal_class.modifier: private volatile
focal_class.original_string: private volatile NotifyingFutureTask currentTask = NotifyingFutureTask.completed();
focal_class.type: NotifyingFutureTask
focal_class.var_name: currentTask
focal_class.declarator: completionHandler = new Runnable() {
          private final Callable<Void> task = new Callable<Void>() {
              @Override
              public Void call() throws Exception {
                  try {
                      long start = PERF_LOGGER.start();
                      int maxSize = docsQueue.size();
                      List<LuceneDoc> docs = Lists.newArrayListWithCapacity(maxSize);
                      ListMultimap<String, LuceneDoc> docsPerIndex = ArrayListMultimap.create();
  
                      //Do the processing in batches
                      int count = docsQueue.drainTo(docs, maxSize);
                      if (count == 0) {
                          return null;
                      }
  
                      queueSizeStats.dec(count);
  
                      for (int i = 0; i < count; i++) {
                          LuceneDoc doc = docs.get(i);
                          if (doc == STOP) {
                              return null;
                          }
                          docsPerIndex.get(doc.indexPath).add(doc);
                      }
  
                      addDocsToIndex(docsPerIndex.asMap(), true);
  
                      scheduleQueuedDocsProcessing();
                      PERF_LOGGER.end(start, 1, "Processed {} docs from queue", count);
                  } catch (Throwable t) {
                      exceptionHandler.uncaughtException(Thread.currentThread(), t);
                      delegate.uncaughtException(Thread.currentThread(), t);
                  }
                  return null;
              }
          };
  
          @Override
          public void run() {
              currentTask = new NotifyingFutureTask(task);
              executor.execute(currentTask);
          }
      }
focal_class.modifier: private final
focal_class.original_string: private final Runnable completionHandler = new Runnable() {
          private final Callable<Void> task = new Callable<Void>() {
              @Override
              public Void call() throws Exception {
                  try {
                      long start = PERF_LOGGER.start();
                      int maxSize = docsQueue.size();
                      List<LuceneDoc> docs = Lists.newArrayListWithCapacity(maxSize);
                      ListMultimap<String, LuceneDoc> docsPerIndex = ArrayListMultimap.create();
  
                      //Do the processing in batches
                      int count = docsQueue.drainTo(docs, maxSize);
                      if (count == 0) {
                          return null;
                      }
  
                      queueSizeStats.dec(count);
  
                      for (int i = 0; i < count; i++) {
                          LuceneDoc doc = docs.get(i);
                          if (doc == STOP) {
                              return null;
                          }
                          docsPerIndex.get(doc.indexPath).add(doc);
                      }
  
                      addDocsToIndex(docsPerIndex.asMap(), true);
  
                      scheduleQueuedDocsProcessing();
                      PERF_LOGGER.end(start, 1, "Processed {} docs from queue", count);
                  } catch (Throwable t) {
                      exceptionHandler.uncaughtException(Thread.currentThread(), t);
                      delegate.uncaughtException(Thread.currentThread(), t);
                  }
                  return null;
              }
          };
  
          @Override
          public void run() {
              currentTask = new NotifyingFutureTask(task);
              executor.execute(currentTask);
          }
      };
focal_class.type: Runnable
focal_class.var_name: completionHandler
focal_class.file: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DocumentQueue.java
focal_class.identifier: DocumentQueue
focal_class.interfaces: implements Closeable, IndexingQueue
focal_class.class_method_signature: DocumentQueue.DocumentQueue(int maxQueueSize, IndexTracker tracker, Executor executor)
focal_class.full_signature: public  DocumentQueue(int maxQueueSize, IndexTracker tracker, Executor executor)
focal_class.identifier: DocumentQueue
focal_class.modifiers: public
focal_class.parameters: (int maxQueueSize, IndexTracker tracker, Executor executor)
focal_class.signature:  DocumentQueue(int maxQueueSize, IndexTracker tracker, Executor executor)
focal_class.class_method_signature: DocumentQueue.DocumentQueue(int maxQueueSize, long queueOfferTimeoutMillis, IndexTracker tracker, Executor executor, StatisticsProvider sp)
focal_class.full_signature: public  DocumentQueue(int maxQueueSize, long queueOfferTimeoutMillis, IndexTracker tracker, Executor executor, StatisticsProvider sp)
focal_class.identifier: DocumentQueue
focal_class.modifiers: public
focal_class.parameters: (int maxQueueSize, long queueOfferTimeoutMillis, IndexTracker tracker, Executor executor, StatisticsProvider sp)
focal_class.signature:  DocumentQueue(int maxQueueSize, long queueOfferTimeoutMillis, IndexTracker tracker, Executor executor, StatisticsProvider sp)
focal_class.class_method_signature: DocumentQueue.addIfNotFullWithoutWait(LuceneDoc doc)
focal_class.full_signature: @Override public boolean addIfNotFullWithoutWait(LuceneDoc doc)
focal_class.identifier: addIfNotFullWithoutWait
focal_class.modifiers: @Override public
focal_class.parameters: (LuceneDoc doc)
focal_class.return: boolean
focal_class.signature: boolean addIfNotFullWithoutWait(LuceneDoc doc)
focal_class.class_method_signature: DocumentQueue.add(LuceneDoc doc)
focal_class.full_signature: @Override public boolean add(LuceneDoc doc)
focal_class.identifier: add
focal_class.modifiers: @Override public
focal_class.parameters: (LuceneDoc doc)
focal_class.return: boolean
focal_class.signature: boolean add(LuceneDoc doc)
focal_class.class_method_signature: DocumentQueue.scheduleQueuedDocsProcessing()
focal_class.full_signature: @Override public void scheduleQueuedDocsProcessing()
focal_class.identifier: scheduleQueuedDocsProcessing
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void scheduleQueuedDocsProcessing()
focal_class.class_method_signature: DocumentQueue.addAllSynchronously(Map<String, Collection<LuceneDoc>> docsPerIndex)
focal_class.full_signature: @Override public void addAllSynchronously(Map<String, Collection<LuceneDoc>> docsPerIndex)
focal_class.identifier: addAllSynchronously
focal_class.modifiers: @Override public
focal_class.parameters: (Map<String, Collection<LuceneDoc>> docsPerIndex)
focal_class.return: void
focal_class.signature: void addAllSynchronously(Map<String, Collection<LuceneDoc>> docsPerIndex)
focal_class.class_method_signature: DocumentQueue.setExceptionHandler(UncaughtExceptionHandler delegate)
focal_class.full_signature: public void setExceptionHandler(UncaughtExceptionHandler delegate)
focal_class.identifier: setExceptionHandler
focal_class.modifiers: public
focal_class.parameters: (UncaughtExceptionHandler delegate)
focal_class.return: void
focal_class.signature: void setExceptionHandler(UncaughtExceptionHandler delegate)
focal_class.class_method_signature: DocumentQueue.addDocsToIndex(Map<String, Collection<LuceneDoc>> docsPerIndex, boolean docsFromQueue)
focal_class.full_signature: private void addDocsToIndex(Map<String, Collection<LuceneDoc>> docsPerIndex, boolean docsFromQueue)
focal_class.identifier: addDocsToIndex
focal_class.modifiers: private
focal_class.parameters: (Map<String, Collection<LuceneDoc>> docsPerIndex, boolean docsFromQueue)
focal_class.return: void
focal_class.signature: void addDocsToIndex(Map<String, Collection<LuceneDoc>> docsPerIndex, boolean docsFromQueue)
focal_class.class_method_signature: DocumentQueue.getQueuedDocs()
focal_class.full_signature:  List<LuceneDoc> getQueuedDocs()
focal_class.identifier: getQueuedDocs
focal_class.parameters: ()
focal_class.return: List<LuceneDoc>
focal_class.signature: List<LuceneDoc> getQueuedDocs()
focal_class.class_method_signature: DocumentQueue.processDocs(String indexPath, Iterable<LuceneDoc> docs, boolean docsFromQueue)
focal_class.full_signature: private void processDocs(String indexPath, Iterable<LuceneDoc> docs, boolean docsFromQueue)
focal_class.identifier: processDocs
focal_class.modifiers: private
focal_class.parameters: (String indexPath, Iterable<LuceneDoc> docs, boolean docsFromQueue)
focal_class.return: void
focal_class.signature: void processDocs(String indexPath, Iterable<LuceneDoc> docs, boolean docsFromQueue)
focal_class.class_method_signature: DocumentQueue.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_method.body: @Override
      public boolean add(LuceneDoc doc){
          checkState(!stopped);
          boolean added = false;
          try {
              added = docsQueue.offer(doc, queueOfferTimeoutMillis, TimeUnit.MILLISECONDS);
          } catch (InterruptedException e) {
              Thread.currentThread().interrupt();
          }
          scheduleQueuedDocsProcessing();
  
          if (added) {
              queueSizeStats.inc();
              if (log.isTraceEnabled()){
                  log.trace("Adding {} to queue at size {}", doc, docsQueue.size());
              }
          } else {
              dropped.mark();
          }
          return added;
      }
focal_method.class_method_signature: DocumentQueue.add(LuceneDoc doc)
focal_method.full_signature: @Override public boolean add(LuceneDoc doc)
focal_method.identifier: add
focal_method.invocations: checkState offer interrupt currentThread scheduleQueuedDocsProcessing inc isTraceEnabled trace size mark
focal_method.modifiers: @Override public
focal_method.parameters: (LuceneDoc doc)
focal_method.return: boolean
focal_method.signature: boolean add(LuceneDoc doc)