Skip to content

Commit a5f0720

Browse files
committed
modify schem
1 parent 21f5894 commit a5f0720

File tree

3 files changed

+91
-25
lines changed

3 files changed

+91
-25
lines changed

pkg/data/usecases/iot/diagnostics.go

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package iot
22

33
import (
4+
"time"
5+
46
"github.com/cnosdb/tsdb-comparisons/pkg/data"
57
"github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common"
6-
"time"
78
)
89

910
const (
@@ -17,11 +18,16 @@ var (
1718
labelFuelState = []byte("fuel_state")
1819
labelCurrentLoad = []byte("current_load")
1920
labelStatus = []byte("status")
20-
fuelUD = common.UD(-0.001, 0)
21-
loadUD = common.UD(0, maxLoad)
22-
loadSaddleUD = common.UD(0, 1)
23-
statusND = common.ND(0, 1)
24-
21+
22+
labelLoadCapacity = []byte("load_capacity")
23+
labelFuelCapacity = []byte("fuel_capacity")
24+
labelNominalFuelConsumption = []byte("nominal_fuel_consumption")
25+
26+
fuelUD = common.UD(-0.001, 0)
27+
loadUD = common.UD(0, maxLoad)
28+
loadSaddleUD = common.UD(0, 1)
29+
statusND = common.ND(0, 1)
30+
2531
diagnosticsFields = []common.LabeledDistributionMaker{
2632
{
2733
Label: labelFuelState,
@@ -50,6 +56,33 @@ var (
5056
)
5157
},
5258
},
59+
{
60+
Label: labelLoadCapacity,
61+
DistributionMaker: func() common.Distribution {
62+
return common.FP(
63+
common.CWD(statusND, 1500, 5000, 0),
64+
0,
65+
)
66+
},
67+
},
68+
{
69+
Label: labelFuelCapacity,
70+
DistributionMaker: func() common.Distribution {
71+
return common.FP(
72+
common.CWD(statusND, 150, 300, 0),
73+
0,
74+
)
75+
},
76+
},
77+
{
78+
Label: labelNominalFuelConsumption,
79+
DistributionMaker: func() common.Distribution {
80+
return common.FP(
81+
common.CWD(statusND, 12, 29, 0),
82+
0,
83+
)
84+
},
85+
},
5386
}
5487
)
5588

@@ -76,16 +109,19 @@ func (m *DiagnosticsMeasurement) ToPoint(p *data.Point) {
76109
p.SetMeasurementName(labelDiagnostics)
77110
copy := m.Timestamp
78111
p.SetTimestamp(&copy)
79-
112+
80113
p.AppendField(diagnosticsFields[0].Label, float64(m.Distributions[0].Get()))
81114
p.AppendField(diagnosticsFields[1].Label, float64(m.Distributions[1].Get()))
82115
p.AppendField(diagnosticsFields[2].Label, int64(m.Distributions[2].Get()))
116+
p.AppendField(diagnosticsFields[3].Label, float64(m.Distributions[3].Get()))
117+
p.AppendField(diagnosticsFields[4].Label, float64(m.Distributions[4].Get()))
118+
p.AppendField(diagnosticsFields[5].Label, float64(m.Distributions[5].Get()))
83119
}
84120

85121
// NewDiagnosticsMeasurement creates a DiagnosticsMeasurement with start time.
86122
func NewDiagnosticsMeasurement(start time.Time) *DiagnosticsMeasurement {
87123
sub := common.NewSubsystemMeasurementWithDistributionMakers(start, diagnosticsFields)
88-
124+
89125
return &DiagnosticsMeasurement{
90126
SubsystemMeasurement: sub,
91127
}

pkg/data/usecases/iot/readings.go

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package iot
22

33
import (
4-
"github.com/cnosdb/tsdb-comparisons/pkg/data"
5-
"github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common"
64
"math/rand"
75
"time"
6+
7+
"github.com/cnosdb/tsdb-comparisons/pkg/data"
8+
"github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common"
89
)
910

1011
const (
@@ -26,11 +27,12 @@ var (
2627
labelHeading = []byte("heading")
2728
labelGrade = []byte("grade")
2829
labelFuelConsumption = []byte("fuel_consumption")
29-
geoStepUD = common.UD(-0.005, 0.005)
30-
30+
31+
geoStepUD = common.UD(-0.005, 0.005)
32+
3133
bigUD = common.UD(-10, 10)
3234
smallUD = common.UD(-5, 5)
33-
35+
3436
readingsFields = []common.LabeledDistributionMaker{
3537
{
3638
Label: labelLatitude,
@@ -95,6 +97,33 @@ var (
9597
)
9698
},
9799
},
100+
{
101+
Label: labelLoadCapacity,
102+
DistributionMaker: func() common.Distribution {
103+
return common.FP(
104+
common.CWD(statusND, 1500, 5000, 0),
105+
0,
106+
)
107+
},
108+
},
109+
{
110+
Label: labelFuelCapacity,
111+
DistributionMaker: func() common.Distribution {
112+
return common.FP(
113+
common.CWD(statusND, 150, 300, 0),
114+
0,
115+
)
116+
},
117+
},
118+
{
119+
Label: labelNominalFuelConsumption,
120+
DistributionMaker: func() common.Distribution {
121+
return common.FP(
122+
common.CWD(statusND, 12, 29, 0),
123+
0,
124+
)
125+
},
126+
},
98127
}
99128
)
100129

@@ -108,7 +137,7 @@ func (m *ReadingsMeasurement) ToPoint(p *data.Point) {
108137
p.SetMeasurementName(labelReadings)
109138
copy := m.Timestamp
110139
p.SetTimestamp(&copy)
111-
140+
112141
for i, d := range m.Distributions {
113142
p.AppendField(readingsFields[i].Label, float64(d.Get()))
114143
}
@@ -117,7 +146,7 @@ func (m *ReadingsMeasurement) ToPoint(p *data.Point) {
117146
// NewReadingsMeasurement creates a new ReadingsMeasurement with start time.
118147
func NewReadingsMeasurement(start time.Time) *ReadingsMeasurement {
119148
sub := common.NewSubsystemMeasurementWithDistributionMakers(start, readingsFields)
120-
149+
121150
return &ReadingsMeasurement{
122151
SubsystemMeasurement: sub,
123152
}

pkg/data/usecases/iot/truck.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package iot
22

33
import (
44
"fmt"
5-
"github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common"
65
"math/rand"
76
"time"
7+
8+
"github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common"
89
)
910

1011
const (
@@ -27,7 +28,7 @@ var (
2728
"Seth",
2829
"Trish",
2930
}
30-
31+
3132
modelChoices = []model{
3233
{
3334
Name: "F-150",
@@ -48,14 +49,14 @@ var (
4849
FuelConsumption: 12,
4950
},
5051
}
51-
52+
5253
deviceVersionChoices = []string{
5354
"v1.0",
5455
"v1.5",
5556
"v2.0",
5657
"v2.3",
5758
}
58-
59+
5960
// FleetChoices contains all the fleet name values for the IoT use case
6061
FleetChoices = []string{
6162
"East",
@@ -103,22 +104,22 @@ func NewTruck(i int, start time.Time) common.Generator {
103104

104105
func newTruckWithMeasurementGenerator(i int, start time.Time, generator func(time.Time) []common.SimulatedMeasurement) Truck {
105106
sm := generator(start)
106-
107+
107108
m := modelChoices[rand.Intn(len(modelChoices))]
108-
109+
109110
h := Truck{
110111
tags: []common.Tag{
111112
{Key: []byte("name"), Value: fmt.Sprintf(truckNameFmt, i)},
112113
{Key: []byte("fleet"), Value: common.RandomStringSliceChoice(FleetChoices)},
113114
{Key: []byte("driver"), Value: common.RandomStringSliceChoice(driverChoices)},
114115
{Key: []byte("model"), Value: m.Name},
115116
{Key: []byte("device_version"), Value: common.RandomStringSliceChoice(deviceVersionChoices)},
116-
{Key: []byte("load_capacity"), Value: m.LoadCapacity},
117-
{Key: []byte("fuel_capacity"), Value: m.FuelCapacity},
118-
{Key: []byte("nominal_fuel_consumption"), Value: m.FuelConsumption},
117+
// {Key: []byte("load_capacity"), Value: m.LoadCapacity},
118+
// {Key: []byte("fuel_capacity"), Value: m.FuelCapacity},
119+
// {Key: []byte("nominal_fuel_consumption"), Value: m.FuelConsumption},
119120
},
120121
simulatedMeasurements: sm,
121122
}
122-
123+
123124
return h
124125
}

0 commit comments

Comments
 (0)