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

Function SchemaWithDynamicChanges

tempodb/encoding/vparquet5/schema.go:882–967  ·  view source on GitHub ↗
(dedicatedColumns backend.DedicatedColumns)

Source from the content-addressed store, hash-verified

880}
881
882func SchemaWithDynamicChanges(dedicatedColumns backend.DedicatedColumns) (*parquet.Schema, []parquet.WriterOption, []parquet.ReaderOption) {
883 var (
884 resMapping = dedicatedColumnsToColumnMapping(dedicatedColumns, backend.DedicatedColumnScopeResource)
885 spanMapping = dedicatedColumnsToColumnMapping(dedicatedColumns, backend.DedicatedColumnScopeSpan)
886 eventMapping = dedicatedColumnsToColumnMapping(dedicatedColumns, backend.DedicatedColumnScopeEvent)
887 )
888
889 schemaOptions := []parquet.SchemaOption{}
890 writerOptions := []parquet.WriterOption{}
891 readerOptions := []parquet.ReaderOption{}
892
893 // Blobify
894 blobify := func(col dedicatedColumn) {
895 path := strings.Split(col.ColumnPath, ".")
896
897 // Remove dictionary encoding and change compression.
898 option := parquet.StructTag(`parquet:",zstd,optional"`, path...)
899 schemaOptions = append(schemaOptions, option)
900 readerOptions = append(readerOptions, option)
901 writerOptions = append(writerOptions, option)
902
903 // Minor optimization: skip page bounds for blob columns. The min/max values are not
904 // selective, and this saves a little bit of storage and overhead.
905 writerOptions = append(writerOptions, parquet.SkipPageBounds(path...))
906 }
907
908 for _, col := range spanMapping.mapping {
909 if col.IsBlob {
910 blobify(col)
911 }
912 }
913 for _, col := range resMapping.mapping {
914 if col.IsBlob {
915 blobify(col)
916 }
917 }
918 for _, col := range eventMapping.mapping {
919 if col.IsBlob {
920 blobify(col)
921 }
922 }
923
924 // Remove unused dedicated columns.
925 del := func(path string) {
926 option := parquet.StructTag(`parquet:"-"`, strings.Split(path, ".")...)
927 schemaOptions = append(schemaOptions, option)
928 readerOptions = append(readerOptions, option)
929 writerOptions = append(writerOptions, option)
930 }
931
932 for scope, m1 := range DedicatedResourceColumnPaths {
933 for _, paths := range m1 {
934 for _, path := range paths {
935 switch scope {
936 case backend.DedicatedColumnScopeResource:
937 if !resMapping.usesPath(path) {
938 del(path)
939 }

Callers 11

openForIterationMethod · 0.85
CompactMethod · 0.85
findTraceByIDFunction · 0.85
TestCountSpansFunction · 0.85
fileMethod · 0.85
openWriterMethod · 0.85
IteratorMethod · 0.85
FindTraceByIDMethod · 0.85
openForSearchMethod · 0.85
newStreamingBlockFunction · 0.85

Calls 3

usesPathMethod · 0.80
lenMethod · 0.45

Tested by 2

TestCountSpansFunction · 0.68