< prev index next >

application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/common/DataPageToolkit.java

Print this page




 791                 // FIXME: Should we always include event type? Does it make any sense, except on the custom pages?
 792 
 793                 // FIXME: Transform both START_TIME and END_TIME to LIFETIME?
 794                 // FIXME: Add derived attributes, like a conversion of any THREAD or CLASS attribute? Thread group?
 795                 /*
 796                  * Make sure to do the conversions in the right order, so for example a stack trace can be
 797                  * converted to a top method, which then is converted to a method string.
 798                  */
 799                 return attributes.map(a -> a.equals(JfrAttributes.EVENT_THREAD) ? JdkAttributes.EVENT_THREAD_NAME : a)
 800                                 .flatMap(a -> a.equals(JfrAttributes.EVENT_STACKTRACE) ? Stream.of(JdkAttributes.STACK_TRACE_STRING,
 801                                                 JdkAttributes.STACK_TRACE_TOP_METHOD_STRING, JdkAttributes.STACK_TRACE_TOP_CLASS_STRING,
 802                                                 JdkAttributes.STACK_TRACE_TOP_PACKAGE, JdkAttributes.STACK_TRACE_BOTTOM_METHOD_STRING)
 803                                                 : Stream.of(a))
 804                                 .map(a -> a.equals(JdkAttributes.COMPILER_METHOD) ? JdkAttributes.COMPILER_METHOD_STRING : a)
 805                                 // FIXME: String or id?
 806                                 .map(a -> a.equals(JdkAttributes.REC_SETTING_FOR) ? JdkAttributes.REC_SETTING_FOR_NAME : a)
 807                                 .map(a -> a.equals(JdkAttributes.CLASS_DEFINING_CLASSLOADER)
 808                                                 ? JdkAttributes.CLASS_DEFINING_CLASSLOADER_STRING : a)
 809                                 .map(a -> a.equals(JdkAttributes.CLASS_INITIATING_CLASSLOADER)
 810                                                 ? JdkAttributes.CLASS_INITIATING_CLASSLOADER_STRING : a)




 811                                 .filter(a -> a.equals(JfrAttributes.EVENT_TYPE) || (a.getContentType() instanceof RangeContentType)
 812                                                 || (a.getContentType().getPersister() != null))
 813                                 .distinct();
 814         }
 815 
 816         /**
 817          * Returns a value for attribute, firstly by trying to find one in the items, secondly by
 818          * creating a default value for some known content types. Returns null if the first two cases
 819          * fail.
 820          *
 821          * @param items
 822          * @param attribute
 823          * @return a value of type V, or null
 824          */
 825         @SuppressWarnings("unchecked")
 826         private static <V> V findValueForFilter(IItemCollection items, ICanonicalAccessorFactory<V> attribute) {
 827                 IItem firstItem = ItemCollectionToolkit.stream(items).filter(is -> is.getType().hasAttribute(attribute))
 828                                 .flatMap(ItemIterableToolkit::stream)
 829                                 .filter(i -> ((IMemberAccessor<V, IItem>) attribute.getAccessor(i.getType())).getMember(i) != null)
 830                                 .findFirst().orElse(null);




 791                 // FIXME: Should we always include event type? Does it make any sense, except on the custom pages?
 792 
 793                 // FIXME: Transform both START_TIME and END_TIME to LIFETIME?
 794                 // FIXME: Add derived attributes, like a conversion of any THREAD or CLASS attribute? Thread group?
 795                 /*
 796                  * Make sure to do the conversions in the right order, so for example a stack trace can be
 797                  * converted to a top method, which then is converted to a method string.
 798                  */
 799                 return attributes.map(a -> a.equals(JfrAttributes.EVENT_THREAD) ? JdkAttributes.EVENT_THREAD_NAME : a)
 800                                 .flatMap(a -> a.equals(JfrAttributes.EVENT_STACKTRACE) ? Stream.of(JdkAttributes.STACK_TRACE_STRING,
 801                                                 JdkAttributes.STACK_TRACE_TOP_METHOD_STRING, JdkAttributes.STACK_TRACE_TOP_CLASS_STRING,
 802                                                 JdkAttributes.STACK_TRACE_TOP_PACKAGE, JdkAttributes.STACK_TRACE_BOTTOM_METHOD_STRING)
 803                                                 : Stream.of(a))
 804                                 .map(a -> a.equals(JdkAttributes.COMPILER_METHOD) ? JdkAttributes.COMPILER_METHOD_STRING : a)
 805                                 // FIXME: String or id?
 806                                 .map(a -> a.equals(JdkAttributes.REC_SETTING_FOR) ? JdkAttributes.REC_SETTING_FOR_NAME : a)
 807                                 .map(a -> a.equals(JdkAttributes.CLASS_DEFINING_CLASSLOADER)
 808                                                 ? JdkAttributes.CLASS_DEFINING_CLASSLOADER_STRING : a)
 809                                 .map(a -> a.equals(JdkAttributes.CLASS_INITIATING_CLASSLOADER)
 810                                                 ? JdkAttributes.CLASS_INITIATING_CLASSLOADER_STRING : a)
 811                                 .map(a -> a.equals(JdkAttributes.PARENT_CLASSLOADER)
 812                                                 ? JdkAttributes.PARENT_CLASSLOADER_STRING : a)
 813                                 .map(a -> a.equals(JdkAttributes.CLASSLOADER)
 814                                                 ? JdkAttributes.CLASSLOADER_STRING : a)
 815                                 .filter(a -> a.equals(JfrAttributes.EVENT_TYPE) || (a.getContentType() instanceof RangeContentType)
 816                                                 || (a.getContentType().getPersister() != null))
 817                                 .distinct();
 818         }
 819 
 820         /**
 821          * Returns a value for attribute, firstly by trying to find one in the items, secondly by
 822          * creating a default value for some known content types. Returns null if the first two cases
 823          * fail.
 824          *
 825          * @param items
 826          * @param attribute
 827          * @return a value of type V, or null
 828          */
 829         @SuppressWarnings("unchecked")
 830         private static <V> V findValueForFilter(IItemCollection items, ICanonicalAccessorFactory<V> attribute) {
 831                 IItem firstItem = ItemCollectionToolkit.stream(items).filter(is -> is.getType().hasAttribute(attribute))
 832                                 .flatMap(ItemIterableToolkit::stream)
 833                                 .filter(i -> ((IMemberAccessor<V, IItem>) attribute.getAccessor(i.getType())).getMember(i) != null)
 834                                 .findFirst().orElse(null);


< prev index next >