63 SeekableInputStream input = SeekableInputStream.build(data, header.isIntegersCompressed()); 64 65 // Read metadata 66 input.seek(header.getMetadataOffset()); 67 List<ClassElement> classes = ChunkMetadata.readMetadata(input).metadata.classes; 68 TypeManager manager = new TypeManager(classes, context, header); 69 70 // Read constants 71 long constantPoolOffset = 0; 72 // An initial constantPoolOffset of 0 indicates no constant pools. 73 long delta = header.getConstantPoolOffset(); 74 while (delta != 0) { 75 constantPoolOffset += delta; 76 input.seek(constantPoolOffset); 77 delta = readConstantPoolEvent(input, manager); 78 } 79 manager.resolveConstants(); 80 81 // Read events 82 long index = header.getBodyStartOffset(); 83 while (true) { 84 input.seek(index); 85 int size = input.readInt(); 86 long type = input.readLong(); 87 if (type == ChunkMetadata.METADATA_EVENT_TYPE) { 88 return data; 89 } else if (type != CONSTANT_POOL_EVENT_TYPE) { 90 manager.readEvent(type, input); 91 } 92 index += size; 93 } 94 } 95 96 private static long readConstantPoolEvent(IDataInput input, TypeManager manager) 97 throws IOException, InvalidJfrFileException { 98 input.readInt(); // size 99 ParserToolkit.assertValue(input.readLong(), CONSTANT_POOL_EVENT_TYPE); // type; 100 input.readLong(); // start 101 input.readLong(); // duration 102 long delta = input.readLong(); 103 input.readBoolean(); // flush 104 int poolCount = input.readInt(); 105 for (int i = 0; i < poolCount; i++) { 106 long classId = input.readLong(); 107 int constantCount = input.readInt(); 108 manager.readConstants(classId, input, constantCount); 109 } 110 return delta; 111 } 112 113 public static IChunkLoader create(Chunk input, LoaderContext context) | 63 SeekableInputStream input = SeekableInputStream.build(data, header.isIntegersCompressed()); 64 65 // Read metadata 66 input.seek(header.getMetadataOffset()); 67 List<ClassElement> classes = ChunkMetadata.readMetadata(input).metadata.classes; 68 TypeManager manager = new TypeManager(classes, context, header); 69 70 // Read constants 71 long constantPoolOffset = 0; 72 // An initial constantPoolOffset of 0 indicates no constant pools. 73 long delta = header.getConstantPoolOffset(); 74 while (delta != 0) { 75 constantPoolOffset += delta; 76 input.seek(constantPoolOffset); 77 delta = readConstantPoolEvent(input, manager); 78 } 79 manager.resolveConstants(); 80 81 // Read events 82 long index = header.getBodyStartOffset(); 83 while (index < header.getChunkSize()) { 84 input.seek(index); 85 int size = input.readInt(); 86 long type = input.readLong(); 87 if (type != CONSTANT_POOL_EVENT_TYPE && type != ChunkMetadata.METADATA_EVENT_TYPE) { 88 manager.readEvent(type, input); 89 } 90 index += size; 91 } 92 return data; 93 } 94 95 private static long readConstantPoolEvent(IDataInput input, TypeManager manager) 96 throws IOException, InvalidJfrFileException { 97 input.readInt(); // size 98 ParserToolkit.assertValue(input.readLong(), CONSTANT_POOL_EVENT_TYPE); // type; 99 input.readLong(); // start 100 input.readLong(); // duration 101 long delta = input.readLong(); 102 input.readBoolean(); // flush 103 int poolCount = input.readInt(); 104 for (int i = 0; i < poolCount; i++) { 105 long classId = input.readLong(); 106 int constantCount = input.readInt(); 107 manager.readConstants(classId, input, constantCount); 108 } 109 return delta; 110 } 111 112 public static IChunkLoader create(Chunk input, LoaderContext context) |