|
|
@@ -1,18 +1,19 @@
|
|
|
-// //////////////////////////////////////////////////////////////////////////////
|
|
|
+////////////////////////////////////////////////////////////////////////////////
|
|
|
//
|
|
|
-// DO NOT MODIFY
|
|
|
+// DO NOT MODIFY
|
|
|
//
|
|
|
-// ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
|
|
|
+// ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
|
|
|
//
|
|
|
//
|
|
|
-// This source file was automatically generated by bingen.
|
|
|
+// This source file was automatically generated by bingen.
|
|
|
//
|
|
|
-// //////////////////////////////////////////////////////////////////////////////
|
|
|
-// TODO This file was infact modified due to an issue with including aliased string types from 'shared'
|
|
|
+////////////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
package pricingmodel
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "github.com/opencost/opencost/core/pkg/model/shared"
|
|
|
"io"
|
|
|
"iter"
|
|
|
"os"
|
|
|
@@ -22,23 +23,17 @@ import (
|
|
|
"time"
|
|
|
"unsafe"
|
|
|
|
|
|
- "github.com/opencost/opencost/core/pkg/model/shared"
|
|
|
- "github.com/opencost/opencost/core/pkg/util"
|
|
|
+ util "github.com/opencost/opencost/core/pkg/util"
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
// GeneratorPackageName is the package the generator is targetting
|
|
|
GeneratorPackageName string = "pricingmodel"
|
|
|
-)
|
|
|
|
|
|
-// BinaryTags represent the formatting tag used for specific optimization features
|
|
|
-const (
|
|
|
// BinaryTagStringTable is written and/or read prior to the existence of a string
|
|
|
// table (where each index is encoded as a string entry in the resource
|
|
|
BinaryTagStringTable string = "BGST"
|
|
|
-)
|
|
|
|
|
|
-const (
|
|
|
// DefaultCodecVersion is used for any resources listed in the Default version set
|
|
|
DefaultCodecVersion uint8 = 1
|
|
|
)
|
|
|
@@ -104,8 +99,7 @@ func BingenFileBackedStringTableDir() string {
|
|
|
// Type Map
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
-// Generated type map for resolving interface implementations to
|
|
|
-// to concrete types
|
|
|
+// Generated type map for resolving interface implementations to to concrete types
|
|
|
var typeMap map[string]reflect.Type = map[string]reflect.Type{
|
|
|
"NodeKey": reflect.TypeFor[NodeKey](),
|
|
|
"NodePricing": reflect.TypeFor[NodePricing](),
|
|
|
@@ -197,7 +191,9 @@ type StreamFactoryFunc func(io.Reader) BingenStream
|
|
|
|
|
|
// Generated streamable factory map for finding the specific new stream methods
|
|
|
// by T type
|
|
|
-var streamFactoryMap map[reflect.Type]StreamFactoryFunc = map[reflect.Type]StreamFactoryFunc{}
|
|
|
+var streamFactoryMap map[reflect.Type]StreamFactoryFunc = map[reflect.Type]StreamFactoryFunc{
|
|
|
+ reflect.TypeFor[PricingModelSet](): NewPricingModelSetStream,
|
|
|
+}
|
|
|
|
|
|
// NewStreamFor accepts an io.Reader, and returns a new BingenStream for the generic T
|
|
|
// type provided _if_ it is a registered bingen type that is annotated as 'streamable'. See
|
|
|
@@ -350,7 +346,7 @@ type StringTableReader interface {
|
|
|
|
|
|
// SliceStringTableReader is a basic pre-loaded []string that provides index-based access.
|
|
|
// The cost of this implementation is holding all strings in memory, which provides faster
|
|
|
-// lookup performance for memory usage.
|
|
|
+// lookup performance at the expense of memory usage.
|
|
|
type SliceStringTableReader struct {
|
|
|
table []string
|
|
|
}
|
|
|
@@ -653,9 +649,9 @@ func (target *NodeKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -664,30 +660,36 @@ func (target *NodeKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error
|
|
|
buff.WriteUInt8(DefaultCodecVersion) // version
|
|
|
|
|
|
// --- [begin][write][alias](shared.Provider) ---
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
a := ctx.Table.AddOrGet(string(target.Provider))
|
|
|
buff.WriteInt(a) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(string(target.Provider)) // write string
|
|
|
}
|
|
|
+
|
|
|
// --- [end][write][alias](shared.Provider) ---
|
|
|
|
|
|
// --- [begin][write][alias](NodePricingType) ---
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
b := ctx.Table.AddOrGet(string(target.PricingType))
|
|
|
buff.WriteInt(b) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(string(target.PricingType)) // write string
|
|
|
}
|
|
|
+
|
|
|
// --- [end][write][alias](NodePricingType) ---
|
|
|
|
|
|
// --- [begin][write][alias](shared.UsageType) ---
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
c := ctx.Table.AddOrGet(string(target.UsageType))
|
|
|
buff.WriteInt(c) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(string(target.UsageType)) // write string
|
|
|
}
|
|
|
+
|
|
|
// --- [end][write][alias](shared.UsageType) ---
|
|
|
|
|
|
if ctx.IsStringTable() {
|
|
|
@@ -696,24 +698,28 @@ func (target *NodeKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error
|
|
|
} else {
|
|
|
buff.WriteString(target.Region) // write string
|
|
|
}
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
e := ctx.Table.AddOrGet(target.NodeType)
|
|
|
buff.WriteInt(e) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(target.NodeType) // write string
|
|
|
}
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
f := ctx.Table.AddOrGet(target.Family)
|
|
|
buff.WriteInt(f) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(target.Family) // write string
|
|
|
}
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
g := ctx.Table.AddOrGet(target.DeviceType)
|
|
|
buff.WriteInt(g) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(target.DeviceType) // write string
|
|
|
}
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -722,6 +728,7 @@ func (target *NodeKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error
|
|
|
func (target *NodeKey) UnmarshalBinary(data []byte) error {
|
|
|
ctx := NewDecodingContextFromBytes(data)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -735,6 +742,7 @@ func (target *NodeKey) UnmarshalBinary(data []byte) error {
|
|
|
func (target *NodeKey) UnmarshalBinaryFromReader(reader io.Reader) error {
|
|
|
ctx := NewDecodingContextFromReader(reader)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -752,9 +760,9 @@ func (target *NodeKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err err
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -763,85 +771,93 @@ func (target *NodeKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err err
|
|
|
version := buff.ReadUInt8()
|
|
|
|
|
|
if version > DefaultCodecVersion {
|
|
|
- return fmt.Errorf("Invalid Version Unmarshaling NodeKey. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
+ return fmt.Errorf("Invalid Version Unmarshalling NodeKey. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
}
|
|
|
|
|
|
// --- [begin][read][alias](shared.Provider) ---
|
|
|
var a string
|
|
|
+ var c string
|
|
|
if ctx.IsStringTable() {
|
|
|
- b := buff.ReadInt() // read string index
|
|
|
- a = ctx.Table.At(b)
|
|
|
+ d := buff.ReadInt() // read string index
|
|
|
+ c = ctx.Table.At(d)
|
|
|
} else {
|
|
|
- a = buff.ReadString() // read string
|
|
|
+ c = buff.ReadString() // read string
|
|
|
}
|
|
|
+ b := c
|
|
|
+ a = b
|
|
|
+
|
|
|
target.Provider = shared.Provider(a)
|
|
|
// --- [end][read][alias](shared.Provider) ---
|
|
|
|
|
|
// --- [begin][read][alias](NodePricingType) ---
|
|
|
- var d string
|
|
|
- var f string
|
|
|
+ var e string
|
|
|
+ var g string
|
|
|
if ctx.IsStringTable() {
|
|
|
- g := buff.ReadInt() // read string index
|
|
|
- f = ctx.Table.At(g)
|
|
|
+ h := buff.ReadInt() // read string index
|
|
|
+ g = ctx.Table.At(h)
|
|
|
} else {
|
|
|
- f = buff.ReadString() // read string
|
|
|
+ g = buff.ReadString() // read string
|
|
|
}
|
|
|
- e := f
|
|
|
- d = e
|
|
|
+ f := g
|
|
|
+ e = f
|
|
|
|
|
|
- target.PricingType = NodePricingType(d)
|
|
|
+ target.PricingType = NodePricingType(e)
|
|
|
// --- [end][read][alias](NodePricingType) ---
|
|
|
|
|
|
// --- [begin][read][alias](shared.UsageType) ---
|
|
|
- var h string
|
|
|
+ var l string
|
|
|
+ var n string
|
|
|
if ctx.IsStringTable() {
|
|
|
- l := buff.ReadInt() // read string index
|
|
|
- h = ctx.Table.At(l)
|
|
|
+ o := buff.ReadInt() // read string index
|
|
|
+ n = ctx.Table.At(o)
|
|
|
} else {
|
|
|
- h = buff.ReadString() // read string
|
|
|
+ n = buff.ReadString() // read string
|
|
|
}
|
|
|
- target.UsageType = shared.UsageType(h)
|
|
|
+ m := n
|
|
|
+ l = m
|
|
|
+
|
|
|
+ target.UsageType = shared.UsageType(l)
|
|
|
// --- [end][read][alias](shared.UsageType) ---
|
|
|
|
|
|
- var o string
|
|
|
+ var q string
|
|
|
if ctx.IsStringTable() {
|
|
|
- p := buff.ReadInt() // read string index
|
|
|
- o = ctx.Table.At(p)
|
|
|
+ r := buff.ReadInt() // read string index
|
|
|
+ q = ctx.Table.At(r)
|
|
|
} else {
|
|
|
- o = buff.ReadString() // read string
|
|
|
+ q = buff.ReadString() // read string
|
|
|
}
|
|
|
- n := o
|
|
|
- target.Region = n
|
|
|
+ p := q
|
|
|
+ target.Region = p
|
|
|
|
|
|
- var r string
|
|
|
+ var t string
|
|
|
if ctx.IsStringTable() {
|
|
|
- s := buff.ReadInt() // read string index
|
|
|
- r = ctx.Table.At(s)
|
|
|
+ u := buff.ReadInt() // read string index
|
|
|
+ t = ctx.Table.At(u)
|
|
|
} else {
|
|
|
- r = buff.ReadString() // read string
|
|
|
+ t = buff.ReadString() // read string
|
|
|
}
|
|
|
- q := r
|
|
|
- target.NodeType = q
|
|
|
+ s := t
|
|
|
+ target.NodeType = s
|
|
|
|
|
|
- var u string
|
|
|
+ var x string
|
|
|
if ctx.IsStringTable() {
|
|
|
- w := buff.ReadInt() // read string index
|
|
|
- u = ctx.Table.At(w)
|
|
|
+ y := buff.ReadInt() // read string index
|
|
|
+ x = ctx.Table.At(y)
|
|
|
} else {
|
|
|
- u = buff.ReadString() // read string
|
|
|
+ x = buff.ReadString() // read string
|
|
|
}
|
|
|
- t := u
|
|
|
- target.Family = t
|
|
|
+ w := x
|
|
|
+ target.Family = w
|
|
|
|
|
|
- var y string
|
|
|
+ var bb string
|
|
|
if ctx.IsStringTable() {
|
|
|
- aa := buff.ReadInt() // read string index
|
|
|
- y = ctx.Table.At(aa)
|
|
|
+ cc := buff.ReadInt() // read string index
|
|
|
+ bb = ctx.Table.At(cc)
|
|
|
} else {
|
|
|
- y = buff.ReadString() // read string
|
|
|
+ bb = buff.ReadString() // read string
|
|
|
}
|
|
|
- x := y
|
|
|
- target.DeviceType = x
|
|
|
+ aa := bb
|
|
|
+ target.DeviceType = aa
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
@@ -876,9 +892,9 @@ func (target *NodePricing) MarshalBinaryWithContext(ctx *EncodingContext) (err e
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -887,6 +903,7 @@ func (target *NodePricing) MarshalBinaryWithContext(ctx *EncodingContext) (err e
|
|
|
buff.WriteUInt8(DefaultCodecVersion) // version
|
|
|
|
|
|
buff.WriteFloat64(target.HourlyRate) // write float64
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -895,6 +912,7 @@ func (target *NodePricing) MarshalBinaryWithContext(ctx *EncodingContext) (err e
|
|
|
func (target *NodePricing) UnmarshalBinary(data []byte) error {
|
|
|
ctx := NewDecodingContextFromBytes(data)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -908,6 +926,7 @@ func (target *NodePricing) UnmarshalBinary(data []byte) error {
|
|
|
func (target *NodePricing) UnmarshalBinaryFromReader(reader io.Reader) error {
|
|
|
ctx := NewDecodingContextFromReader(reader)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -925,9 +944,9 @@ func (target *NodePricing) UnmarshalBinaryWithContext(ctx *DecodingContext) (err
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -936,7 +955,7 @@ func (target *NodePricing) UnmarshalBinaryWithContext(ctx *DecodingContext) (err
|
|
|
version := buff.ReadUInt8()
|
|
|
|
|
|
if version > DefaultCodecVersion {
|
|
|
- return fmt.Errorf("Invalid Version Unmarshaling NodePricing. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
+ return fmt.Errorf("Invalid Version Unmarshalling NodePricing. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
}
|
|
|
|
|
|
a := buff.ReadFloat64() // read float64
|
|
|
@@ -954,7 +973,7 @@ func (target *NodePricing) UnmarshalBinaryWithContext(ctx *DecodingContext) (err
|
|
|
func (target *PricingModelSet) MarshalBinary() (data []byte, err error) {
|
|
|
ctx := &EncodingContext{
|
|
|
Buffer: util.NewBuffer(),
|
|
|
- Table: nil,
|
|
|
+ Table: NewStringTableWriter(),
|
|
|
}
|
|
|
|
|
|
e := target.MarshalBinaryWithContext(ctx)
|
|
|
@@ -963,7 +982,9 @@ func (target *PricingModelSet) MarshalBinary() (data []byte, err error) {
|
|
|
}
|
|
|
|
|
|
encBytes := ctx.Buffer.Bytes()
|
|
|
- return encBytes, nil
|
|
|
+ sTableBytes := ctx.Table.ToBytes()
|
|
|
+ merged := appendBytes(sTableBytes, encBytes)
|
|
|
+ return merged, nil
|
|
|
}
|
|
|
|
|
|
// MarshalBinaryWithContext serializes the internal properties of this PricingModelSet instance
|
|
|
@@ -975,9 +996,9 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -995,12 +1016,14 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
// --- [end][write][reference](time.Time) ---
|
|
|
|
|
|
// --- [begin][write][alias](PricingSourceType) ---
|
|
|
+
|
|
|
if ctx.IsStringTable() {
|
|
|
b := ctx.Table.AddOrGet(string(target.SourceType))
|
|
|
buff.WriteInt(b) // write table index
|
|
|
} else {
|
|
|
buff.WriteString(string(target.SourceType)) // write string
|
|
|
}
|
|
|
+
|
|
|
// --- [end][write][alias](PricingSourceType) ---
|
|
|
|
|
|
if ctx.IsStringTable() {
|
|
|
@@ -1009,6 +1032,7 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
} else {
|
|
|
buff.WriteString(target.SourceKey) // write string
|
|
|
}
|
|
|
+
|
|
|
if target.NodePricing == nil {
|
|
|
buff.WriteUInt8(uint8(0)) // write nil byte
|
|
|
} else {
|
|
|
@@ -1017,6 +1041,7 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
// --- [begin][write][map](map[NodeKey]NodePricing) ---
|
|
|
buff.WriteInt(len(target.NodePricing)) // map length
|
|
|
for v, z := range target.NodePricing {
|
|
|
+
|
|
|
// --- [begin][write][struct](NodeKey) ---
|
|
|
buff.WriteInt(0) // [compatibility, unused]
|
|
|
errB := v.MarshalBinaryWithContext(ctx)
|
|
|
@@ -1037,6 +1062,7 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
// --- [end][write][map](map[NodeKey]NodePricing) ---
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
@@ -1045,6 +1071,7 @@ func (target *PricingModelSet) MarshalBinaryWithContext(ctx *EncodingContext) (e
|
|
|
func (target *PricingModelSet) UnmarshalBinary(data []byte) error {
|
|
|
ctx := NewDecodingContextFromBytes(data)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -1058,6 +1085,7 @@ func (target *PricingModelSet) UnmarshalBinary(data []byte) error {
|
|
|
func (target *PricingModelSet) UnmarshalBinaryFromReader(reader io.Reader) error {
|
|
|
ctx := NewDecodingContextFromReader(reader)
|
|
|
defer ctx.Close()
|
|
|
+
|
|
|
err := target.UnmarshalBinaryWithContext(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -1075,9 +1103,9 @@ func (target *PricingModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext)
|
|
|
if e, ok := r.(error); ok {
|
|
|
err = e
|
|
|
} else if s, ok := r.(string); ok {
|
|
|
- err = fmt.Errorf("Unexpected panic: %s", s)
|
|
|
+ err = fmt.Errorf("unexpected panic: %s", s)
|
|
|
} else {
|
|
|
- err = fmt.Errorf("Unexpected panic: %+v", r)
|
|
|
+ err = fmt.Errorf("unexpected panic: %+v", r)
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
@@ -1086,13 +1114,13 @@ func (target *PricingModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext)
|
|
|
version := buff.ReadUInt8()
|
|
|
|
|
|
if version > DefaultCodecVersion {
|
|
|
- return fmt.Errorf("Invalid Version Unmarshaling PricingModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
+ return fmt.Errorf("Invalid Version Unmarshalling PricingModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
}
|
|
|
|
|
|
// --- [begin][read][reference](time.Time) ---
|
|
|
- a := &time.Time{}
|
|
|
- b := buff.ReadInt() // byte array length
|
|
|
- c := buff.ReadBytes(b) // byte array
|
|
|
+ a := new(time.Time)
|
|
|
+ b := buff.ReadInt() // byte array length
|
|
|
+ c := buff.ReadBytes(b)
|
|
|
errA := a.UnmarshalBinary(c)
|
|
|
if errA != nil {
|
|
|
return errA
|
|
|
@@ -1131,9 +1159,10 @@ func (target *PricingModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext)
|
|
|
// --- [begin][read][map](map[NodeKey]NodePricing) ---
|
|
|
o := buff.ReadInt() // map len
|
|
|
n := make(map[NodeKey]NodePricing, o)
|
|
|
- for i := 0; i < o; i++ {
|
|
|
+ for range o {
|
|
|
+
|
|
|
// --- [begin][read][struct](NodeKey) ---
|
|
|
- p := &NodeKey{}
|
|
|
+ p := new(NodeKey)
|
|
|
buff.ReadInt() // [compatibility, unused]
|
|
|
errB := p.UnmarshalBinaryWithContext(ctx)
|
|
|
if errB != nil {
|
|
|
@@ -1143,7 +1172,7 @@ func (target *PricingModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext)
|
|
|
// --- [end][read][struct](NodeKey) ---
|
|
|
|
|
|
// --- [begin][read][struct](NodePricing) ---
|
|
|
- q := &NodePricing{}
|
|
|
+ q := new(NodePricing)
|
|
|
buff.ReadInt() // [compatibility, unused]
|
|
|
errC := q.UnmarshalBinaryWithContext(ctx)
|
|
|
if errC != nil {
|
|
|
@@ -1158,5 +1187,168 @@ func (target *PricingModelSet) UnmarshalBinaryWithContext(ctx *DecodingContext)
|
|
|
// --- [end][read][map](map[NodeKey]NodePricing) ---
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+//--------------------------------------------------------------------------
|
|
|
+// PricingModelSetStream
|
|
|
+//--------------------------------------------------------------------------
|
|
|
+
|
|
|
+// PricingModelSetStream is a single use field stream for the contents of an PricingModelSet instance. Instead of creating an instance and populating
|
|
|
+// the fields on that instance, we provide a streaming iterator which yields (BingenFieldInfo, *BingenValue) tuples for each
|
|
|
+// streamable element. All slices and maps will be flattened one depth and each element streamed individually.
|
|
|
+type PricingModelSetStream struct {
|
|
|
+ reader io.Reader
|
|
|
+ ctx *DecodingContext
|
|
|
+ err error
|
|
|
+}
|
|
|
+
|
|
|
+// Closes closes the internal io.Reader used to read and parse the PricingModelSet fields.
|
|
|
+// This should be called once the stream is no longer needed.
|
|
|
+func (stream *PricingModelSetStream) Close() {
|
|
|
+ if closer, ok := stream.reader.(io.Closer); ok {
|
|
|
+ closer.Close()
|
|
|
+ }
|
|
|
+ stream.ctx.Close()
|
|
|
+}
|
|
|
+
|
|
|
+// Error returns an error if one occurred during the process of streaming the PricingModelSet
|
|
|
+// This can be checked after iterating through the Stream().
|
|
|
+func (stream *PricingModelSetStream) Error() error {
|
|
|
+ return stream.err
|
|
|
+}
|
|
|
+
|
|
|
+// NewPricingModelSetStream creates a new PricingModelSetStream, which uses the io.Reader data to stream all internal fields of an PricingModelSet instance
|
|
|
+func NewPricingModelSetStream(reader io.Reader) BingenStream {
|
|
|
+ ctx := NewDecodingContextFromReader(reader)
|
|
|
+
|
|
|
+ return &PricingModelSetStream{
|
|
|
+ ctx: ctx,
|
|
|
+ reader: reader,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Stream returns the iterator which will stream each field of the target type.
|
|
|
+func (stream *PricingModelSetStream) Stream() iter.Seq2[BingenFieldInfo, *BingenValue] {
|
|
|
+ return func(yield func(BingenFieldInfo, *BingenValue) bool) {
|
|
|
+ var fi BingenFieldInfo
|
|
|
+
|
|
|
+ ctx := stream.ctx
|
|
|
+ buff := ctx.Buffer
|
|
|
+ version := buff.ReadUInt8()
|
|
|
+
|
|
|
+ if version > DefaultCodecVersion {
|
|
|
+ stream.err = fmt.Errorf("Invalid Version Unmarshalling PricingModelSet. Expected %d or less, got %d", DefaultCodecVersion, version)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fi = BingenFieldInfo{
|
|
|
+ Type: reflect.TypeFor[time.Time](),
|
|
|
+ Name: "TimeStamp",
|
|
|
+ }
|
|
|
+
|
|
|
+ // --- [begin][read][reference](time.Time) ---
|
|
|
+ b := new(time.Time)
|
|
|
+ c := buff.ReadInt() // byte array length
|
|
|
+ d := buff.ReadBytes(c)
|
|
|
+ errA := b.UnmarshalBinary(d)
|
|
|
+ if errA != nil {
|
|
|
+ stream.err = errA
|
|
|
+ return
|
|
|
+
|
|
|
+ }
|
|
|
+ a := *b
|
|
|
+ // --- [end][read][reference](time.Time) ---
|
|
|
+ if !yield(fi, singleV(a)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fi = BingenFieldInfo{
|
|
|
+ Type: reflect.TypeFor[PricingSourceType](),
|
|
|
+ Name: "SourceType",
|
|
|
+ }
|
|
|
+ // --- [begin][read][streaming-alias](PricingSourceType) ---
|
|
|
+
|
|
|
+ var e string
|
|
|
+ var g string
|
|
|
+ if ctx.IsStringTable() {
|
|
|
+ h := buff.ReadInt() // read string index
|
|
|
+ g = ctx.Table.At(h)
|
|
|
+ } else {
|
|
|
+ g = buff.ReadString() // read string
|
|
|
+ }
|
|
|
+ f := g
|
|
|
+ e = f
|
|
|
+
|
|
|
+ if !yield(fi, singleV(PricingSourceType(e))) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // --- [end][read][streaming-alias](PricingSourceType) ---
|
|
|
+
|
|
|
+ fi = BingenFieldInfo{
|
|
|
+ Type: reflect.TypeFor[string](),
|
|
|
+ Name: "SourceKey",
|
|
|
+ }
|
|
|
+
|
|
|
+ var l string
|
|
|
+ var n string
|
|
|
+ if ctx.IsStringTable() {
|
|
|
+ o := buff.ReadInt() // read string index
|
|
|
+ n = ctx.Table.At(o)
|
|
|
+ } else {
|
|
|
+ n = buff.ReadString() // read string
|
|
|
+ }
|
|
|
+ m := n
|
|
|
+ l = m
|
|
|
+ if !yield(fi, singleV(l)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fi = BingenFieldInfo{
|
|
|
+ Type: reflect.TypeFor[map[NodeKey]NodePricing](),
|
|
|
+ Name: "NodePricing",
|
|
|
+ }
|
|
|
+ if buff.ReadUInt8() == uint8(0) {
|
|
|
+ if !yield(fi, nil) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // --- [begin][read][streaming-map](map[NodeKey]NodePricing) ---
|
|
|
+ p := buff.ReadInt() // map len
|
|
|
+ for range p {
|
|
|
+
|
|
|
+ // --- [begin][read][struct](NodeKey) ---
|
|
|
+ q := new(NodeKey)
|
|
|
+ buff.ReadInt() // [compatibility, unused]
|
|
|
+ errB := q.UnmarshalBinaryWithContext(ctx)
|
|
|
+ if errB != nil {
|
|
|
+ stream.err = errB
|
|
|
+ return
|
|
|
+
|
|
|
+ }
|
|
|
+ v := *q
|
|
|
+ // --- [end][read][struct](NodeKey) ---
|
|
|
+
|
|
|
+ // --- [begin][read][struct](NodePricing) ---
|
|
|
+ r := new(NodePricing)
|
|
|
+ buff.ReadInt() // [compatibility, unused]
|
|
|
+ errC := r.UnmarshalBinaryWithContext(ctx)
|
|
|
+ if errC != nil {
|
|
|
+ stream.err = errC
|
|
|
+ return
|
|
|
+
|
|
|
+ }
|
|
|
+ z := *r
|
|
|
+ // --- [end][read][struct](NodePricing) ---
|
|
|
+
|
|
|
+ if !yield(fi, pairV(v, z)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // --- [end][read][streaming-map](map[NodeKey]NodePricing) ---
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|