src/jdk.jfr/share/classes/jdk/jfr/consumer/EventParser.java
branchJEP-349-branch
changeset 57460 bcbc53560c77
parent 57452 6fabe73e5d9a
child 57463 e8d4ec2bf480
equal deleted inserted replaced
57459:df39f8d8f4d6 57460:bcbc53560c77
    52     private RecordedEvent[] eventCache;
    52     private RecordedEvent[] eventCache;
    53     private int index;
    53     private int index;
    54     private boolean ordered;
    54     private boolean ordered;
    55     private long firstNanos;
    55     private long firstNanos;
    56     private long thresholdNanos = -1;
    56     private long thresholdNanos = -1;
       
    57     private ObjectContext objectContext;
    57 
    58 
    58     EventParser(TimeConverter timeConverter, EventType type, Parser[] parsers) {
    59     EventParser(TimeConverter timeConverter, EventType type, Parser[] parsers) {
    59         this.timeConverter = timeConverter;
    60         this.timeConverter = timeConverter;
    60         this.parsers = parsers;
    61         this.parsers = parsers;
    61         this.eventType = type;
    62         this.eventType = type;
    62         this.hasDuration = type.getField(FIELD_DURATION) != null;
    63         this.hasDuration = type.getField(FIELD_DURATION) != null;
    63         this.startIndex = hasDuration ? 2 : 1;
    64         this.startIndex = hasDuration ? 2 : 1;
    64         this.length = parsers.length - startIndex;
    65         this.length = parsers.length - startIndex;
    65         this.valueDescriptors = type.getFields();
    66         this.valueDescriptors = type.getFields();
    66         this.unorderedEvent = new RecordedEvent(eventType, valueDescriptors, new Object[length], 0L, 0L, timeConverter);
    67         this.objectContext = new ObjectContext(type, valueDescriptors, timeConverter);
       
    68         this.unorderedEvent = new RecordedEvent(objectContext, new Object[length], 0L, 0L);
    67     }
    69     }
    68 
    70 
    69     private RecordedEvent cachedEvent() {
    71     private RecordedEvent cachedEvent() {
    70         if (ordered) {
    72         if (ordered) {
    71             if (index == eventCache.length) {
    73             if (index == eventCache.length) {
    73                 eventCache = new RecordedEvent[eventCache.length * 2];
    75                 eventCache = new RecordedEvent[eventCache.length * 2];
    74                 System.arraycopy(cache, 0, eventCache, 0, cache.length);
    76                 System.arraycopy(cache, 0, eventCache, 0, cache.length);
    75             }
    77             }
    76             RecordedEvent event = eventCache[index];
    78             RecordedEvent event = eventCache[index];
    77             if (event == null) {
    79             if (event == null) {
    78                 event = new RecordedEvent(eventType, valueDescriptors, new Object[length], 0L, 0L, timeConverter);
    80                 event = new RecordedEvent(objectContext, new Object[length], 0L, 0L);
    79                 eventCache[index] = event;
    81                 eventCache[index] = event;
    80             }
    82             }
    81             index++;
    83             index++;
    82             return event;
    84             return event;
    83         } else {
    85         } else {
   132             } else {
   134             } else {
   133                 Object[] values = new Object[length];
   135                 Object[] values = new Object[length];
   134                 for (int i = 0; i < length; i++) {
   136                 for (int i = 0; i < length; i++) {
   135                     values[i] = parsers[startIndex + i].parse(input);
   137                     values[i] = parsers[startIndex + i].parse(input);
   136                 }
   138                 }
   137                 return new RecordedEvent(eventType, valueDescriptors, values, startTicks, endTicks, timeConverter);
   139                 return new RecordedEvent(objectContext, values, startTicks, endTicks);
   138             }
   140             }
   139         }
   141         }
   140         return null;
   142         return null;
   141     }
   143     }
   142 
   144