test_class.declarator: empty = Collections.emptyList()
test_class.modifier: private final
test_class.original_string: private final List<String> empty = Collections.emptyList();
test_class.type: List<String>
test_class.var_name: empty
test_class.declarator: builderProvider = new DocumentMKBuilderProvider()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public DocumentMKBuilderProvider builderProvider = new DocumentMKBuilderProvider();
test_class.type: DocumentMKBuilderProvider
test_class.var_name: builderProvider
test_class.declarator: primary
test_class.modifier: private
test_class.original_string: private DocumentNodeStore primary;
test_class.type: DocumentNodeStore
test_class.var_name: primary
test_class.declarator: secondary
test_class.modifier: private
test_class.original_string: private NodeStore secondary;
test_class.type: NodeStore
test_class.var_name: secondary
test_class.file: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCacheTest.java
test_class.identifier: SecondaryStoreCacheTest
test_case.body: @Test
      public void binarySearch() throws Exception{
          SecondaryStoreCache cache = createCache(new PathFilter(of("/a"), empty));
  
          List<AbstractDocumentNodeState> roots = Lists.newArrayList();
          List<RevisionVector> revs = Lists.newArrayList();
          for (int i = 0; i < 50; i++) {
              NodeBuilder nb = primary.getRoot().builder();
              create(nb, "/a/b"+i);
              AbstractDocumentNodeState r = merge(nb);
              roots.add(r);
              revs.add(r.getRootRevision());
          }
  
          AbstractDocumentNodeState[] rootsArr = Iterables.toArray(roots, AbstractDocumentNodeState.class);
  
          Collections.shuffle(revs);
          for (RevisionVector rev : revs){
              AbstractDocumentNodeState result = SecondaryStoreCache.findMatchingRoot(rootsArr, rev);
              assertNotNull(result);
              assertEquals(rev, result.getRootRevision());
          }
  
          NodeBuilder nb = primary.getRoot().builder();
          create(nb, "/a/m");
          AbstractDocumentNodeState r = merge(nb);
          AbstractDocumentNodeState result = SecondaryStoreCache.findMatchingRoot(rootsArr, r.getRootRevision());
          assertNull(result);
  
      }
test_case.class_method_signature: SecondaryStoreCacheTest.binarySearch()
test_case.full_signature: @Test public void binarySearch()
test_case.identifier: binarySearch
test_case.invocations: createCache of newArrayList newArrayList builder getRoot create merge add add getRootRevision toArray shuffle findMatchingRoot assertNotNull assertEquals getRootRevision builder getRoot create merge findMatchingRoot getRootRevision assertNull
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void binarySearch()
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: EMPTY = new AbstractDocumentNodeState[0]
focal_class.modifier: private static final
focal_class.original_string: private static final AbstractDocumentNodeState[] EMPTY = new AbstractDocumentNodeState[0];
focal_class.type: AbstractDocumentNodeState[]
focal_class.var_name: EMPTY
focal_class.declarator: store
focal_class.modifier: private final
focal_class.original_string: private final NodeStore store;
focal_class.type: NodeStore
focal_class.var_name: store
focal_class.declarator: pathFilter
focal_class.modifier: private final
focal_class.original_string: private final PathFilter pathFilter;
focal_class.type: PathFilter
focal_class.var_name: pathFilter
focal_class.declarator: differ
focal_class.modifier: private final
focal_class.original_string: private final NodeStateDiffer differ;
focal_class.type: NodeStateDiffer
focal_class.var_name: differ
focal_class.declarator: unknownPaths
focal_class.modifier: private final
focal_class.original_string: private final MeterStats unknownPaths;
focal_class.type: MeterStats
focal_class.var_name: unknownPaths
focal_class.declarator: knownMissed
focal_class.modifier: private final
focal_class.original_string: private final MeterStats knownMissed;
focal_class.type: MeterStats
focal_class.var_name: knownMissed
focal_class.declarator: knownMissedOld
focal_class.modifier: private final
focal_class.original_string: private final MeterStats knownMissedOld;
focal_class.type: MeterStats
focal_class.var_name: knownMissedOld
focal_class.declarator: knownMissedNew
focal_class.modifier: private final
focal_class.original_string: private final MeterStats knownMissedNew;
focal_class.type: MeterStats
focal_class.var_name: knownMissedNew
focal_class.declarator: knownMissedInRange
focal_class.modifier: private final
focal_class.original_string: private final MeterStats knownMissedInRange;
focal_class.type: MeterStats
focal_class.var_name: knownMissedInRange
focal_class.declarator: headRevMatched
focal_class.modifier: private final
focal_class.original_string: private final MeterStats headRevMatched;
focal_class.type: MeterStats
focal_class.var_name: headRevMatched
focal_class.declarator: prevRevMatched
focal_class.modifier: private final
focal_class.original_string: private final MeterStats prevRevMatched;
focal_class.type: MeterStats
focal_class.var_name: prevRevMatched
focal_class.declarator: maxSize = 10000
focal_class.modifier: private final
focal_class.original_string: private final int maxSize = 10000;
focal_class.type: int
focal_class.var_name: maxSize
focal_class.declarator: queue
focal_class.modifier: private final
focal_class.original_string: private final EvictingQueue<AbstractDocumentNodeState> queue;
focal_class.type: EvictingQueue<AbstractDocumentNodeState>
focal_class.var_name: queue
focal_class.declarator: previousRoots = EMPTY
focal_class.modifier: private volatile
focal_class.original_string: private volatile AbstractDocumentNodeState[] previousRoots = EMPTY;
focal_class.type: AbstractDocumentNodeState[]
focal_class.var_name: previousRoots
focal_class.file: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/secondary/SecondaryStoreCache.java
focal_class.identifier: SecondaryStoreCache
focal_class.interfaces: implements DocumentNodeStateCache, SecondaryStoreRootObserver
focal_class.class_method_signature: SecondaryStoreCache.SecondaryStoreCache(NodeStore nodeStore, NodeStateDiffer differ, PathFilter pathFilter,
                                 StatisticsProvider statisticsProvider)
focal_class.full_signature: public  SecondaryStoreCache(NodeStore nodeStore, NodeStateDiffer differ, PathFilter pathFilter,
                                 StatisticsProvider statisticsProvider)
focal_class.identifier: SecondaryStoreCache
focal_class.modifiers: public
focal_class.parameters: (NodeStore nodeStore, NodeStateDiffer differ, PathFilter pathFilter,
                                 StatisticsProvider statisticsProvider)
focal_class.signature:  SecondaryStoreCache(NodeStore nodeStore, NodeStateDiffer differ, PathFilter pathFilter,
                                 StatisticsProvider statisticsProvider)
focal_class.class_method_signature: SecondaryStoreCache.getDocumentNodeState(Path path, RevisionVector rootRevision,
                                                            RevisionVector lastRev)
focal_class.full_signature: @Nullable @Override public AbstractDocumentNodeState getDocumentNodeState(Path path, RevisionVector rootRevision,
                                                            RevisionVector lastRev)
focal_class.identifier: getDocumentNodeState
focal_class.modifiers: @Nullable @Override public
focal_class.parameters: (Path path, RevisionVector rootRevision,
                                                            RevisionVector lastRev)
focal_class.return: AbstractDocumentNodeState
focal_class.signature: AbstractDocumentNodeState getDocumentNodeState(Path path, RevisionVector rootRevision,
                                                            RevisionVector lastRev)
focal_class.class_method_signature: SecondaryStoreCache.isCached(Path path)
focal_class.full_signature: @Override public boolean isCached(Path path)
focal_class.identifier: isCached
focal_class.modifiers: @Override public
focal_class.parameters: (Path path)
focal_class.return: boolean
focal_class.signature: boolean isCached(Path path)
focal_class.class_method_signature: SecondaryStoreCache.findByMatchingLastRev(AbstractDocumentNodeState root, Path path,
                                                        RevisionVector lastRev)
focal_class.full_signature: @Nullable private AbstractDocumentNodeState findByMatchingLastRev(AbstractDocumentNodeState root, Path path,
                                                        RevisionVector lastRev)
focal_class.identifier: findByMatchingLastRev
focal_class.modifiers: @Nullable private
focal_class.parameters: (AbstractDocumentNodeState root, Path path,
                                                        RevisionVector lastRev)
focal_class.return: AbstractDocumentNodeState
focal_class.signature: AbstractDocumentNodeState findByMatchingLastRev(AbstractDocumentNodeState root, Path path,
                                                        RevisionVector lastRev)
focal_class.class_method_signature: SecondaryStoreCache.findMatchingRoot(RevisionVector rr)
focal_class.full_signature: @Nullable private AbstractDocumentNodeState findMatchingRoot(RevisionVector rr)
focal_class.identifier: findMatchingRoot
focal_class.modifiers: @Nullable private
focal_class.parameters: (RevisionVector rr)
focal_class.return: AbstractDocumentNodeState
focal_class.signature: AbstractDocumentNodeState findMatchingRoot(RevisionVector rr)
focal_class.class_method_signature: SecondaryStoreCache.contentChanged(@NotNull AbstractDocumentNodeState root)
focal_class.full_signature: @Override public void contentChanged(@NotNull AbstractDocumentNodeState root)
focal_class.identifier: contentChanged
focal_class.modifiers: @Override public
focal_class.parameters: (@NotNull AbstractDocumentNodeState root)
focal_class.return: void
focal_class.signature: void contentChanged(@NotNull AbstractDocumentNodeState root)
focal_class.class_method_signature: SecondaryStoreCache.isEmpty()
focal_class.full_signature: private boolean isEmpty()
focal_class.identifier: isEmpty
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isEmpty()
focal_class.class_method_signature: SecondaryStoreCache.findMatchingRoot(AbstractDocumentNodeState[] roots, RevisionVector key)
focal_class.full_signature: static AbstractDocumentNodeState findMatchingRoot(AbstractDocumentNodeState[] roots, RevisionVector key)
focal_class.identifier: findMatchingRoot
focal_class.modifiers: static
focal_class.parameters: (AbstractDocumentNodeState[] roots, RevisionVector key)
focal_class.return: AbstractDocumentNodeState
focal_class.signature: AbstractDocumentNodeState findMatchingRoot(AbstractDocumentNodeState[] roots, RevisionVector key)
focal_class.class_method_signature: SecondaryStoreCache.asDocState(NodeState state)
focal_class.full_signature: private static AbstractDocumentNodeState asDocState(NodeState state)
focal_class.identifier: asDocState
focal_class.modifiers: private static
focal_class.parameters: (NodeState state)
focal_class.return: AbstractDocumentNodeState
focal_class.signature: AbstractDocumentNodeState asDocState(NodeState state)
focal_method.body: @Nullable
      private AbstractDocumentNodeState findMatchingRoot(RevisionVector rr) {
          if (isEmpty()){
              return null;
          }
  
          //Use a local variable as the array can get changed in process
          AbstractDocumentNodeState[] roots = previousRoots;
          AbstractDocumentNodeState latest = roots[roots.length - 1];
          AbstractDocumentNodeState oldest = roots[0];
  
          if (rr.compareTo(latest.getRootRevision()) > 0){
              knownMissedNew.mark();
              return null;
          }
  
          if (rr.compareTo(oldest.getRootRevision()) < 0){
              knownMissedOld.mark();
              return null;
          }
  
          AbstractDocumentNodeState result = findMatchingRoot(roots, rr);
          if (result != null){
              return result;
          }
          knownMissedInRange.mark();
          return null;
      }
focal_method.class_method_signature: SecondaryStoreCache.findMatchingRoot(RevisionVector rr)
focal_method.full_signature: @Nullable private AbstractDocumentNodeState findMatchingRoot(RevisionVector rr)
focal_method.identifier: findMatchingRoot
focal_method.invocations: isEmpty compareTo getRootRevision mark compareTo getRootRevision mark findMatchingRoot mark
focal_method.modifiers: @Nullable private
focal_method.parameters: (RevisionVector rr)
focal_method.return: AbstractDocumentNodeState
focal_method.signature: AbstractDocumentNodeState findMatchingRoot(RevisionVector rr)