type generation … type spilledBatch … // readGeneration buffers and decodes the structural elements of a trace generation // out of r. spill is the first batch of the new generation (already buffered and // parsed from reading the last generation). Returns the generation and the first // batch read of the next generation, if any. // // If gen is non-nil, it is valid and must be processed before handling the returned // error. func readGeneration(r *bufio.Reader, spill *spilledBatch) (*generation, *spilledBatch, error) { … } // processBatch adds the batch to the generation. func processBatch(g *generation, b batch) error { … } // validateStackStrings makes sure all the string references in // the stack table are present in the string table. func validateStackStrings( stacks *dataTable[stackID, stack], strings *dataTable[stringID, string], frames map[uint64]frame, ) error { … } // addStrings takes a batch whose first byte is an EvStrings event // (indicating that the batch contains only strings) and adds each // string contained therein to the provided strings map. func addStrings(stringTable *dataTable[stringID, string], b batch) error { … } // addStacks takes a batch whose first byte is an EvStacks event // (indicating that the batch contains only stacks) and adds each // string contained therein to the provided stacks map. func addStacks(stackTable *dataTable[stackID, stack], pcs map[uint64]frame, b batch) error { … } // addCPUSamples takes a batch whose first byte is an EvCPUSamples event // (indicating that the batch contains only CPU samples) and adds each // sample contained therein to the provided samples list. func addCPUSamples(samples []cpuSample, b batch) ([]cpuSample, error) { … } // parseFreq parses out a lone EvFrequency from a batch. func parseFreq(b batch) (frequency, error) { … } // addExperimentalData takes an experimental batch and adds it to the ExperimentalData // for the experiment its a part of. func addExperimentalData(expData map[event.Experiment]*ExperimentalData, b batch) error { … }