func _Value_OneofSizer(msg proto.Message) (n int) { m := msg.(*Value) // kind switch x := m.Kind.(type) { case *Value_NullValue: n += proto.SizeVarint(1<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.NullValue)) case *Value_NumberValue: n += proto.SizeVarint(2<<3 | proto.WireFixed64) n += 8 case *Value_StringValue: n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.StringValue))) n += len(x.StringValue) case *Value_BoolValue: n += proto.SizeVarint(4<<3 | proto.WireVarint) n += 1 case *Value_StructValue: s := proto.Size(x.StructValue) n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Value_ListValue: s := proto.Size(x.ListValue) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _Mutation_OneofSizer(msg proto.Message) (n int) { m := msg.(*Mutation) // operation switch x := m.Operation.(type) { case *Mutation_Insert: s := proto.Size(x.Insert) n += proto.SizeVarint(4<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Mutation_Update: s := proto.Size(x.Update) n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Mutation_Upsert: s := proto.Size(x.Upsert) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Mutation_Delete: s := proto.Size(x.Delete) n += proto.SizeVarint(7<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _Distribution_BucketOptions_OneofSizer(msg proto.Message) (n int) { m := msg.(*Distribution_BucketOptions) // options switch x := m.Options.(type) { case *Distribution_BucketOptions_LinearBuckets: s := proto.Size(x.LinearBuckets) n += proto.SizeVarint(1<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Distribution_BucketOptions_ExponentialBuckets: s := proto.Size(x.ExponentialBuckets) n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Distribution_BucketOptions_ExplicitBuckets: s := proto.Size(x.ExplicitBuckets) n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _Value_OneofSizer(msg proto.Message) (n int) { m := msg.(*Value) // value_type switch x := m.ValueType.(type) { case *Value_NullValue: n += proto.SizeVarint(11<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.NullValue)) case *Value_BooleanValue: n += proto.SizeVarint(1<<3 | proto.WireVarint) n += 1 case *Value_IntegerValue: n += proto.SizeVarint(2<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.IntegerValue)) case *Value_DoubleValue: n += proto.SizeVarint(3<<3 | proto.WireFixed64) n += 8 case *Value_TimestampValue: s := proto.Size(x.TimestampValue) n += proto.SizeVarint(10<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Value_KeyValue: s := proto.Size(x.KeyValue) n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Value_StringValue: n += proto.SizeVarint(17<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.StringValue))) n += len(x.StringValue) case *Value_BlobValue: n += proto.SizeVarint(18<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.BlobValue))) n += len(x.BlobValue) case *Value_GeoPointValue: s := proto.Size(x.GeoPointValue) n += proto.SizeVarint(8<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Value_EntityValue: s := proto.Size(x.EntityValue) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Value_ArrayValue: s := proto.Size(x.ArrayValue) n += proto.SizeVarint(9<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _HttpRule_OneofSizer(msg proto.Message) (n int) { m := msg.(*HttpRule) // pattern switch x := m.Pattern.(type) { case *HttpRule_Get: n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Get))) n += len(x.Get) case *HttpRule_Put: n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Put))) n += len(x.Put) case *HttpRule_Post: n += proto.SizeVarint(4<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Post))) n += len(x.Post) case *HttpRule_Delete: n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Delete))) n += len(x.Delete) case *HttpRule_Patch: n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Patch))) n += len(x.Patch) case *HttpRule_Custom: s := proto.Size(x.Custom) n += proto.SizeVarint(8<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _RowValue_OneofSizer(msg proto.Message) (n int) { m := msg.(*RowValue) // value switch x := m.Value.(type) { case *RowValue_Str: n += proto.SizeVarint(1<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Str))) n += len(x.Str) case *RowValue_Int: n += proto.SizeVarint(2<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.Int)) case *RowValue_Real: n += proto.SizeVarint(3<<3 | proto.WireFixed32) n += 4 case *RowValue_Date: n += proto.SizeVarint(4<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.Date)) case *RowValue_DateOfTime: n += proto.SizeVarint(5<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.DateOfTime)) case *RowValue_TimeOfDay: s := proto.Size(x.TimeOfDay) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func testSize(m interface { proto.Message Size() int }, desc string, expected int) ([]byte, error) { data, err := proto.Marshal(m) if err != nil { return nil, err } protoSize := proto.Size(m) mSize := m.Size() lenData := len(data) if protoSize != mSize || protoSize != lenData || mSize != lenData { return nil, fmt.Errorf("%s proto.Size(m){%d} != m.Size(){%d} != len(data){%d}", desc, protoSize, mSize, lenData) } if got := protoSize; got != expected { return nil, fmt.Errorf("%s proto.Size(m) got %d expected %d", desc, got, expected) } if got := mSize; got != expected { return nil, fmt.Errorf("%s m.Size() got %d expected %d", desc, got, expected) } if got := lenData; got != expected { return nil, fmt.Errorf("%s len(data) got %d expected %d", desc, got, expected) } return data, nil }
func _Communique_OneofSizer(msg proto.Message) (n int) { m := msg.(*Communique) // union switch x := m.Union.(type) { case *Communique_Number: n += proto.SizeVarint(5<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.Number)) case *Communique_Name: n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Name))) n += len(x.Name) case *Communique_Data: n += proto.SizeVarint(7<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Data))) n += len(x.Data) case *Communique_TempC: n += proto.SizeVarint(8<<3 | proto.WireFixed64) n += 8 case *Communique_Height: n += proto.SizeVarint(9<<3 | proto.WireFixed32) n += 4 case *Communique_Today: n += proto.SizeVarint(10<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.Today)) case *Communique_Maybe: n += proto.SizeVarint(11<<3 | proto.WireVarint) n += 1 case *Communique_Delta_: n += proto.SizeVarint(12<<3 | proto.WireVarint) n += proto.SizeVarint(uint64((uint32(x.Delta) << 1) ^ uint32((int32(x.Delta) >> 31)))) case *Communique_Msg: s := proto.Size(x.Msg) n += proto.SizeVarint(13<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Communique_Somegroup: n += proto.SizeVarint(14<<3 | proto.WireStartGroup) n += proto.Size(x.Somegroup) n += proto.SizeVarint(14<<3 | proto.WireEndGroup) case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _RunQueryRequest_OneofSizer(msg proto.Message) (n int) { m := msg.(*RunQueryRequest) // query_type switch x := m.QueryType.(type) { case *RunQueryRequest_Query: s := proto.Size(x.Query) n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *RunQueryRequest_GqlQuery: s := proto.Size(x.GqlQuery) n += proto.SizeVarint(7<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func TestRatchetState_SavedKeys_MessageKeySize(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedRatchetState_SavedKeys_MessageKey(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Fatalf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Fatalf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Fatalf("size %v != after marshal proto.Size %v", size, size3) } }
func _Filter_OneofSizer(msg proto.Message) (n int) { m := msg.(*Filter) // filter_type switch x := m.FilterType.(type) { case *Filter_CompositeFilter: s := proto.Size(x.CompositeFilter) n += proto.SizeVarint(1<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Filter_PropertyFilter: s := proto.Size(x.PropertyFilter) n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func TestClientToServer_DeliverEnvelopeSize(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedClientToServer_DeliverEnvelope(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Fatalf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Fatalf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Fatalf("size %v != after marshal proto.Size %v", size, size3) } }
func TestFloatingPointSize(t *testing.T) { popr := math_rand.New(math_rand.NewSource(time.Now().UnixNano())) p := NewPopulatedFloatingPoint(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) data, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Errorf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Errorf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Errorf("size %v != after marshal proto.Size %v", size, size3) } }
func TestOperation_ExpungeSize(t *testing18.T) { popr := math_rand18.New(math_rand18.NewSource(time18.Now().UnixNano())) p := NewPopulatedOperation_Expunge(popr, true) size2 := github_com_gogo_protobuf_proto10.Size(p) data, err := github_com_gogo_protobuf_proto10.Marshal(p) if err != nil { panic(err) } size := p.Size() if len(data) != size { t.Fatalf("size %v != marshalled size %v", size, len(data)) } if size2 != size { t.Fatalf("size %v != before marshal proto.Size %v", size, size2) } size3 := github_com_gogo_protobuf_proto10.Size(p) if size3 != size { t.Fatalf("size %v != after marshal proto.Size %v", size, size3) } }
func _Operation_OneofSizer(msg proto.Message) (n int) { m := msg.(*Operation) // result switch x := m.Result.(type) { case *Operation_Error: s := proto.Size(x.Error) n += proto.SizeVarint(4<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *Operation_Response: s := proto.Size(x.Response) n += proto.SizeVarint(5<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func TestAllMapsOrderedSize(t *testing.T) { seed := time.Now().UnixNano() popr := math_rand.New(math_rand.NewSource(seed)) p := NewPopulatedAllMapsOrdered(popr, true) size2 := github_com_gogo_protobuf_proto.Size(p) dAtA, err := github_com_gogo_protobuf_proto.Marshal(p) if err != nil { t.Fatalf("seed = %d, err = %v", seed, err) } size := p.Size() if len(dAtA) != size { t.Errorf("seed = %d, size %v != marshalled size %v", seed, size, len(dAtA)) } if size2 != size { t.Errorf("seed = %d, size %v != before marshal proto.Size %v", seed, size, size2) } size3 := github_com_gogo_protobuf_proto.Size(p) if size3 != size { t.Errorf("seed = %d, size %v != after marshal proto.Size %v", seed, size, size3) } }
func CreateHekaStream(msgBytes []byte, outBytes *[]byte, msc *message.MessageSigningConfig) error { msgSize := uint32(len(msgBytes)) if msgSize > message.MAX_MESSAGE_SIZE { return fmt.Errorf("Message too big, requires %d (MAX_MESSAGE_SIZE = %d)", len(msgBytes), message.MAX_MESSAGE_SIZE) } h := &message.Header{} h.SetMessageLength(msgSize) if msc != nil { h.SetHmacSigner(msc.Name) h.SetHmacKeyVersion(msc.Version) var hm hash.Hash switch msc.Hash { case "sha1": hm = hmac.New(sha1.New, []byte(msc.Key)) h.SetHmacHashFunction(message.Header_SHA1) default: hm = hmac.New(md5.New, []byte(msc.Key)) } hm.Write(msgBytes) h.SetHmac(hm.Sum(nil)) } headerSize := proto.Size(h) if headerSize > message.MAX_HEADER_SIZE { return fmt.Errorf("Message header too big, requires %d (MAX_HEADER_SIZE = %d)", headerSize, message.MAX_HEADER_SIZE) } requiredSize := message.HEADER_FRAMING_SIZE + headerSize + len(msgBytes) if cap(*outBytes) < requiredSize { *outBytes = make([]byte, requiredSize) } else { *outBytes = (*outBytes)[:requiredSize] } (*outBytes)[0] = message.RECORD_SEPARATOR (*outBytes)[1] = uint8(headerSize) // This looks odd but is correct; it effectively "seeks" the initial write // position for the protobuf output to be at the // `(*outBytes)[message.HEADER_DELIMITER_SIZE]` position. pbuf := proto.NewBuffer((*outBytes)[message.HEADER_DELIMITER_SIZE:message.HEADER_DELIMITER_SIZE]) if err := pbuf.Marshal(h); err != nil { return err } (*outBytes)[headerSize+message.HEADER_DELIMITER_SIZE] = message.UNIT_SEPARATOR copy((*outBytes)[message.HEADER_FRAMING_SIZE+headerSize:], msgBytes) return nil }
func _LogEntry_OneofSizer(msg proto.Message) (n int) { m := msg.(*LogEntry) // payload switch x := m.Payload.(type) { case *LogEntry_ProtoPayload: s := proto.Size(x.ProtoPayload) n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *LogEntry_TextPayload: n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.TextPayload))) n += len(x.TextPayload) case *LogEntry_JsonPayload: s := proto.Size(x.JsonPayload) n += proto.SizeVarint(6<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func _WatchRequest_OneofSizer(msg proto.Message) (n int) { m := msg.(*WatchRequest) // request_union switch x := m.RequestUnion.(type) { case *WatchRequest_CreateRequest: s := proto.Size(x.CreateRequest) n += proto.SizeVarint(1<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
//http://code.google.com/p/goprotobuf/issues/detail?id=40 func TestBugPackedProtoSize(t *testing.T) { n := &NinRepPackedNative{ Field4: []int64{172960727389894724, 2360337516664475010, 860833876131988189, 9068073014890763245, 7794843386260381831, 4023536436053141786, 8992311247496919020, 4330096163611305776, 4490411416244976467, 7873947349172707443, 2754969595834279669, 1360667855926938684, 4771480785172657389, 4875578924966668055, 8070579869808877481, 9128179594766551001, 4630419407064527516, 863844540220372892, 8208727650143073487, 7086117356301045838, 7779695211931506151, 5493835345187563535, 9119767633370806007, 9054342025895349248, 1887303228838508438, 7624573031734528281, 1874668389749611225, 3517684643468970593, 6677697606628877758, 7293473953189936168, 444475066704085538, 8594971141363049302, 1146643249094989673, 733393306232853371, 7721178528893916886, 7784452000911004429, 6436373110242711440, 6897422461738321237, 8772249155667732778, 6211871464311393541, 3061903718310406883, 7845488913176136641, 8342255034663902574, 3443058984649725748, 8410801047334832902, 7496541071517841153, 4305416923521577765, 7814967600020476457, 8671843803465481186, 3490266370361096855, 1447425664719091336, 653218597262334239, 8306243902880091940, 7851896059762409081, 5936760560798954978, 5755724498441478025, 7022701569985035966, 3707709584811468220, 529069456924666920, 7986469043681522462, 3092513330689518836, 5103541550470476202, 3577384161242626406, 3733428084624703294, 8388690542440473117, 3262468785346149388, 8788358556558007570, 5476276940198542020, 7277903243119461239, 5065861426928605020, 7533460976202697734, 1749213838654236956, 557497603941617931, 5496307611456481108, 6444547750062831720, 6992758776744205596, 7356719693428537399, 2896328872476734507, 381447079530132038, 598300737753233118, 3687980626612697715, 7240924191084283349, 8172414415307971170, 4847024388701257185, 2081764168600256551, 3394217778539123488, 6244660626429310923, 8301712215675381614, 5360615125359461174, 8410140945829785773, 3152963269026381373, 6197275282781459633, 4419829061407546410, 6262035523070047537, 2837207483933463885, 2158105736666826128, 8150764172235490711}, Field7: []int32{249451845, 1409974015, 393609128, 435232428, 1817529040, 91769006, 861170933, 1556185603, 1568580279, 1236375273, 512276621, 693633711, 967580535, 1950715977, 853431462, 1362390253, 159591204, 111900629, 322985263, 279671129, 1592548430, 465651370, 733849989, 1172059400, 1574824441, 263541092, 1271612397, 1520584358, 467078791, 117698716, 1098255064, 2054264846, 1766452305, 1267576395, 1557505617, 1187833560, 956187431, 1970977586, 1160235159, 1610259028, 489585797, 459139078, 566263183, 954319278, 1545018565, 1753946743, 948214318, 422878159, 883926576, 1424009347, 824732372, 1290433180, 80297942, 417294230, 1402647904, 2078392782, 220505045, 787368129, 463781454, 293083578, 808156928, 293976361}, Field9: []uint32{0xaa4976e8, 0x3da8cc4c, 0x8c470d83, 0x344d964e, 0x5b90925, 0xa4c4d34e, 0x666eff19, 0xc238e552, 0x9be53bb6, 0x56364245, 0x33ee079d, 0x96bf0ede, 0x7941b74f, 0xdb07cb47, 0x6d76d827, 0x9b211d5d, 0x2798adb6, 0xe48b0c3b, 0x87061b21, 0x48f4e4d2, 0x3e5d5c12, 0x5ee91288, 0x336d4f35, 0xe1d44941, 0xc065548d, 0x2953d73f, 0x873af451, 0xfc769db, 0x9f1bf8da, 0x9baafdfc, 0xf1d3d770, 0x5bb5d2b4, 0xc2c67c48, 0x6845c4c1, 0xa48f32b0, 0xbb04bb70, 0xa5b1ca36, 0x8d98356a, 0x2171f654, 0x5ae279b0, 0x6c4a3d6b, 0x4fff5468, 0xcf9bf851, 0x68513614, 0xdbecd9b0, 0x9553ed3c, 0xa494a736, 0x42205438, 0xbf8e5caa, 0xd3283c6, 0x76d20788, 0x9179826f, 0x96b24f85, 0xbc2eacf4, 0xe4afae0b, 0x4bca85cb, 0x35e63b5b, 0xd7ccee0c, 0x2b506bb9, 0xe78e9f44, 0x9ad232f1, 0x99a37335, 0xa5d6ffc8}, Field11: []uint64{0x53c01ebc, 0x4fb85ba6, 0x8805eea1, 0xb20ec896, 0x93b63410, 0xec7c9492, 0x50765a28, 0x19592106, 0x2ecc59b3, 0x39cd474f, 0xe4c9e47, 0x444f48c5, 0xe7731d32, 0xf3f43975, 0x603caedd, 0xbb05a1af, 0xa808e34e, 0x88580b07, 0x4c96bbd1, 0x730b4ab9, 0xed126e2b, 0x6db48205, 0x154ba1b9, 0xc26bfb6a, 0x389aa052, 0x869d966c, 0x7c86b366, 0xcc8edbcd, 0xfa8d6dad, 0xcf5857d9, 0x2d9cda0f, 0x1218a0b8, 0x41bf997, 0xf0ca65ac, 0xa610d4b9, 0x8d362e28, 0xb7212d87, 0x8e0fe109, 0xbee041d9, 0x759be2f6, 0x35fef4f3, 0xaeacdb71, 0x10888852, 0xf4e28117, 0xe2a14812, 0x73b748dc, 0xd1c3c6b2, 0xfef41bf0, 0xc9b43b62, 0x810e4faa, 0xcaa41c06, 0x1893fe0d, 0xedc7c850, 0xd12b9eaa, 0x467ee1a9, 0xbe84756b, 0xda7b1680, 0xdc069ffe, 0xf1e7e9f9, 0xb3d95370, 0xa92b77df, 0x5693ac41, 0xd04b7287, 0x27aebf15, 0x837b316e, 0x4dbe2263, 0xbab70c67, 0x547dab21, 0x3c346c1f, 0xb8ef0e4e, 0xfe2d03ce, 0xe1d75955, 0xfec1306, 0xba35c23e, 0xb784ed04, 0x2a4e33aa, 0x7e19d09a, 0x3827c1fe, 0xf3a51561, 0xef765e2b, 0xb044256c, 0x62b322be, 0xf34d56be, 0xeb71b369, 0xffe1294f, 0x237fe8d0, 0x77a1473b, 0x239e1196, 0xdd19bf3d, 0x82c91fe1, 0x95361c57, 0xffea3f1b, 0x1a094c84}, Field12: []int64{8308420747267165049, 3664160795077875961, 7868970059161834817, 7237335984251173739, 5254748003907196506, 3362259627111837480, 430460752854552122, 5119635556501066533, 1277716037866233522, 9185775384759813768, 833932430882717888, 7986528304451297640, 6792233378368656337, 2074207091120609721, 1788723326198279432, 7756514594746453657, 2283775964901597324, 3061497730110517191, 7733947890656120277, 626967303632386244, 7822928600388582821, 3489658753000061230, 168869995163005961, 248814782163480763, 477885608911386247, 4198422415674133867, 3379354662797976109, 9925112544736939, 1486335136459138480, 4561560414032850671, 1010864164014091267, 186722821683803084, 5106357936724819318, 1298160820191228988, 4675403242419953145, 7130634540106489752, 7101280006672440929, 7176058292431955718, 9109875054097770321, 6810974877085322872, 4736707874303993641, 8993135362721382187, 6857881554990254283, 3704748883307461680, 1099360832887634994, 5207691918707192633, 5984721695043995243}, } size := proto.Size(n) data, err := proto.Marshal(n) if err != nil { panic(err) } if len(data) != size { t.Fatalf("expected %v, but got %v diff is %v", len(data), size, len(data)-size) } }
func _GqlQueryParameter_OneofSizer(msg proto.Message) (n int) { m := msg.(*GqlQueryParameter) // parameter_type switch x := m.ParameterType.(type) { case *GqlQueryParameter_Value: s := proto.Size(x.Value) n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s case *GqlQueryParameter_Cursor: n += proto.SizeVarint(3<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(len(x.Cursor))) n += len(x.Cursor) case nil: default: panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) } return n }
func CreateHekaStream(msgBytes []byte, outBytes *[]byte) error { h := &message.Header{} h.SetMessageLength(uint32(len(msgBytes))) headerSize := proto.Size(h) requiredSize := message.HEADER_FRAMING_SIZE + headerSize + len(msgBytes) if cap(*outBytes) < requiredSize { *outBytes = make([]byte, requiredSize) } else { *outBytes = (*outBytes)[:requiredSize] } (*outBytes)[0] = message.RECORD_SEPARATOR (*outBytes)[1] = uint8(headerSize) pbuf := proto.NewBuffer((*outBytes)[message.HEADER_DELIMITER_SIZE:message.HEADER_DELIMITER_SIZE]) if err := pbuf.Marshal(h); err != nil { return err } (*outBytes)[headerSize+message.HEADER_DELIMITER_SIZE] = message.UNIT_SEPARATOR copy((*outBytes)[message.HEADER_FRAMING_SIZE+headerSize:], msgBytes) return nil }
func TestNilMaps(t *testing.T) { m := &AllMaps{StringToMsgMap: map[string]*FloatingPoint{"a": nil}} data, err := proto.Marshal(m) if err != nil { t.Fatal(err) } size := m.Size() protoSize := proto.Size(m) marshaledSize := len(data) if size != protoSize || marshaledSize != protoSize { t.Errorf("size %d != protoSize %d != marshaledSize %d", size, protoSize, marshaledSize) } m2 := &AllMaps{} if err := proto.Unmarshal(data, m2); err != nil { t.Fatal(err) } if v, ok := m2.StringToMsgMap["a"]; !ok { t.Error("element not in map") } else if v != nil { t.Errorf("element should be nil, but its %v", v) } }
func TestEmptyMapsBytes(t *testing.T) { m := &AllMaps{StringToBytesMap: map[string][]byte{"b": {}}} data, err := proto.Marshal(m) if err != nil { t.Fatal(err) } size := m.Size() protoSize := proto.Size(m) marshaledSize := len(data) if size != protoSize || marshaledSize != protoSize { t.Errorf("size %d != protoSize %d != marshaledSize %d", size, protoSize, marshaledSize) } m2 := &AllMaps{} if err := proto.Unmarshal(data, m2); err != nil { t.Fatal(err) } if v, ok := m2.StringToBytesMap["b"]; !ok { t.Error("element not in map") } else if len(v) != 0 { t.Errorf("element should be empty, but its %v", v) } }