From 684e26d21b64d6f80b2c7897432cf68d3808586d Mon Sep 17 00:00:00 2001
From: Pawan Rawal <pawan0201@gmail.com>
Date: Mon, 16 May 2016 08:30:32 +0530
Subject: [PATCH] Changing type of val in Properties to byte slice

---
 query/graph/graphresponse.pb.go | 71 ++++++++++++---------------------
 query/graph/graphresponse.proto |  6 +--
 query/query.go                  |  7 ++--
 query/query_test.go             | 10 ++---
 4 files changed, 35 insertions(+), 59 deletions(-)

diff --git a/query/graph/graphresponse.pb.go b/query/graph/graphresponse.pb.go
index c56d6df9..aae952c5 100644
--- a/query/graph/graphresponse.pb.go
+++ b/query/graph/graphresponse.pb.go
@@ -10,7 +10,6 @@ It is generated from these files:
 
 It has these top-level messages:
 	Request
-	Value
 	Latency
 	Property
 	Node
@@ -45,15 +44,6 @@ func (m *Request) String() string            { return proto.CompactTextString(m)
 func (*Request) ProtoMessage()               {}
 func (*Request) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
 
-type Value struct {
-	Str string `protobuf:"bytes,1,opt,name=str" json:"str,omitempty"`
-}
-
-func (m *Value) Reset()                    { *m = Value{} }
-func (m *Value) String() string            { return proto.CompactTextString(m) }
-func (*Value) ProtoMessage()               {}
-func (*Value) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
-
 type Latency struct {
 	Parsing    string `protobuf:"bytes,1,opt,name=parsing" json:"parsing,omitempty"`
 	Processing string `protobuf:"bytes,2,opt,name=processing" json:"processing,omitempty"`
@@ -63,24 +53,17 @@ type Latency struct {
 func (m *Latency) Reset()                    { *m = Latency{} }
 func (m *Latency) String() string            { return proto.CompactTextString(m) }
 func (*Latency) ProtoMessage()               {}
-func (*Latency) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
+func (*Latency) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
 
 type Property struct {
 	Prop string `protobuf:"bytes,1,opt,name=prop" json:"prop,omitempty"`
-	Val  *Value `protobuf:"bytes,2,opt,name=val" json:"val,omitempty"`
+	Val  []byte `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"`
 }
 
 func (m *Property) Reset()                    { *m = Property{} }
 func (m *Property) String() string            { return proto.CompactTextString(m) }
 func (*Property) ProtoMessage()               {}
-func (*Property) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
-
-func (m *Property) GetVal() *Value {
-	if m != nil {
-		return m.Val
-	}
-	return nil
-}
+func (*Property) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
 
 type Node struct {
 	Uid        uint64      `protobuf:"varint,1,opt,name=uid" json:"uid,omitempty"`
@@ -93,7 +76,7 @@ type Node struct {
 func (m *Node) Reset()                    { *m = Node{} }
 func (m *Node) String() string            { return proto.CompactTextString(m) }
 func (*Node) ProtoMessage()               {}
-func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
+func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
 
 func (m *Node) GetProperties() []*Property {
 	if m != nil {
@@ -117,7 +100,7 @@ type Response struct {
 func (m *Response) Reset()                    { *m = Response{} }
 func (m *Response) String() string            { return proto.CompactTextString(m) }
 func (*Response) ProtoMessage()               {}
-func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
+func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
 
 func (m *Response) GetN() *Node {
 	if m != nil {
@@ -135,7 +118,6 @@ func (m *Response) GetL() *Latency {
 
 func init() {
 	proto.RegisterType((*Request)(nil), "graph.Request")
-	proto.RegisterType((*Value)(nil), "graph.Value")
 	proto.RegisterType((*Latency)(nil), "graph.Latency")
 	proto.RegisterType((*Property)(nil), "graph.Property")
 	proto.RegisterType((*Node)(nil), "graph.Node")
@@ -214,26 +196,25 @@ var _DGraph_serviceDesc = grpc.ServiceDesc{
 }
 
 var fileDescriptor0 = []byte{
-	// 327 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 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, 0xb6, 0x95, 0x38, 0xb0, 0xe0,
+	0x15, 0x0c, 0x56, 0xdb, 0x62, 0xb7, 0x36, 0x52, 0x65, 0x29, 0xd9, 0x47, 0xd1, 0x1e, 0x1a, 0x89,
+	0xbd, 0xc8, 0x1f, 0x60, 0x20, 0xe2, 0x96, 0xf1, 0x14, 0x98, 0xa2, 0x96, 0x7f, 0xdc, 0x4c, 0xf9,
+	0x7a, 0xac, 0xf9, 0xdb, 0x68, 0x31, 0x8e, 0x52, 0x5c, 0xb1, 0x60, 0xbb, 0xc5, 0x3d, 0xf4, 0x1e,
+	0x9f, 0x02, 0x89, 0xd7, 0x90, 0xbe, 0x85, 0x1b, 0x60, 0xeb, 0x8a, 0x97, 0x3a, 0x9b, 0xec, 0xdf,
+	0x4d, 0x18, 0xff, 0xb7, 0xec, 0xd1, 0x55, 0xef, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x62, 0xcc,
+	0xa3, 0x13, 0xec, 0x01, 0x00, 0x00,
 }
diff --git a/query/graph/graphresponse.proto b/query/graph/graphresponse.proto
index 6f35f87f..225f4ae8 100644
--- a/query/graph/graphresponse.proto
+++ b/query/graph/graphresponse.proto
@@ -12,10 +12,6 @@ message Request {
   string query = 1;
 }
 
-message Value {
-  string str = 1;
-}
-
 message Latency {
   string parsing = 1;
   string processing = 2;
@@ -24,7 +20,7 @@ message Latency {
 
 message Property {
   string prop = 1;
-  Value val = 2;
+  bytes val = 2;
 }
 
 message Node {
diff --git a/query/query.go b/query/query.go
index 6eeaece7..30d5f9c3 100644
--- a/query/query.go
+++ b/query/query.go
@@ -323,7 +323,6 @@ func (g *SubGraph) preTraverse(uid uint64, dst *graph.Node) error {
 				children = append(children, uc)
 			}
 		} else {
-			v := new(graph.Value)
 			if ok := r.Values(&tv, idx); !ok {
 				return fmt.Errorf("While parsing value")
 			}
@@ -337,12 +336,12 @@ func (g *SubGraph) preTraverse(uid uint64, dst *graph.Node) error {
 				ival = ""
 			}
 
-			v.Str = ival.(string)
+			v := ival.(string)
 
 			if pc.Attr == "_xid_" {
-				dst.Xid = v.Str
+				dst.Xid = v
 			} else {
-				p := &graph.Property{Prop: pc.Attr, Val: v}
+				p := &graph.Property{Prop: pc.Attr, Val: []byte(v)}
 				properties = append(properties, p)
 			}
 
diff --git a/query/query_test.go b/query/query_test.go
index 2ddbf7eb..9805a7c3 100644
--- a/query/query_test.go
+++ b/query/query_test.go
@@ -326,7 +326,7 @@ func TestToJson(t *testing.T) {
 	fmt.Printf(string(js))
 }
 
-func getProperty(properties []*graph.Property, prop string) *graph.Value {
+func getProperty(properties []*graph.Property, prop string) []byte {
 	for _, p := range properties {
 		if p.Prop == prop {
 			return p.Val
@@ -390,9 +390,9 @@ func TestToPB(t *testing.T) {
 		t.Errorf("Expected values map to contain 3 properties, Got: %v",
 			len(gr.Properties))
 	}
-	if getProperty(gr.Properties, "name").Str != "Michonne" {
+	if string(getProperty(gr.Properties, "name")) != "Michonne" {
 		t.Errorf("Expected property name to have value Michonne, Got: %v",
-			getProperty(gr.Properties, "name").Str)
+			string(getProperty(gr.Properties, "name")))
 	}
 	if len(gr.Children) != 10 {
 		t.Errorf("Expected 10 children, Got: %v", len(gr.Children))
@@ -409,9 +409,9 @@ func TestToPB(t *testing.T) {
 		t.Errorf("Expected values map to contain 1 property, Got: %v",
 			len(child.Properties))
 	}
-	if getProperty(child.Properties, "name").Str != "Rick Grimes" {
+	if string(getProperty(child.Properties, "name")) != "Rick Grimes" {
 		t.Errorf("Expected property name to have value Rick Grimes, Got: %v",
-			getProperty(child.Properties, "name").Str)
+			string(getProperty(child.Properties, "name")))
 	}
 	if len(child.Children) != 0 {
 		t.Errorf("Expected 0 children, Got: %v", len(child.Children))
-- 
GitLab