(settings heuristicSettings)
| 454 | } |
| 455 | |
| 456 | func (s blockSummary) ToDedicatedColumns(settings heuristicSettings) []backend.DedicatedColumn { |
| 457 | var dedicatedCols []backend.DedicatedColumn |
| 458 | |
| 459 | doStringSummary := func(summary attributeSummary, scope backend.DedicatedColumnScope) { |
| 460 | if summary.rowCount == 0 { |
| 461 | return |
| 462 | } |
| 463 | for _, attr := range topN(settings.NumStringAttr, summary.attributes) { |
| 464 | percentOfRows := float64(attr.cardinality.totalOccurrences()) / float64(summary.rowCount) |
| 465 | if percentOfRows < settings.StrThresholdPercent { |
| 466 | continue |
| 467 | } |
| 468 | |
| 469 | options := backend.DedicatedColumnOptions{} |
| 470 | totalSize := attr.cardinality.avgSizePerRowGroup(s.numRowGroups) |
| 471 | if settings.BlobThresholdBytes > 0 && totalSize >= settings.BlobThresholdBytes { |
| 472 | options = append(options, backend.DedicatedColumnOptionBlob) |
| 473 | } |
| 474 | dedicatedCols = append(dedicatedCols, backend.DedicatedColumn{ |
| 475 | Name: attr.name, |
| 476 | Scope: scope, |
| 477 | Type: backend.DedicatedColumnTypeString, |
| 478 | Options: options, |
| 479 | }) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | doIntSummary := func(summary attributeSummary, scope backend.DedicatedColumnScope) { |
| 484 | if summary.rowCount == 0 { |
| 485 | return |
| 486 | } |
| 487 | for _, attr := range topNInt(settings.NumIntAttr, summary.integerAttributes) { |
| 488 | percentOfRows := float64(attr.count) / float64(summary.rowCount) |
| 489 | if percentOfRows < settings.IntThresholdPercent { |
| 490 | continue |
| 491 | } |
| 492 | dedicatedCols = append(dedicatedCols, backend.DedicatedColumn{ |
| 493 | Name: attr.name, |
| 494 | Scope: scope, |
| 495 | Type: backend.DedicatedColumnTypeInt, |
| 496 | Options: backend.DedicatedColumnOptions{}, |
| 497 | }) |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | doStringSummary(s.spanSummary, backend.DedicatedColumnScopeSpan) |
| 502 | doIntSummary(s.spanSummary, backend.DedicatedColumnScopeSpan) |
| 503 | doStringSummary(s.resourceSummary, backend.DedicatedColumnScopeResource) |
| 504 | doIntSummary(s.resourceSummary, backend.DedicatedColumnScopeResource) |
| 505 | doStringSummary(s.eventSummary, backend.DedicatedColumnScopeEvent) |
| 506 | doIntSummary(s.eventSummary, backend.DedicatedColumnScopeEvent) |
| 507 | |
| 508 | return dedicatedCols |
| 509 | } |
| 510 | |
| 511 | type attributeSummary struct { |
| 512 | attributes map[string]*stringAttributeSummary // key: attribute name |
no test coverage detected