MCPcopy
hub / github.com/grafana/tempo / Complete

Method Complete

tempodb/encoding/vparquet5/create.go:231–286  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229}
230
231func (b *streamingBlock) Complete() (int, error) {
232 // Flush final row group
233 b.index.Flush()
234 b.meta.TotalRecords++
235 err := b.pw.Flush()
236 if err != nil {
237 return 0, err
238 }
239
240 // Close parquet file. This writes the footer and metadata.
241 err = b.pw.Close()
242 if err != nil {
243 return 0, err
244 }
245
246 // Now Flush and close out in-memory buffer
247 n := b.bw.Len()
248 b.meta.Size_ += uint64(n)
249 err = b.bw.Flush()
250 if err != nil {
251 return 0, err
252 }
253
254 err = b.bw.Close()
255 if err != nil {
256 return 0, err
257 }
258
259 err = b.w.Close()
260 if err != nil {
261 return 0, err
262 }
263
264 // Read the footer size out of the parquet footer
265 buf := make([]byte, 8)
266 err = b.r.ReadRange(b.ctx, DataFileName, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID, b.meta.Size_-8, buf, nil)
267 if err != nil {
268 return 0, fmt.Errorf("error reading parquet file footer: %w", err)
269 }
270 if string(buf[4:8]) != "PAR1" {
271 return 0, errors.New("failed to confirm magic footer while writing a new parquet block")
272 }
273 b.meta.FooterSize = binary.LittleEndian.Uint32(buf[0:4])
274
275 b.meta.BloomShardCount = uint32(b.bloom.GetShardCount())
276
277 if b.withNoCompactFlag {
278 // write nocompact flag first to prevent compaction before completion
279 err := b.to.WriteNoCompactFlag(b.ctx, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID)
280 if err != nil {
281 return 0, fmt.Errorf("unexpected error writing nocompact flag: %w", err)
282 }
283 }
284
285 return n, writeBlockMeta(b.ctx, b.to, b.meta, b.bloom, b.index)
286}
287
288// estimateMarshalledSizeFromTrace estimates the size of this trace when written to parquet. This is used to

Callers 5

finishBlockMethod · 0.45
createTestBlockFunction · 0.45
CreateBlockFunction · 0.45

Calls 7

GetShardCountMethod · 0.80
writeBlockMetaFunction · 0.70
FlushMethod · 0.65
CloseMethod · 0.65
LenMethod · 0.65
ReadRangeMethod · 0.65
WriteNoCompactFlagMethod · 0.65