Class FastCursorRandomAccessLoops


  • final class FastCursorRandomAccessLoops
    extends java.lang.Object
    This class aims to avoid performance problems of the Java just in time compilation when running a loop that executes an action on a Cursor and multiple RandomAccesses. Such a loop might look like this:
     
    
     while(--n >= 0) {
       A a = cursorA.next();
       randomAccessB.setPosition( cursorA );
       randomAccessC.setPosition( cursorA );
       action.accept( a, randomAccessB.get(), randomAccessC.get() );
     }
     
     
    Usually such a loop has significant performance problems when used together multiple different classes that implement Cursor, RandomAccess, and action interfaces. This is caused by the JIT-compiler who simple performs badly in these situations. This class solves these performance problems by holding multiple copies of the bytecode of these loops. A bytecode copy can be individually optimized by the Java JIT compiler to perform optimally for a specific use case.
    • Field Detail

      • factories

        private static final java.util.List<ClassCopyProvider<java.util.function.LongConsumer>> factories
    • Constructor Detail

      • FastCursorRandomAccessLoops

        private FastCursorRandomAccessLoops()
    • Method Detail

      • loop

        static void loop​(java.lang.Object action,
                         long n,
                         Cursor<?> cursor,
                         java.util.List<? extends RandomAccess<?>> randomAccesses)
      • createLoop

        private static java.util.function.LongConsumer createLoop​(java.lang.Object action,
                                                                  Cursor<?> cursor,
                                                                  java.util.List<? extends RandomAccess<?>> randomAccesses)