1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,53 @@
package utils
// This is split out from the 'postgresql' package as its depended upon by both the 'postgresql' and
// 'postgresql/template' packages.
import (
"sort"
"strings"
)
// ColumnRole specifies the role of a column in a metric.
// It helps map the columns to the DB.
type ColumnRole int
const (
TimeColType ColumnRole = iota + 1
TagsIDColType
TagColType
FieldColType
)
type Column struct {
Name string
// the data type of each column should have in the db. used when checking
// if the schema matches or it needs updates
Type string
// the role each column has, helps properly map the metric to the db
Role ColumnRole
}
// ColumnList implements sort.Interface.
// Columns are sorted first into groups of time,tag_id,tags,fields, and then alphabetically within
// each group.
type ColumnList []Column
func (cl ColumnList) Len() int {
return len(cl)
}
func (cl ColumnList) Less(i, j int) bool {
if cl[i].Role != cl[j].Role {
return cl[i].Role < cl[j].Role
}
return strings.ToLower(cl[i].Name) < strings.ToLower(cl[j].Name)
}
func (cl ColumnList) Swap(i, j int) {
cl[i], cl[j] = cl[j], cl[i]
}
func (cl ColumnList) Sort() {
sort.Sort(cl)
}