Skip to content

Commit

Permalink
Loop in HashTrie
Browse files Browse the repository at this point in the history
```
/Users/jz/.jabba/jdk/[email protected]/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Users/jz/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.4865.12/IntelliJ IDEA 2020.1 EAP.app/Contents/lib/idea_rt.jar=58866:/Users/jz/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.4865.12/IntelliJ IDEA 2020.1 EAP.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/jz/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.4865.12/IntelliJ IDEA 2020.1 EAP.app/Contents/lib/idea_rt.jar:/Users/jz/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.4865.12/IntelliJ IDEA 2020.1 EAP.app/Contents/plugins/junit/lib/junit5-rt.jar:/Users/jz/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.4865.12/IntelliJ IDEA 2020.1 EAP.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/charsets.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/cldrdata.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/dnsns.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/jaccess.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/localedata.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/nashorn.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/sunec.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/ext/zipfs.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/jce.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/jsse.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/management-agent.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/resources.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/jre/lib/rt.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/lib/dt.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/lib/jconsole.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/lib/sa-jdi.jar:/Users/jz/.jabba/jdk/[email protected]/Contents/Home/lib/tools.jar:/Users/jz/code/scala/target/junit/test-classes:/Users/jz/code/scala/build/quick/classes/library:/Users/jz/code/scala/build/quick/classes/reflect:/Users/jz/code/scala/build/quick/classes/compiler:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/ant/ant/1.9.4/ant-1.9.4.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/jline/jline/2.14.6/jline-2.14.6.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.12/1.0.6/scala-xml_2.12-1.0.6.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.12/jansi-1.12.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/ant/ant-launcher/1.9.4/ant-launcher-1.9.4.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-asm/7.3.1-scala-1/scala-asm-7.3.1-scala-1.jar:/Users/jz/code/scala/build/quick/classes/repl:/Users/jz/code/scala/build/quick/classes/interactive:/Users/jz/code/scala/build/quick/classes/scaladoc:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/webjars/jquery/3.4.1/jquery-3.4.1.jar:/Users/jz/code/scala/build/quick/classes/partest-extras:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-partest_2.12/1.1.9/scala-partest_2.12-1.1.9.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/openjdk/jol/jol-core/0.9/jol-core-0.9.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar:/Users/jz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 scala.collection.immutable.HashSetTest,optimizedAppendAllWorks
.   HashTrieSet@1191747167
     HashTrieSet@2096057945
       LeafHashSet
       HashTrieSet@766572210
         HashTrieSet@1020391880
          !! LOOP DETECTED. 1020391880
           LeafHashSet
         HashTrieSet@429313384
           LeafHashSet
           HashTrieSet@5592464
             LeafHashSet
             LeafHashSet
           LeafHashSet
         HashTrieSet@380936215
           HashTrieSet@142638629
             LeafHashSet
             LeafHashSet
           LeafHashSet
           LeafHashSet
           LeafHashSet
         HashTrieSet@1555845260
           LeafHashSet
           HashTrieSet@104739310
             LeafHashSet
             LeafHashSet
           LeafHashSet
           LeafHashSet
         HashTrieSet@1749186397
           LeafHashSet
           LeafHashSet
           HashTrieSet@392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
             HashTrieSet@1818402158
              !! LOOP DETECTED. 1818402158
              !! LOOP DETECTED. 1818402158
             HashTrieSet@1590550415
               LeafHashSet
               LeafHashSet
               LeafHashSet
             LeafHashSet
             HashTrieSet@1359044626
               LeafHashSet
               LeafHashSet
               HashTrieSet@353842779
                !! LOOP DETECTED. 353842779
                !! LOOP DETECTED. 353842779
                !! LOOP DETECTED. 353842779
                 HashTrieSet@1338823963
                  !! LOOP DETECTED. 1338823963
                  !! LOOP DETECTED. 1338823963
                  !! LOOP DETECTED. 1338823963
                  !! LOOP DETECTED. 1338823963
                !! LOOP DETECTED. 353842779
                !! LOOP DETECTED. 353842779
                !! LOOP DETECTED. 353842779
                 HashTrieSet@1156060786
                  !! LOOP DETECTED. 1156060786
                  !! LOOP DETECTED. 1156060786
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@1709537756
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   HashTrieSet@2101842856
                     LeafHashSet
                     LeafHashSet
                   LeafHashSet
                 LeafHashSet
                 LeafHashSet
                 HashTrieSet@1123225098
                   LeafHashSet
                   LeafHashSet
                 LeafHashSet
                 HashTrieSet@472654579
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@1514322932
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@1634198
                   LeafHashSet
                   LeafHashSet
                 LeafHashSet
                 HashTrieSet@762152757
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@232824863
                   HashTrieSet@1282788025
                     LeafHashSet
                     LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@611437735
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@1543727556
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@985934102
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@581374081
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@947679291
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 LeafHashSet
                 HashTrieSet@1595212853
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@20671747
                   LeafHashSet
                   LeafHashSet
                 HashTrieSet@1690716179
                   LeafHashSet
                   HashTrieSet@1211888640
                     LeafHashSet
                     LeafHashSet
                 LeafHashSet
              !! LOOP DETECTED. 1359044626
              !! LOOP DETECTED. 1359044626
            !! LOOP DETECTED. 392292416
             HashTrieSet@627150481
              !! LOOP DETECTED. 627150481
               LeafHashSet
            !! LOOP DETECTED. 392292416
             HashTrieSet@1911728085
              !! LOOP DETECTED. 1911728085
              !! LOOP DETECTED. 1911728085
              !! LOOP DETECTED. 1911728085
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
             HashTrieSet@754666084
               LeafHashSet
              !! LOOP DETECTED. 754666084
              !! LOOP DETECTED. 754666084
              !! LOOP DETECTED. 754666084
               LeafHashSet
              !! LOOP DETECTED. 754666084
              !! LOOP DETECTED. 754666084
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
            !! LOOP DETECTED. 392292416
             HashTrieSet@801197928
              !! LOOP DETECTED. 801197928
               LeafHashSet
              !! LOOP DETECTED. 801197928
               LeafHashSet
            !! LOOP DETECTED. 392292416
             HashTrieSet@1631862159
              !! LOOP DETECTED. 1631862159
               LeafHashSet
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
         HashTrieSet@1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
          !! LOOP DETECTED. 1638215613
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
         HashTrieSet@591137559
          !! LOOP DETECTED. 591137559
          !! LOOP DETECTED. 591137559
          !! LOOP DETECTED. 591137559
         LeafHashSet
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
        !! LOOP DETECTED. 766572210
         HashTrieSet@2075203460
          !! LOOP DETECTED. 2075203460
          !! LOOP DETECTED. 2075203460
          !! LOOP DETECTED. 2075203460
          !! LOOP DETECTED. 2075203460
          !! LOOP DETECTED. 2075203460
         HashTrieSet@866191240
          !! LOOP DETECTED. 866191240
          !! LOOP DETECTED. 866191240
          !! LOOP DETECTED. 866191240
          !! LOOP DETECTED. 866191240
          !! LOOP DETECTED. 866191240
        !! LOOP DETECTED. 766572210
         HashTrieSet@1879492184
          !! LOOP DETECTED. 1879492184
          !! LOOP DETECTED. 1879492184
          !! LOOP DETECTED. 1879492184
      !! LOOP DETECTED. 2096057945
    !! LOOP DETECTED. 1191747167
     HashTrieSet@872627152
       LeafHashSet
       LeafHashSet
     HashTrieSet@984213526
      !! LOOP DETECTED. 984213526
       LeafHashSet
      !! LOOP DETECTED. 984213526
      !! LOOP DETECTED. 984213526
       LeafHashSet
     LeafHashSet
     HashTrieSet@1879034789
      !! LOOP DETECTED. 1879034789
       HashTrieSet@875827115
         LeafHashSet
        !! LOOP DETECTED. 875827115
       LeafHashSet
      !! LOOP DETECTED. 1879034789
     HashTrieSet@984849465
      !! LOOP DETECTED. 984849465
      !! LOOP DETECTED. 984849465
      !! LOOP DETECTED. 984849465
       HashTrieSet@787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
         HashTrieSet@2030562336
          !! LOOP DETECTED. 2030562336
          !! LOOP DETECTED. 2030562336
          !! LOOP DETECTED. 2030562336
          !! LOOP DETECTED. 2030562336
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
         HashTrieSet@1416233903
           LeafHashSet
          !! LOOP DETECTED. 1416233903
           LeafHashSet
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
         HashTrieSet@1856426318
          !! LOOP DETECTED. 1856426318
          !! LOOP DETECTED. 1856426318
          !! LOOP DETECTED. 1856426318
         HashTrieSet@1792393294
           LeafHashSet
          !! LOOP DETECTED. 1792393294
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
         HashTrieSet@1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
          !! LOOP DETECTED. 1918627686
        !! LOOP DETECTED. 787387795
         HashTrieSet@716143810
          !! LOOP DETECTED. 716143810
           LeafHashSet
         HashTrieSet@411631404
          !! LOOP DETECTED. 411631404
           LeafHashSet
          !! LOOP DETECTED. 411631404
          !! LOOP DETECTED. 411631404
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
        !! LOOP DETECTED. 787387795
     HashTrieSet@1688019098
       HashTrieSet@1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
         HashTrieSet@896681694
           LeafHashSet
           HashTrieSet@627185331
            !! LOOP DETECTED. 627185331
             LeafHashSet
          !! LOOP DETECTED. 896681694
          !! LOOP DETECTED. 896681694
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
         HashTrieSet@226170135
          !! LOOP DETECTED. 226170135
          !! LOOP DETECTED. 226170135
          !! LOOP DETECTED. 226170135
          !! LOOP DETECTED. 226170135
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
         HashTrieSet@381707837
          !! LOOP DETECTED. 381707837
          !! LOOP DETECTED. 381707837
          !! LOOP DETECTED. 381707837
          !! LOOP DETECTED. 381707837
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
         HashTrieSet@589446616
           LeafHashSet
          !! LOOP DETECTED. 589446616
        !! LOOP DETECTED. 1792845110
        !! LOOP DETECTED. 1792845110
         HashTrieSet@457233904
          !! LOOP DETECTED. 457233904
          !! LOOP DETECTED. 457233904
          !! LOOP DETECTED. 457233904
        !! LOOP DETECTED. 1792845110
      !! LOOP DETECTED. 1688019098
      !! LOOP DETECTED. 1688019098
      !! LOOP DETECTED. 1688019098
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
     HashTrieSet@245672235
      !! LOOP DETECTED. 245672235
      !! LOOP DETECTED. 245672235
      !! LOOP DETECTED. 245672235
      !! LOOP DETECTED. 245672235
     HashTrieSet@1012570586
      !! LOOP DETECTED. 1012570586
       LeafHashSet
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
     HashTrieSet@1510067370
       HashTrieSet@1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
         HashTrieSet@431687835
          !! LOOP DETECTED. 431687835
           LeafHashSet
           HashTrieSet@290658609
            !! LOOP DETECTED. 290658609
             LeafHashSet
          !! LOOP DETECTED. 431687835
         HashTrieSet@532445947
          !! LOOP DETECTED. 532445947
          !! LOOP DETECTED. 532445947
          !! LOOP DETECTED. 532445947
        !! LOOP DETECTED. 1908923184
        !! LOOP DETECTED. 1908923184
         HashTrieSet@1170794006
          !! LOOP DETECTED. 1170794006
          !! LOOP DETECTED. 1170794006
          !! LOOP DETECTED. 1170794006
          !! LOOP DETECTED. 1170794006
         HashTrieSet@1289479439
          !! LOOP DETECTED. 1289479439
          !! LOOP DETECTED. 1289479439
          !! LOOP DETECTED. 1289479439
          !! LOOP DETECTED. 1289479439
      !! LOOP DETECTED. 1510067370
      !! LOOP DETECTED. 1510067370
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
    !! LOOP DETECTED. 1191747167
     HashTrieSet@6738746
      !! LOOP DETECTED. 6738746
      !! LOOP DETECTED. 6738746
       HashTrieSet@2096171631
        !! LOOP DETECTED. 2096171631
         HashTrieSet@2114694065
          !! LOOP DETECTED. 2114694065
           LeafHashSet
      !! LOOP DETECTED. 6738746
    !! LOOP DETECTED. 1191747167

java.lang.AssertionError: not equals

	at org.junit.Assert.fail(Assert.java:88)
	at scala.collection.immutable.HashSetTest.$anonfun$optimizedAppendAllWorks$1(HashSetTest.scala:238)
	at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:158)
	at scala.collection.immutable.HashSetTest.optimizedAppendAllWorks(HashSetTest.scala:223)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Process finished with exit code 255

```
  • Loading branch information
retronym committed Feb 19, 2020
1 parent b193a2b commit fd08eec
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 29 deletions.
89 changes: 75 additions & 14 deletions src/library/scala/collection/immutable/HashSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ sealed class HashSet[A] extends AbstractSet[A]
with GenericSetTemplate[A, HashSet]
with SetLike[A, HashSet[A]]
with CustomParallelizable[A, ParHashSet[A]]
with Serializable
{
with Serializable {
import HashSet.{nullToEmpty, bufferSize, computeHash}

override def companion: GenericCompanion[HashSet] = HashSet
Expand All @@ -59,7 +58,7 @@ sealed class HashSet[A] extends AbstractSet[A]
def contains(e: A): Boolean = get0(e, computeHash(e), 0)

override def subsetOf(that: GenSet[A]) = that match {
case that:HashSet[A] =>
case that: HashSet[A] =>
// call the specialized implementation with a level of 0 since both this and that are top-level hash sets
subsetOf0(that, 0)
case _ =>
Expand All @@ -70,7 +69,8 @@ sealed class HashSet[A] extends AbstractSet[A]
/**
* A specialized implementation of subsetOf for when both this and that are HashSet[A] and we can take advantage
* of the tree structure of both operands and the precalculated hashcodes of the HashSet1 instances.
* @param that the other set
*
* @param that the other set
* @param level the level of this and that hashset
* The purpose of level is to keep track of how deep we are in the tree.
* We need this information for when we arrive at a leaf and have to call get0 on that
Expand All @@ -82,9 +82,9 @@ sealed class HashSet[A] extends AbstractSet[A]
true
}

override def + (e: A): HashSet[A] = updated0(e, computeHash(e), 0)
override def +(e: A): HashSet[A] = updated0(e, computeHash(e), 0)

override def + (elem1: A, elem2: A, elems: A*): HashSet[A] =
override def +(elem1: A, elem2: A, elems: A*): HashSet[A] =
this + elem1 + elem2 ++ elems

override def union(that: GenSet[A]): HashSet[A] = that match {
Expand Down Expand Up @@ -121,7 +121,8 @@ sealed class HashSet[A] extends AbstractSet[A]

/**
* Union with a HashSet at a given level
* @param that a HashSet
*
* @param that a HashSet
* @param level the depth in the tree. We need to keep track of the level to know how deep we are in the tree
* @return The union of this and that at the given level. Unless level is zero, the result is not a self-contained
* HashSet but needs to be stored at the correct depth
Expand All @@ -133,8 +134,9 @@ sealed class HashSet[A] extends AbstractSet[A]

/**
* Intersection with another hash set at a given level
* @param level the depth in the tree. We need to keep track of the level to know how deep we are in the tree
* @param buffer a temporary buffer that is used for temporarily storing elements when creating new branch nodes
*
* @param level the depth in the tree. We need to keep track of the level to know how deep we are in the tree
* @param buffer a temporary buffer that is used for temporarily storing elements when creating new branch nodes
* @param offset0 the first offset into the buffer in which we are allowed to write
* @return The intersection of this and that at the given level. Unless level is zero, the result is not a
* self-contained HashSet but needs to be stored at the correct depth
Expand All @@ -146,8 +148,9 @@ sealed class HashSet[A] extends AbstractSet[A]

/**
* Diff with another hash set at a given level
* @param level the depth in the tree. We need to keep track of the level to know how deep we are in the tree
* @param buffer a temporary buffer that is used for temporarily storing elements when creating new branch nodes
*
* @param level the depth in the tree. We need to keep track of the level to know how deep we are in the tree
* @param buffer a temporary buffer that is used for temporarily storing elements when creating new branch nodes
* @param offset0 the first offset into the buffer in which we are allowed to write
* @return The diff of this and that at the given level. Unless level is zero, the result is not a
* self-contained HashSet but needs to be stored at the correct depth
Expand All @@ -157,7 +160,7 @@ sealed class HashSet[A] extends AbstractSet[A]
null
}

def - (e: A): HashSet[A] =
def -(e: A): HashSet[A] =
nullToEmpty(removed0(e, computeHash(e), 0))

override def tail: HashSet[A] = this - head
Expand All @@ -179,7 +182,6 @@ sealed class HashSet[A] extends AbstractSet[A]
}



protected def filter0(p: A => Boolean, negate: Boolean, level: Int, buffer: Array[HashSet[A]], offset0: Int): HashSet[A] = null

protected def get0(key: A, hash: Int, level: Int): Boolean = false
Expand All @@ -192,6 +194,61 @@ sealed class HashSet[A] extends AbstractSet[A]
protected def writeReplace(): AnyRef = new HashSet.SerializationProxy(this)

override def toSet[B >: A]: Set[B] = this.asInstanceOf[HashSet[B]]

def printDebug(): Unit = {
var indent = -1
val seen = new java.util.IdentityHashMap[HashSet[_], Object]

def loop(node: HashSet[_]): Unit = {
indent += 1
try {
seen.put(node, null)
(node: HashSet[_]) match {
case HashSet.EmptyHashSet =>
println((" " * indent) + " EmptyHashSet")
case set: HashSet.LeafHashSet[_] =>
println((" " * indent) + " " + set.getClass.getSimpleName + "@" + System.identityHashCode(set))
case set: HashSet.HashTrieSet[_] =>
println((" " * indent) + " HashTrieSet@" + System.identityHashCode(set))
for (elem <- set.elems) {
if (elem != null && seen.containsKey(elem)) {
println((" " * (indent + 1)) + "!! DUPLICATE NODE DETECTED. " + set.getClass.getSimpleName + "@" + System.identityHashCode(set))
getClass
} else loop(elem)
}
case _ =>
}
} finally {
indent -= 1
}
}

loop(this)
}

def selfCheck(): Unit = {

val seen = new java.util.IdentityHashMap[HashSet[_], Object]

def loop(node: HashSet[_]): Unit = {
seen.put(node, null)
(node: HashSet[_]) match {
case HashSet.EmptyHashSet =>
case set: HashSet.LeafHashSet[_] =>
case set: HashSet.HashTrieSet[_] =>
for (elem <- set.elems) {
if (elem != null && seen.containsKey(elem)) {
printDebug()
throw new AssertionError("")
}
else loop(elem)
}
case _ =>
}
}

loop(this)
}
}

/** $factoryInfo
Expand Down Expand Up @@ -527,7 +584,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
class HashTrieSet[A](private[HashSet] var bitmap: Int, private[collection] var elems: Array[HashSet[A]], private[HashSet] var size0: Int)
extends HashSet[A] {
@inline override def size = size0
// assert(Integer.bitCount(bitmap) == elems.length)
assert(Integer.bitCount(bitmap) == elems.length)
// assertion has to remain disabled until scala/bug#6197 is solved
// assert(elems.length > 1 || (elems.length == 1 && elems(0).isInstanceOf[HashTrieSet[_]]))

Expand Down Expand Up @@ -1390,20 +1447,23 @@ object HashSet extends ImmutableSetFactory[HashSet] {
if (arrayIndex == -1) {
val newToNode = makeMutable(toNode)
newToNode.elems(rawIndex) = result
newToNode.selfCheck()
newToNode
} else {
val old = toNode.elems(arrayIndex)
if (old eq toBeAdded) toNode
else if (old eq null) {
assert(isMutable(toNode))
toNode.elems(arrayIndex) = toBeAdded
toNode.selfCheck()
toNode
} else {
val result = addHashSet(old, toBeAdded, level + 5)
if (result eq old) toNode
else {
val newToNode = makeMutable(toNode)
newToNode.elems(rawIndex) = result
newToNode.selfCheck()
newToNode
}
}
Expand Down Expand Up @@ -1437,6 +1497,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
bBitSet ^= 1 << rawIndex
bArrayIndex += 1
}
result.selfCheck()
result

case empty if empty eq EmptyHashSet => toNode
Expand Down
34 changes: 19 additions & 15 deletions test/junit/scala/collection/immutable/HashSetTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.collection.immutable

import org.junit.Assert._
import org.junit.Test
import org.junit.{Assert, Test}
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

Expand Down Expand Up @@ -218,21 +218,25 @@ class HashSetTest extends AllocationTest {

@Test
def optimizedAppendAllWorks(): Unit = {
case class C(i: Int) {
override def hashCode: Int = i % 1024
}
case class C(i: Int) { override def hashCode: Int = i % 1024 }
val setReference = collection.mutable.HashSet[C]()
val builder0 = collection.immutable.HashSet.newBuilder[C];
for (i <- 1 to 16) {
val builder1 = collection.immutable.HashSet.newBuilder[C];
for (i <- 1 to 8)
builder1 += C(scala.util.Random.nextInt());
val s1 = builder1.result()
builder0 ++= s1
setReference ++= s1
for (i <- 1 to 10) {
println("iteration " + i)
val builder0 = collection.immutable.HashSet.newBuilder[C];
for (i <- 1 to 16) {
val builder1 = collection.immutable.HashSet.newBuilder[C];
for (i <- 1 to 8)
builder1 += C(scala.util.Random.nextInt());
val s1 = builder1.result()
builder0 ++= s1
setReference ++= s1
}
val set0 = builder0.result()
set0.foreach(_.hashCode)
if (set0 != setReference) {
set0.printDebug()
Assert.fail("not equals")
}
}
val set0 = builder0.result()
assertEquals(set0, setReference)
}

}

0 comments on commit fd08eec

Please sign in to comment.