test_class.file: oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentIdTableTest.java
test_class.identifier: SegmentIdTableTest
test_case.body: @Test
      public void endlessSearchLoop() throws IOException {
          final SegmentIdFactory maker = newSegmentIdMaker();
          final SegmentIdTable tbl = new SegmentIdTable();
  
          List<SegmentId> refs = new ArrayList<SegmentId>();
          for (int i = 0; i < 1024; i++) {
              refs.add(tbl.newSegmentId(i, i % 64, maker));
          }
  
          Callable<SegmentId> c = new Callable<SegmentId>() {
  
              @Override
              public SegmentId call() throws Exception {
                  // (2,1) doesn't exist
                  return tbl.newSegmentId(2, 1, maker);
              }
          };
          Future<SegmentId> f = Executors.newSingleThreadExecutor().submit(c);
          SegmentId s = null;
          try {
              s = f.get(5, TimeUnit.SECONDS);
          } catch (Exception e) {
              fail(e.getMessage());
          }
          assertNotNull(s);
          assertEquals(2, s.getMostSignificantBits());
          assertEquals(1, s.getLeastSignificantBits());
      }
test_case.class_method_signature: SegmentIdTableTest.endlessSearchLoop()
test_case.full_signature: @Test public void endlessSearchLoop()
test_case.identifier: endlessSearchLoop
test_case.invocations: newSegmentIdMaker add newSegmentId newSegmentId submit newSingleThreadExecutor get fail getMessage assertNotNull assertEquals getMostSignificantBits assertEquals getLeastSignificantBits
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void endlessSearchLoop()
focal_class.declarator: references =
              newArrayList(nCopies(1024, (WeakReference<SegmentId>) null))
focal_class.modifier: private final
focal_class.original_string: private final ArrayList<WeakReference<SegmentId>> references =
              newArrayList(nCopies(1024, (WeakReference<SegmentId>) null));
focal_class.type: ArrayList<WeakReference<SegmentId>>
focal_class.var_name: references
focal_class.declarator: LOG = LoggerFactory.getLogger(SegmentIdTable.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(SegmentIdTable.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: rebuildCount
focal_class.modifier: private
focal_class.original_string: private int rebuildCount;
focal_class.type: int
focal_class.var_name: rebuildCount
focal_class.declarator: entryCount
focal_class.modifier: private
focal_class.original_string: private int entryCount;
focal_class.type: int
focal_class.var_name: entryCount
focal_class.file: oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentIdTable.java
focal_class.identifier: SegmentIdTable
focal_class.class_method_signature: SegmentIdTable.newSegmentId(long msb, long lsb, SegmentIdFactory maker)
focal_class.full_signature: @NotNull synchronized SegmentId newSegmentId(long msb, long lsb, SegmentIdFactory maker)
focal_class.identifier: newSegmentId
focal_class.modifiers: @NotNull synchronized
focal_class.parameters: (long msb, long lsb, SegmentIdFactory maker)
focal_class.return: SegmentId
focal_class.signature: SegmentId newSegmentId(long msb, long lsb, SegmentIdFactory maker)
focal_class.class_method_signature: SegmentIdTable.collectReferencedIds(Collection<SegmentId> ids)
focal_class.full_signature:  void collectReferencedIds(Collection<SegmentId> ids)
focal_class.identifier: collectReferencedIds
focal_class.parameters: (Collection<SegmentId> ids)
focal_class.return: void
focal_class.signature: void collectReferencedIds(Collection<SegmentId> ids)
focal_class.class_method_signature: SegmentIdTable.refresh()
focal_class.full_signature: private synchronized Collection<SegmentId> refresh()
focal_class.identifier: refresh
focal_class.modifiers: private synchronized
focal_class.parameters: ()
focal_class.return: Collection<SegmentId>
focal_class.signature: Collection<SegmentId> refresh()
focal_class.class_method_signature: SegmentIdTable.getIndex(SegmentId id)
focal_class.full_signature: private int getIndex(SegmentId id)
focal_class.identifier: getIndex
focal_class.modifiers: private
focal_class.parameters: (SegmentId id)
focal_class.return: int
focal_class.signature: int getIndex(SegmentId id)
focal_class.class_method_signature: SegmentIdTable.getIndex(long lsb)
focal_class.full_signature: private int getIndex(long lsb)
focal_class.identifier: getIndex
focal_class.modifiers: private
focal_class.parameters: (long lsb)
focal_class.return: int
focal_class.signature: int getIndex(long lsb)
focal_class.class_method_signature: SegmentIdTable.clearSegmentIdTables(@NotNull Set<UUID> reclaimed, @NotNull String gcInfo)
focal_class.full_signature: synchronized void clearSegmentIdTables(@NotNull Set<UUID> reclaimed, @NotNull String gcInfo)
focal_class.identifier: clearSegmentIdTables
focal_class.modifiers: synchronized
focal_class.parameters: (@NotNull Set<UUID> reclaimed, @NotNull String gcInfo)
focal_class.return: void
focal_class.signature: void clearSegmentIdTables(@NotNull Set<UUID> reclaimed, @NotNull String gcInfo)
focal_class.class_method_signature: SegmentIdTable.getMapRebuildCount()
focal_class.full_signature:  int getMapRebuildCount()
focal_class.identifier: getMapRebuildCount
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMapRebuildCount()
focal_class.class_method_signature: SegmentIdTable.getEntryCount()
focal_class.full_signature:  int getEntryCount()
focal_class.identifier: getEntryCount
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getEntryCount()
focal_class.class_method_signature: SegmentIdTable.getMapSize()
focal_class.full_signature:  int getMapSize()
focal_class.identifier: getMapSize
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMapSize()
focal_class.class_method_signature: SegmentIdTable.getRawSegmentIdList()
focal_class.full_signature:  List<SegmentId> getRawSegmentIdList()
focal_class.identifier: getRawSegmentIdList
focal_class.parameters: ()
focal_class.return: List<SegmentId>
focal_class.signature: List<SegmentId> getRawSegmentIdList()
focal_method.body: @NotNull
      synchronized SegmentId newSegmentId(long msb, long lsb, SegmentIdFactory maker) {
          int index = getIndex(lsb);
          boolean shouldRefresh = false;
  
          WeakReference<SegmentId> reference = references.get(index);
          while (reference != null) {
              SegmentId id = reference.get();
              if (id != null
                      && id.getMostSignificantBits() == msb
                      && id.getLeastSignificantBits() == lsb) {
                  return id;
              }
              // shouldRefresh if we have a garbage collected entry
              shouldRefresh = shouldRefresh || id == null;
              // open addressing / linear probing
              index = (index + 1) % references.size();
              reference = references.get(index);
          }
  
          SegmentId id = maker.newSegmentId(msb, lsb);
          references.set(index, new WeakReference<SegmentId>(id));
          entryCount++;
          if (entryCount > references.size() * 0.75) {
              // more than 75% full            
              shouldRefresh = true;
          }
          if (shouldRefresh) {
              refresh();
          }
          return id;
      }
focal_method.class_method_signature: SegmentIdTable.newSegmentId(long msb, long lsb, SegmentIdFactory maker)
focal_method.full_signature: @NotNull synchronized SegmentId newSegmentId(long msb, long lsb, SegmentIdFactory maker)
focal_method.identifier: newSegmentId
focal_method.invocations: getIndex get get getMostSignificantBits getLeastSignificantBits size get newSegmentId set size refresh
focal_method.modifiers: @NotNull synchronized
focal_method.parameters: (long msb, long lsb, SegmentIdFactory maker)
focal_method.return: SegmentId
focal_method.signature: SegmentId newSegmentId(long msb, long lsb, SegmentIdFactory maker)