test_class.declarator: dic = new TagDictionary(4)
test_class.original_string: TagDictionary dic = new TagDictionary(4);
test_class.type: TagDictionary
test_class.var_name: dic
test_class.declarator: encoder = new TestEncoder()
test_class.original_string: TestEncoder encoder = new TestEncoder();
test_class.type: TestEncoder
test_class.var_name: encoder
test_class.file: sjk-stacktrace/src/test/java/org/gridkit/jvmtool/stacktrace/TagDictionaryTest.java
test_class.identifier: TagDictionaryTest
test_case.body: @Test
      public void tag_eviction() {
          int id1 = dic.intern(tags("A", "1"), encoder);
          int id2 = dic.intern(tags("A", "2"), encoder);
          int id3 = dic.intern(tags("B", "1", "A", "1", "A", "2"), encoder);
          int id11 = dic.intern(tags("A", "1"), encoder);
          int id4 = dic.intern(tags("B", "1", "A", "2", "C", "1"), encoder);
          int id5 = dic.intern(tags("C", "1", "B", "1"), encoder);
  
          assertThat(id1).isEqualTo(1);
          assertThat(id2).isEqualTo(2);
          assertThat(id3).isEqualTo(3);
          assertThat(id11).isEqualTo(1);
          assertThat(id4).isEqualTo(2); // id reused
          assertThat(id5).isEqualTo(1); // id reused, 3 was used as base so it survives
          assertThat(encoder.toString()).isEqualTo(
                  "[1,0] +A:1! [2,0] +A:2! [3,1] +A:2 +B:1! [2,3] -A:1 +C:1! [1,2] -A!");
      }
test_case.class_method_signature: TagDictionaryTest.tag_eviction()
test_case.full_signature: @Test public void tag_eviction()
test_case.identifier: tag_eviction
test_case.invocations: intern tags intern tags intern tags intern tags intern tags intern tags isEqualTo assertThat isEqualTo assertThat isEqualTo assertThat isEqualTo assertThat isEqualTo assertThat isEqualTo assertThat isEqualTo assertThat toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void tag_eviction()
focal_class.declarator: EMPTY = new TagSet(new SimpleTagCollection())
focal_class.modifier: private static final
focal_class.original_string: private static final TagSet EMPTY = new TagSet(new SimpleTagCollection());
focal_class.type: TagSet
focal_class.var_name: EMPTY
focal_class.declarator: tagSetDic = new LinkedHashMap<TagSet, Integer>()
focal_class.modifier: private
focal_class.original_string: private Map<TagSet, Integer> tagSetDic = new LinkedHashMap<TagSet, Integer>();
focal_class.type: Map<TagSet, Integer>
focal_class.var_name: tagSetDic
focal_class.declarator: limit
focal_class.modifier: private
focal_class.original_string: private int limit;
focal_class.type: int
focal_class.var_name: limit
focal_class.file: sjk-stacktrace/src/main/java/org/gridkit/jvmtool/stacktrace/TagDictionary.java
focal_class.identifier: TagDictionary
focal_class.class_method_signature: TagDictionary.TagDictionary(int limit)
focal_class.full_signature: public  TagDictionary(int limit)
focal_class.identifier: TagDictionary
focal_class.modifiers: public
focal_class.parameters: (int limit)
focal_class.signature:  TagDictionary(int limit)
focal_class.class_method_signature: TagDictionary.intern(TagCollection tags, TagSetEncoder encoder)
focal_class.full_signature: public int intern(TagCollection tags, TagSetEncoder encoder)
focal_class.identifier: intern
focal_class.modifiers: public
focal_class.parameters: (TagCollection tags, TagSetEncoder encoder)
focal_class.return: int
focal_class.signature: int intern(TagCollection tags, TagSetEncoder encoder)
focal_class.class_method_signature: TagDictionary.evict()
focal_class.full_signature: protected int evict()
focal_class.identifier: evict
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int evict()
focal_class.class_method_signature: TagDictionary.encodeTag(int id, TagSet ts, TagSetEncoder encoder)
focal_class.full_signature: private void encodeTag(int id, TagSet ts, TagSetEncoder encoder)
focal_class.identifier: encodeTag
focal_class.modifiers: private
focal_class.parameters: (int id, TagSet ts, TagSetEncoder encoder)
focal_class.return: void
focal_class.signature: void encodeTag(int id, TagSet ts, TagSetEncoder encoder)
focal_class.class_method_signature: TagDictionary.touch(TagSet baseSet, int baseRef)
focal_class.full_signature: private void touch(TagSet baseSet, int baseRef)
focal_class.identifier: touch
focal_class.modifiers: private
focal_class.parameters: (TagSet baseSet, int baseRef)
focal_class.return: void
focal_class.signature: void touch(TagSet baseSet, int baseRef)
focal_class.class_method_signature: TagDictionary.distance(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.full_signature: private int distance(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.identifier: distance
focal_class.modifiers: private
focal_class.parameters: (TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.return: int
focal_class.signature: int distance(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.class_method_signature: TagDictionary.encode(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.full_signature: private void encode(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.identifier: encode
focal_class.modifiers: private
focal_class.parameters: (TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.return: void
focal_class.signature: void encode(TagSet base, TagSet set, TagSetEncoder encoder)
focal_class.class_method_signature: TagDictionary.encodeRemoveTag(TagSet base, TagSetEncoder encoder, int nb)
focal_class.full_signature: protected void encodeRemoveTag(TagSet base, TagSetEncoder encoder, int nb)
focal_class.identifier: encodeRemoveTag
focal_class.modifiers: protected
focal_class.parameters: (TagSet base, TagSetEncoder encoder, int nb)
focal_class.return: void
focal_class.signature: void encodeRemoveTag(TagSet base, TagSetEncoder encoder, int nb)
focal_method.body: public int intern(TagCollection tags, TagSetEncoder encoder) {
          TagSet ts = new TagSet(tags);
          Integer id = tagSetDic.remove(ts);
          if (id != null) {
              tagSetDic.put(ts, id); // TODO garbage hotspot
              return id;
          }
          else if (tagSetDic.size() < limit) {
              id = tagSetDic.size();
              encodeTag(id, ts, encoder);
              return id;
          }
          else {
              id = evict();
              encodeTag(id, ts, encoder);
              return id;
          }
      }
focal_method.class_method_signature: TagDictionary.intern(TagCollection tags, TagSetEncoder encoder)
focal_method.full_signature: public int intern(TagCollection tags, TagSetEncoder encoder)
focal_method.identifier: intern
focal_method.invocations: remove put size size encodeTag evict encodeTag
focal_method.modifiers: public
focal_method.parameters: (TagCollection tags, TagSetEncoder encoder)
focal_method.return: int
focal_method.signature: int intern(TagCollection tags, TagSetEncoder encoder)