diff --git a/pkg/logs/sender/grpc/inflight.go b/pkg/logs/sender/grpc/inflight.go index d44413dd970b..fffff9dd0c6e 100644 --- a/pkg/logs/sender/grpc/inflight.go +++ b/pkg/logs/sender/grpc/inflight.go @@ -630,6 +630,9 @@ func (t *inflightTracker) addMissingFlatLogReferences(missing stateReferences, k } t.addMissingJsonSchemaReference(missing, known, log.JsonSchemaId) t.addMissingDynamicValueReferences(missing, known, log.JsonContextValues) + for _, dictID := range log.JsonContextDictValues { + t.addMissingDictEntryReference(missing, known, dictID) + } } func (t *inflightTracker) addMissingDeltaEncodingSyncReferences(missing stateReferences, known stateReferences, sync *statefulpb.DeltaEncodingSync) { @@ -784,6 +787,9 @@ func addFlatLogReferences(refs stateReferences, log *statefulpb.FlatLog) { } addFlatLogJsonSchemaReference(refs, log.JsonSchemaId) addDynamicValueReferences(refs, log.JsonContextValues) + for _, dictID := range log.JsonContextDictValues { + refs.addDictEntry(dictID) + } } func addDeltaEncodingSyncReferences(refs stateReferences, sync *statefulpb.DeltaEncodingSync) { diff --git a/pkg/logs/sender/grpc/mock_state.go b/pkg/logs/sender/grpc/mock_state.go index be66ee034bc3..b776e365502a 100644 --- a/pkg/logs/sender/grpc/mock_state.go +++ b/pkg/logs/sender/grpc/mock_state.go @@ -70,6 +70,21 @@ const ( defaultTokenizeBatchSize = 20 ) +const ( + jsonValueKindNull byte = iota + jsonValueKindInt + jsonValueKindFloat + jsonValueKindBoolFalse + jsonValueKindBoolTrue + jsonValueKindString + jsonValueKindDict + jsonValueKindRaw + jsonValueKindIntAsString + jsonValueKindFloatAsString + jsonValueKindBoolFalseAsString + jsonValueKindBoolTrueAsString +) + // dvTypeBackings holds the three oneof wrapper types for a single DynamicValue in one // contiguous allocation. Each wildcard position uses exactly one of the three fields; // grouping them avoids three separate heap allocations per wildcard position. @@ -82,6 +97,20 @@ type dvTypeBackings struct { stringOneof statefulpb.DynamicValue_StringValue } +type compactJSONContextValues struct { + kinds []byte + ints []int64 + floats []float64 + dicts []uint64 + rawValues [][]byte + stringValues []string +} + +type dictEntryDefinition struct { + id uint64 + value string +} + type tagCacheEntry struct { origin *message.Origin hostname string @@ -471,30 +500,19 @@ func (mt *MessageTranslator) processPreTokenized(msg *message.Message, tokenList var messageKeyDV *statefulpb.DynamicValue var jsonContextSchemaID uint64 var jsonContextValuesDV []*statefulpb.DynamicValue + var compactJSONContext compactJSONContextValues if len(jsonContextKeys) > 0 { messageKeyDV, jsonContextSchemaID = mt.sendJsonSchemaDefineIfNeeded(outputChan, msg, messageKey, jsonContextKeys) - jsonContextDVBacking := make([]statefulpb.DynamicValue, len(jsonContextValues)) - jsonContextTypeBacking := make([]dvTypeBackings, len(jsonContextValues)) - jsonContextValuesDV = make([]*statefulpb.DynamicValue, len(jsonContextValues)) - for i := range jsonContextDVBacking { - jsonContextValuesDV[i] = &jsonContextDVBacking[i] - } - for i, val := range jsonContextValues { - dictID, dictValue, isNew := mt.fillDynamicValue( - &jsonContextDVBacking[i], - &jsonContextTypeBacking[i].intOneof, - &jsonContextTypeBacking[i].floatOneof, - &jsonContextTypeBacking[i].boolOneof, - &jsonContextTypeBacking[i].dictOneof, - &jsonContextTypeBacking[i].rawJSONOneof, - &jsonContextTypeBacking[i].stringOneof, - val, - ) - if isNew { - mt.sendDictEntryDefine(outputChan, msg, dictID, dictValue) - } + var dictDefs []dictEntryDefinition + compactJSONContext, dictDefs = mt.compactJSONContextValues(jsonContextValues) + for _, dictDef := range dictDefs { + mt.sendDictEntryDefine(outputChan, msg, dictDef.id, dictDef.value) } + + // Keep the legacy field empty for FlatLog. Consumers that do not understand the compact + // streams should ignore the json schema when json_context_values is absent. + jsonContextValuesDV = nil } service, serviceDictID, serviceIsNew := mt.buildServiceField(msg) @@ -515,7 +533,7 @@ func (mt *MessageTranslator) processPreTokenized(msg *message.Message, tokenList // Send StructuredLog with all fields tsMillis := ts.UnixNano() / nanoToMillis - mt.sendStructuredLog(outputChan, msg, tsMillis, patternID, dynamicValues, tagSet, service, statusDictID, messageKeyDV, jsonContextSchemaID, jsonContextValuesDV) + mt.sendStructuredLog(outputChan, msg, tsMillis, patternID, dynamicValues, tagSet, service, statusDictID, messageKeyDV, jsonContextSchemaID, jsonContextValuesDV, compactJSONContext) } // buildTagSet constructs the complete tag list for a message and encodes it as a TagSet. @@ -881,8 +899,8 @@ func (mt *MessageTranslator) sendRawLog(outputChan chan *message.StatefulMessage } // sendStructuredLog creates and sends a StructuredLog datum -func (mt *MessageTranslator) sendStructuredLog(outputChan chan *message.StatefulMessage, msg *message.Message, timestamp int64, patternID uint64, dynamicValues []*statefulpb.DynamicValue, tagSet *statefulpb.TagSet, service *statefulpb.DynamicValue, statusDictID uint64, messageKey *statefulpb.DynamicValue, jsonContextSchemaID uint64, jsonContextValues []*statefulpb.DynamicValue) { - logDatum := buildStructuredLog(timestamp, patternID, dynamicValues, tagSet, msg.MessageMetadata.DualSendUUID, service, statusDictID, messageKey, jsonContextSchemaID, jsonContextValues) +func (mt *MessageTranslator) sendStructuredLog(outputChan chan *message.StatefulMessage, msg *message.Message, timestamp int64, patternID uint64, dynamicValues []*statefulpb.DynamicValue, tagSet *statefulpb.TagSet, service *statefulpb.DynamicValue, statusDictID uint64, messageKey *statefulpb.DynamicValue, jsonContextSchemaID uint64, jsonContextValues []*statefulpb.DynamicValue, compactJSONContext compactJSONContextValues) { + logDatum := buildStructuredLog(timestamp, patternID, dynamicValues, tagSet, msg.MessageMetadata.DualSendUUID, service, statusDictID, messageKey, jsonContextSchemaID, jsonContextValues, compactJSONContext) tlmPipelinePatternLogsProcessed.Inc(mt.pipelineName) tlmPipelinePatternLogsProcessedBytes.Add(float64(proto.Size(logDatum)), mt.pipelineName) @@ -1123,6 +1141,103 @@ func (mt *MessageTranslator) fillDynamicValue( } } +func (mt *MessageTranslator) compactJSONContextValues(values []interface{}) (compactJSONContextValues, []dictEntryDefinition) { + compact := compactJSONContextValues{kinds: make([]byte, 0, len(values))} + dictDefs := make([]dictEntryDefinition, 0) + for _, value := range values { + dictID, dictValue, isNew := mt.appendCompactJSONContextValue(&compact, value) + if isNew { + dictDefs = append(dictDefs, dictEntryDefinition{id: dictID, value: dictValue}) + } + } + return compact, dictDefs +} + +func (mt *MessageTranslator) appendCompactJSONContextValue(compact *compactJSONContextValues, value interface{}) (dictID uint64, dictValue string, isNew bool) { + switch typed := value.(type) { + case nil: + compact.kinds = append(compact.kinds, jsonValueKindNull) + return 0, "", false + case string: + return mt.appendCompactJSONString(compact, typed) + case json.Number: + return appendCompactJSONNumber(compact, typed.String()) + case float64: + if !math.IsInf(typed, 0) && !math.IsNaN(typed) && math.Trunc(typed) == typed && typed >= math.MinInt64 && typed <= math.MaxInt64 { + compact.kinds = append(compact.kinds, jsonValueKindInt) + compact.ints = append(compact.ints, int64(typed)) + return 0, "", false + } + compact.kinds = append(compact.kinds, jsonValueKindFloat) + compact.floats = append(compact.floats, typed) + return 0, "", false + case bool: + if typed { + compact.kinds = append(compact.kinds, jsonValueKindBoolTrue) + } else { + compact.kinds = append(compact.kinds, jsonValueKindBoolFalse) + } + return 0, "", false + default: + rawJSON, err := json.Marshal(typed) + if err != nil { + log.Warnf("Failed to marshal nested JSON context value: %v", err) + compact.kinds = append(compact.kinds, jsonValueKindString) + compact.stringValues = append(compact.stringValues, "") + return 0, "", false + } + compact.kinds = append(compact.kinds, jsonValueKindRaw) + compact.rawValues = append(compact.rawValues, rawJSON) + return 0, "", false + } +} + +func (mt *MessageTranslator) appendCompactJSONString(compact *compactJSONContextValues, value string) (dictID uint64, dictValue string, isNew bool) { + if intVal, ok := parseLosslessIntString(value); ok { + compact.kinds = append(compact.kinds, jsonValueKindIntAsString) + compact.ints = append(compact.ints, intVal) + return 0, "", false + } + if floatVal, ok := parseLosslessFloatString(value); ok { + compact.kinds = append(compact.kinds, jsonValueKindFloatAsString) + compact.floats = append(compact.floats, floatVal) + return 0, "", false + } + if boolVal, ok := parseLosslessBoolString(value); ok { + if boolVal { + compact.kinds = append(compact.kinds, jsonValueKindBoolTrueAsString) + } else { + compact.kinds = append(compact.kinds, jsonValueKindBoolFalseAsString) + } + return 0, "", false + } + value = toValidUTF8(value) + if dictID, isNew, shouldEncode := mt.tagManager.ObserveDynamicString(value); shouldEncode { + compact.kinds = append(compact.kinds, jsonValueKindDict) + compact.dicts = append(compact.dicts, dictID) + return dictID, value, isNew + } + compact.kinds = append(compact.kinds, jsonValueKindString) + compact.stringValues = append(compact.stringValues, value) + return 0, "", false +} + +func appendCompactJSONNumber(compact *compactJSONContextValues, raw string) (dictID uint64, dictValue string, isNew bool) { + if intVal, ok := parseLosslessIntString(raw); ok { + compact.kinds = append(compact.kinds, jsonValueKindInt) + compact.ints = append(compact.ints, intVal) + return 0, "", false + } + if floatVal, ok := parseLosslessFloatString(raw); ok { + compact.kinds = append(compact.kinds, jsonValueKindFloat) + compact.floats = append(compact.floats, floatVal) + return 0, "", false + } + compact.kinds = append(compact.kinds, jsonValueKindRaw) + compact.rawValues = append(compact.rawValues, []byte(raw)) + return 0, "", false +} + func (mt *MessageTranslator) fillWildcardDynamicValue( dv *statefulpb.DynamicValue, oneofInt *statefulpb.DynamicValue_IntValue, @@ -1167,7 +1282,7 @@ func flatLogDynamicValueDictIndex(value *statefulpb.DynamicValue) uint64 { } // buildStructuredLog creates a Datum containing a FlatLog with pattern references. -func buildStructuredLog(timestamp int64, patternID uint64, dynamicValues []*statefulpb.DynamicValue, tagSet *statefulpb.TagSet, uuid string, service *statefulpb.DynamicValue, statusDictID uint64, messageKey *statefulpb.DynamicValue, jsonContextSchemaID uint64, jsonContextValues []*statefulpb.DynamicValue) *statefulpb.Datum { +func buildStructuredLog(timestamp int64, patternID uint64, dynamicValues []*statefulpb.DynamicValue, tagSet *statefulpb.TagSet, uuid string, service *statefulpb.DynamicValue, statusDictID uint64, messageKey *statefulpb.DynamicValue, jsonContextSchemaID uint64, jsonContextValues []*statefulpb.DynamicValue, compactJSONContext compactJSONContextValues) *statefulpb.Datum { _ = messageKey log := &statefulpb.FlatLog{ Timestamp: timestamp, @@ -1175,10 +1290,16 @@ func buildStructuredLog(timestamp int64, patternID uint64, dynamicValues []*stat Service: flatLogDictIndex(flatLogDynamicValueDictIndex(service)), Tags: flatLogDictIndex(flatLogTagSetDictIndex(tagSet)), - PatternId: patternID, - DynamicValues: dynamicValues, - JsonSchemaId: flatLogDictIndex(jsonContextSchemaID), - JsonContextValues: jsonContextValues, + PatternId: patternID, + DynamicValues: dynamicValues, + JsonSchemaId: flatLogDictIndex(jsonContextSchemaID), + JsonContextValues: jsonContextValues, + JsonContextValueKinds: compactJSONContext.kinds, + JsonContextIntValues: compactJSONContext.ints, + JsonContextFloatValues: compactJSONContext.floats, + JsonContextDictValues: compactJSONContext.dicts, + JsonContextRawValues: compactJSONContext.rawValues, + JsonContextStringValues: compactJSONContext.stringValues, } if uuid != "" { log.Uuid = &uuid diff --git a/pkg/logs/sender/grpc/mock_state_cache_test.go b/pkg/logs/sender/grpc/mock_state_cache_test.go index c7da1ad8fbc4..cf4b83e4b6ab 100644 --- a/pkg/logs/sender/grpc/mock_state_cache_test.go +++ b/pkg/logs/sender/grpc/mock_state_cache_test.go @@ -125,7 +125,7 @@ func TestBuildStructuredLogUsesFlatLog(t *testing.T) { Value: &statefulpb.DynamicValue_StringValue{StringValue: "value"}, }} - datum := buildStructuredLog(123, 12, values, tagSet, "uuid", service, 2, nil, 5, nil) + datum := buildStructuredLog(123, 12, values, tagSet, "uuid", service, 2, nil, 5, nil, compactJSONContextValues{}) require.Nil(t, datum.GetLogs()) flatLog := datum.GetFlatLog() diff --git a/pkg/proto/datadog/stateful/stateful_encoding.proto b/pkg/proto/datadog/stateful/stateful_encoding.proto index 3a4484c1dba6..2fabd773f9e3 100644 --- a/pkg/proto/datadog/stateful/stateful_encoding.proto +++ b/pkg/proto/datadog/stateful/stateful_encoding.proto @@ -70,8 +70,17 @@ message FlatLog { // Delta encoded json_schema_id: when 0 use last json_schema_id. Otherwise use json_schema_id in this dict entry. // Use 1 to indicate no json_schema_id. uint64 json_schema_id = 8; - // Values for the json schema. + // Deprecated fallback values for the json schema. repeated DynamicValue json_context_values = 9; + // Compact values for the json schema. json_context_value_kinds has one byte per schema key. + // Each kind consumes the next value from the corresponding packed value field. + // Kind values are defined by the JsonValueKind constants in the encoder/decoder. + bytes json_context_value_kinds = 10; + repeated int64 json_context_int_values = 11; + repeated double json_context_float_values = 12; + repeated uint64 json_context_dict_values = 13; + repeated bytes json_context_raw_values = 14; + repeated string json_context_string_values = 15; // Optional UUID used to track logs when dual-sent via HTTP and gRPC. optional string uuid = 100; diff --git a/pkg/proto/pbgo/statefulpb/stateful_encoding.pb.go b/pkg/proto/pbgo/statefulpb/stateful_encoding.pb.go index 8af139717591..a54a13e3cbe1 100644 --- a/pkg/proto/pbgo/statefulpb/stateful_encoding.pb.go +++ b/pkg/proto/pbgo/statefulpb/stateful_encoding.pb.go @@ -396,8 +396,17 @@ type FlatLog struct { // Delta encoded json_schema_id: when 0 use last json_schema_id. Otherwise use json_schema_id in this dict entry. // Use 1 to indicate no json_schema_id. JsonSchemaId uint64 `protobuf:"varint,8,opt,name=json_schema_id,json=jsonSchemaId,proto3" json:"json_schema_id,omitempty"` - // Values for the json schema. + // Deprecated fallback values for the json schema. JsonContextValues []*DynamicValue `protobuf:"bytes,9,rep,name=json_context_values,json=jsonContextValues,proto3" json:"json_context_values,omitempty"` + // Compact values for the json schema. json_context_value_kinds has one byte per schema key. + // Each kind consumes the next value from the corresponding packed value field. + // Kind values are defined by the JsonValueKind constants in the encoder/decoder. + JsonContextValueKinds []byte `protobuf:"bytes,10,opt,name=json_context_value_kinds,json=jsonContextValueKinds,proto3" json:"json_context_value_kinds,omitempty"` + JsonContextIntValues []int64 `protobuf:"varint,11,rep,packed,name=json_context_int_values,json=jsonContextIntValues,proto3" json:"json_context_int_values,omitempty"` + JsonContextFloatValues []float64 `protobuf:"fixed64,12,rep,packed,name=json_context_float_values,json=jsonContextFloatValues,proto3" json:"json_context_float_values,omitempty"` + JsonContextDictValues []uint64 `protobuf:"varint,13,rep,packed,name=json_context_dict_values,json=jsonContextDictValues,proto3" json:"json_context_dict_values,omitempty"` + JsonContextRawValues [][]byte `protobuf:"bytes,14,rep,name=json_context_raw_values,json=jsonContextRawValues,proto3" json:"json_context_raw_values,omitempty"` + JsonContextStringValues []string `protobuf:"bytes,15,rep,name=json_context_string_values,json=jsonContextStringValues,proto3" json:"json_context_string_values,omitempty"` // Optional UUID used to track logs when dual-sent via HTTP and gRPC. Uuid *string `protobuf:"bytes,100,opt,name=uuid,proto3,oneof" json:"uuid,omitempty"` unknownFields protoimpl.UnknownFields @@ -497,6 +506,48 @@ func (x *FlatLog) GetJsonContextValues() []*DynamicValue { return nil } +func (x *FlatLog) GetJsonContextValueKinds() []byte { + if x != nil { + return x.JsonContextValueKinds + } + return nil +} + +func (x *FlatLog) GetJsonContextIntValues() []int64 { + if x != nil { + return x.JsonContextIntValues + } + return nil +} + +func (x *FlatLog) GetJsonContextFloatValues() []float64 { + if x != nil { + return x.JsonContextFloatValues + } + return nil +} + +func (x *FlatLog) GetJsonContextDictValues() []uint64 { + if x != nil { + return x.JsonContextDictValues + } + return nil +} + +func (x *FlatLog) GetJsonContextRawValues() [][]byte { + if x != nil { + return x.JsonContextRawValues + } + return nil +} + +func (x *FlatLog) GetJsonContextStringValues() []string { + if x != nil { + return x.JsonContextStringValues + } + return nil +} + func (x *FlatLog) GetUuid() string { if x != nil && x.Uuid != nil { return *x.Uuid @@ -1455,7 +1506,7 @@ const file_datadog_stateful_stateful_encoding_proto_rawDesc = "" + "\x06tagset\x18\x01 \x01(\v2%.datadog.intake.stateful.DynamicValueR\x06tagset\"{\n" + "\x03Tag\x127\n" + "\x03key\x18\x01 \x01(\v2%.datadog.intake.stateful.DynamicValueR\x03key\x12;\n" + - "\x05value\x18\x02 \x01(\v2%.datadog.intake.stateful.DynamicValueR\x05value\"\x92\x03\n" + + "\x05value\x18\x02 \x01(\v2%.datadog.intake.stateful.DynamicValueR\x05value\"\xea\x05\n" + "\aFlatLog\x12\x1c\n" + "\ttimestamp\x18\x01 \x01(\x12R\ttimestamp\x12\x16\n" + "\x06status\x18\x02 \x01(\x04R\x06status\x12\x18\n" + @@ -1466,7 +1517,14 @@ const file_datadog_stateful_stateful_encoding_proto_rawDesc = "" + "\x0edynamic_values\x18\x06 \x03(\v2%.datadog.intake.stateful.DynamicValueR\rdynamicValues\x12\x17\n" + "\araw_log\x18\a \x01(\tR\x06rawLog\x12$\n" + "\x0ejson_schema_id\x18\b \x01(\x04R\fjsonSchemaId\x12U\n" + - "\x13json_context_values\x18\t \x03(\v2%.datadog.intake.stateful.DynamicValueR\x11jsonContextValues\x12\x17\n" + + "\x13json_context_values\x18\t \x03(\v2%.datadog.intake.stateful.DynamicValueR\x11jsonContextValues\x127\n" + + "\x18json_context_value_kinds\x18\n" + + " \x01(\fR\x15jsonContextValueKinds\x125\n" + + "\x17json_context_int_values\x18\v \x03(\x03R\x14jsonContextIntValues\x129\n" + + "\x19json_context_float_values\x18\f \x03(\x01R\x16jsonContextFloatValues\x127\n" + + "\x18json_context_dict_values\x18\r \x03(\x04R\x15jsonContextDictValues\x125\n" + + "\x17json_context_raw_values\x18\x0e \x03(\fR\x14jsonContextRawValues\x12;\n" + + "\x1ajson_context_string_values\x18\x0f \x03(\tR\x17jsonContextStringValues\x12\x17\n" + "\x04uuid\x18d \x01(\tH\x00R\x04uuid\x88\x01\x01B\a\n" + "\x05_uuid\"\xe3\x02\n" + "\x03Log\x12\x1c\n" + diff --git a/pkg/proto/pbgo/statefulpb/stateful_encoding_vtproto.pb.go b/pkg/proto/pbgo/statefulpb/stateful_encoding_vtproto.pb.go index a3bbb1cd1df6..320a2935a24c 100644 --- a/pkg/proto/pbgo/statefulpb/stateful_encoding_vtproto.pb.go +++ b/pkg/proto/pbgo/statefulpb/stateful_encoding_vtproto.pb.go @@ -346,6 +346,82 @@ func (m *FlatLog) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i-- dAtA[i] = 0xa2 } + if len(m.JsonContextStringValues) > 0 { + for iNdEx := len(m.JsonContextStringValues) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.JsonContextStringValues[iNdEx]) + copy(dAtA[i:], m.JsonContextStringValues[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.JsonContextStringValues[iNdEx]))) + i-- + dAtA[i] = 0x7a + } + } + if len(m.JsonContextRawValues) > 0 { + for iNdEx := len(m.JsonContextRawValues) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.JsonContextRawValues[iNdEx]) + copy(dAtA[i:], m.JsonContextRawValues[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.JsonContextRawValues[iNdEx]))) + i-- + dAtA[i] = 0x72 + } + } + if len(m.JsonContextDictValues) > 0 { + var pksize2 int + for _, num := range m.JsonContextDictValues { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num := range m.JsonContextDictValues { + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x6a + } + if len(m.JsonContextFloatValues) > 0 { + for iNdEx := len(m.JsonContextFloatValues) - 1; iNdEx >= 0; iNdEx-- { + f3 := math.Float64bits(float64(m.JsonContextFloatValues[iNdEx])) + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(f3)) + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.JsonContextFloatValues)*8)) + i-- + dAtA[i] = 0x62 + } + if len(m.JsonContextIntValues) > 0 { + var pksize5 int + for _, num := range m.JsonContextIntValues { + pksize5 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize5 + j4 := i + for _, num1 := range m.JsonContextIntValues { + num := uint64(num1) + for num >= 1<<7 { + dAtA[j4] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j4++ + } + dAtA[j4] = uint8(num) + j4++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize5)) + i-- + dAtA[i] = 0x5a + } + if len(m.JsonContextValueKinds) > 0 { + i -= len(m.JsonContextValueKinds) + copy(dAtA[i:], m.JsonContextValueKinds) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.JsonContextValueKinds))) + i-- + dAtA[i] = 0x52 + } if len(m.JsonContextValues) > 0 { for iNdEx := len(m.JsonContextValues) - 1; iNdEx >= 0; iNdEx-- { size, err := m.JsonContextValues[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) @@ -1447,6 +1523,39 @@ func (m *FlatLog) SizeVT() (n int) { n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } } + l = len(m.JsonContextValueKinds) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.JsonContextIntValues) > 0 { + l = 0 + for _, e := range m.JsonContextIntValues { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if len(m.JsonContextFloatValues) > 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(len(m.JsonContextFloatValues)*8)) + len(m.JsonContextFloatValues)*8 + } + if len(m.JsonContextDictValues) > 0 { + l = 0 + for _, e := range m.JsonContextDictValues { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if len(m.JsonContextRawValues) > 0 { + for _, b := range m.JsonContextRawValues { + l = len(b) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if len(m.JsonContextStringValues) > 0 { + for _, s := range m.JsonContextStringValues { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } if m.Uuid != nil { l = len(*m.Uuid) n += 2 + l + protohelpers.SizeOfVarint(uint64(l)) @@ -2769,6 +2878,310 @@ func (m *FlatLog) UnmarshalVT(dAtA []byte) error { return err } iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextValueKinds", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.JsonContextValueKinds = append(m.JsonContextValueKinds[:0], dAtA[iNdEx:postIndex]...) + if m.JsonContextValueKinds == nil { + m.JsonContextValueKinds = []byte{} + } + iNdEx = postIndex + case 11: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.JsonContextIntValues = append(m.JsonContextIntValues, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.JsonContextIntValues) == 0 { + m.JsonContextIntValues = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.JsonContextIntValues = append(m.JsonContextIntValues, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextIntValues", wireType) + } + case 12: + if wireType == 1 { + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + v2 := float64(math.Float64frombits(v)) + m.JsonContextFloatValues = append(m.JsonContextFloatValues, v2) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + elementCount = packedLen / 8 + if elementCount != 0 && len(m.JsonContextFloatValues) == 0 { + m.JsonContextFloatValues = make([]float64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + v2 := float64(math.Float64frombits(v)) + m.JsonContextFloatValues = append(m.JsonContextFloatValues, v2) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextFloatValues", wireType) + } + case 13: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.JsonContextDictValues = append(m.JsonContextDictValues, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.JsonContextDictValues) == 0 { + m.JsonContextDictValues = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.JsonContextDictValues = append(m.JsonContextDictValues, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextDictValues", wireType) + } + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextRawValues", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.JsonContextRawValues = append(m.JsonContextRawValues, make([]byte, postIndex-iNdEx)) + copy(m.JsonContextRawValues[len(m.JsonContextRawValues)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JsonContextStringValues", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.JsonContextStringValues = append(m.JsonContextStringValues, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex case 100: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType)