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

Method Complete

tempodb/encoding/vparquet4/create.go:230–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 6

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

Tested by 4

createTestBlockFunction · 0.36