From e25e61ae4de62e126e74a7187e6314fc6c9cdd02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF=20?= =?UTF-8?q?=E0=AE=9C=E0=AE=BF=E0=AE=A9=E0=AF=8D=E0=AE=A9=E0=AE=BE?= Date: Fri, 20 Sep 2019 01:33:35 -0700 Subject: [PATCH 01/10] add metrics for attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி ஜின்னா --- query/outputnode.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/query/outputnode.go b/query/outputnode.go index 88c4837621d..7660555e3e4 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -41,6 +41,7 @@ import ( // ToJson converts the list of subgraph into a JSON response by calling toFastJSON. func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error) { sgr := &SubGraph{} + metricsMap := map[string]int{} for _, sg := range sgl { if sg.Params.Alias == "var" || sg.Params.Alias == "shortest" { continue @@ -48,8 +49,11 @@ func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error) { if sg.Params.GetUid { sgr.Params.GetUid = true } + // calculate metrics for this query. + calculateMetrics(sg, metricsMap) sgr.Children = append(sgr.Children, sg) } + fmt.Println(metricsMap) return sgr.toFastJSON(l) } @@ -810,3 +814,32 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { return nil } + +// calculateMetrics populates the given map with the number of uids are gathered for each +// attributes. +func calculateMetrics(sg *SubGraph, metricsMap map[string]int) { + // we'll calcuate only destination because this are the uid gathered by this subgraph. + // srcUid is given by parent graph so we don't take that in account. But here we may miss + // some results, because if any filters applied those uids are gone. + updateMetricsMap := func(sg *SubGraph) { + prev := metricsMap[sg.Attr] + // QUESTION: @manish @pawan: should I add destuid or length of posting list?. + prev = prev + len(sg.DestUIDs.GetUids()) + // DestUIDs will be zero if there is any value matrix so including that + // as well. + for _, valList := range sg.valueMatrix { + prev = prev + len(valList.GetValues()) + } + metricsMap[sg.Attr] = prev + } + updateMetricsMap(sg) + + // add all the uids gathered by filters + for _, filter := range sg.Filters { + updateMetricsMap(filter) + } + // calculate metrics for the childres as well. + for _, child := range sg.Children { + calculateMetrics(child, metricsMap) + } +} From 382e9648de074f0188261c37452962c5966d8643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF=20?= =?UTF-8?q?=E0=AE=9C=E0=AE=BF=E0=AE=A9=E0=AF=8D=E0=AE=A9=E0=AE=BE?= Date: Fri, 20 Sep 2019 06:46:17 -0700 Subject: [PATCH 02/10] call recursively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி ஜின்னா --- query/outputnode.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/query/outputnode.go b/query/outputnode.go index 7660555e3e4..b3a0fca4684 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -817,29 +817,26 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { // calculateMetrics populates the given map with the number of uids are gathered for each // attributes. -func calculateMetrics(sg *SubGraph, metricsMap map[string]int) { +func calculateMetrics(sg *SubGraph, metrics map[string]int) { // we'll calcuate only destination because this are the uid gathered by this subgraph. // srcUid is given by parent graph so we don't take that in account. But here we may miss // some results, because if any filters applied those uids are gone. - updateMetricsMap := func(sg *SubGraph) { - prev := metricsMap[sg.Attr] - // QUESTION: @manish @pawan: should I add destuid or length of posting list?. - prev = prev + len(sg.DestUIDs.GetUids()) - // DestUIDs will be zero if there is any value matrix so including that - // as well. - for _, valList := range sg.valueMatrix { - prev = prev + len(valList.GetValues()) - } - metricsMap[sg.Attr] = prev + prev := metrics[sg.Attr] + // QUESTION: @manish @pawan: should I add destuid or length of posting list?. + prev = prev + len(sg.DestUIDs.GetUids()) + // DestUIDs will be zero if there is any value matrix so including that + // as well. + for _, valList := range sg.valueMatrix { + prev = prev + len(valList.GetValues()) } - updateMetricsMap(sg) + metrics[sg.Attr] = prev // add all the uids gathered by filters for _, filter := range sg.Filters { - updateMetricsMap(filter) + calculateMetrics(filter, metrics) } // calculate metrics for the childres as well. for _, child := range sg.Children { - calculateMetrics(child, metricsMap) + calculateMetrics(child, metrics) } } From 0a8c19d80a243d933ef9eb130109d946781cea32 Mon Sep 17 00:00:00 2001 From: balaji jinnah Date: Thu, 10 Oct 2019 21:46:36 +0530 Subject: [PATCH 03/10] change destuid to src uid Signed-off-by: balaji jinnah --- query/outputnode.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/query/outputnode.go b/query/outputnode.go index b3a0fca4684..c602137c462 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -818,17 +818,11 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { // calculateMetrics populates the given map with the number of uids are gathered for each // attributes. func calculateMetrics(sg *SubGraph, metrics map[string]int) { - // we'll calcuate only destination because this are the uid gathered by this subgraph. - // srcUid is given by parent graph so we don't take that in account. But here we may miss - // some results, because if any filters applied those uids are gone. + // we'll calculate srcUid of the each attribute. because, these are number of uids + // processed by this attribute. prev := metrics[sg.Attr] // QUESTION: @manish @pawan: should I add destuid or length of posting list?. - prev = prev + len(sg.DestUIDs.GetUids()) - // DestUIDs will be zero if there is any value matrix so including that - // as well. - for _, valList := range sg.valueMatrix { - prev = prev + len(valList.GetValues()) - } + prev = prev + len(sg.SrcUIDs.GetUids()) metrics[sg.Attr] = prev // add all the uids gathered by filters From fefda147ff13b300ab15ea7380c31c60199b6a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Mon, 14 Oct 2019 16:55:46 +0530 Subject: [PATCH 04/10] moved to execution result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- query/outputnode.go | 24 ------------------------ query/query.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/query/outputnode.go b/query/outputnode.go index c602137c462..88c4837621d 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -41,7 +41,6 @@ import ( // ToJson converts the list of subgraph into a JSON response by calling toFastJSON. func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error) { sgr := &SubGraph{} - metricsMap := map[string]int{} for _, sg := range sgl { if sg.Params.Alias == "var" || sg.Params.Alias == "shortest" { continue @@ -49,11 +48,8 @@ func ToJson(l *Latency, sgl []*SubGraph) ([]byte, error) { if sg.Params.GetUid { sgr.Params.GetUid = true } - // calculate metrics for this query. - calculateMetrics(sg, metricsMap) sgr.Children = append(sgr.Children, sg) } - fmt.Println(metricsMap) return sgr.toFastJSON(l) } @@ -814,23 +810,3 @@ func (sg *SubGraph) preTraverse(uid uint64, dst outputNode) error { return nil } - -// calculateMetrics populates the given map with the number of uids are gathered for each -// attributes. -func calculateMetrics(sg *SubGraph, metrics map[string]int) { - // we'll calculate srcUid of the each attribute. because, these are number of uids - // processed by this attribute. - prev := metrics[sg.Attr] - // QUESTION: @manish @pawan: should I add destuid or length of posting list?. - prev = prev + len(sg.SrcUIDs.GetUids()) - metrics[sg.Attr] = prev - - // add all the uids gathered by filters - for _, filter := range sg.Filters { - calculateMetrics(filter, metrics) - } - // calculate metrics for the childres as well. - for _, child := range sg.Children { - calculateMetrics(child, metrics) - } -} diff --git a/query/query.go b/query/query.go index 8630cacee47..072bf23e648 100644 --- a/query/query.go +++ b/query/query.go @@ -2681,6 +2681,7 @@ type ExecutionResult struct { Subgraphs []*SubGraph SchemaNode []*pb.SchemaNode Types []*pb.TypeUpdate + Metrics map[string]uint64 } // Process handles a query request. @@ -2690,6 +2691,12 @@ func (req *Request) Process(ctx context.Context) (er ExecutionResult, err error) return er, err } er.Subgraphs = req.Subgraphs + // calculate metrics. + metrics := make(map[string]uint64) + for _, sg := range er.Subgraphs { + calculateMetrics(sg, metrics) + } + er.Metrics = metrics schemaProcessingStart := time.Now() if req.GqlQuery.Schema != nil { @@ -2715,3 +2722,24 @@ func StripBlankNode(mp map[string]uint64) map[string]uint64 { } return temp } + +// calculateMetrics populates the given map with the number of uids are gathered for each +// attributes. +func calculateMetrics(sg *SubGraph, metrics map[string]uint64) { + + // skip internal nodes. + if sg.IsInternal() { + return + } + // we'll calculate srcUid of the each attribute. because, these are number of uids + // processed by this attribute. + metrics[sg.Attr] = metrics[sg.Attr] + uint64(len(sg.SrcUIDs.GetUids())) + // add all the uids gathered by filters + for _, filter := range sg.Filters { + calculateMetrics(filter, metrics) + } + // calculate metrics for the childres as well. + for _, child := range sg.Children { + calculateMetrics(child, metrics) + } +} From b4a5cff6cdc43a3c9c50de25b286efa03707333a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Tue, 22 Oct 2019 16:13:26 +0530 Subject: [PATCH 05/10] add api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- dgraph/cmd/alpha/http.go | 1 + edgraph/server.go | 3 +++ go.mod | 4 ++-- go.sum | 6 ++++++ query/outputnode.go | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dgraph/cmd/alpha/http.go b/dgraph/cmd/alpha/http.go index a6389f0b1f4..ffe251b7f39 100644 --- a/dgraph/cmd/alpha/http.go +++ b/dgraph/cmd/alpha/http.go @@ -265,6 +265,7 @@ func queryHandler(w http.ResponseWriter, r *http.Request) { e := query.Extensions{ Txn: resp.Txn, Latency: resp.Latency, + Metrics: resp.Metrics, } js, err := json.Marshal(e) if err != nil { diff --git a/edgraph/server.go b/edgraph/server.go index e818766ba92..7883155377a 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -1048,6 +1048,9 @@ func (s *Server) doQuery(ctx context.Context, req *api.Request, authorize int) ( } resp.Latency = gl + resp.Metrics = &api.Metrics{ + NumUids: er.Metrics, + } return resp, err } diff --git a/go.mod b/go.mod index f1d9eadc961..54ce62debd6 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd github.com/d4l3k/messagediff v1.2.1 // indirect github.com/dgraph-io/badger v0.0.0-20190917133922-cbdef65095c7 - github.com/dgraph-io/dgo/v2 v2.1.1-0.20191011032519-062f5605f6da + github.com/dgraph-io/dgo/v2 v2.1.1-0.20191021171913-3efa60e5593b github.com/dgraph-io/ristretto v0.0.0-20191010170704-2ba187ef9534 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 @@ -23,7 +23,7 @@ require ( github.com/dustin/go-humanize v1.0.0 github.com/go-ini/ini v1.39.0 // indirect github.com/go-sql-driver/mysql v0.0.0-20190330032241-c0f6b444ad8f - github.com/gogo/protobuf v1.2.0 + github.com/gogo/protobuf v1.3.1 github.com/golang/geo v0.0.0-20170810003146-31fb0106dc4a github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b github.com/golang/protobuf v1.3.2 diff --git a/go.sum b/go.sum index 4075b41e13d..9e22e378e0a 100644 --- a/go.sum +++ b/go.sum @@ -58,6 +58,8 @@ github.com/dgraph-io/badger v0.0.0-20190917133922-cbdef65095c7 h1:sXNo2Xtte2hOGe github.com/dgraph-io/badger v0.0.0-20190917133922-cbdef65095c7/go.mod h1:V7oadAIwiqodXo5jT04lP+8ysOAuMFZO5x20VSI94Uc= github.com/dgraph-io/dgo/v2 v2.1.1-0.20191011032519-062f5605f6da h1:JAadBE19xm15ZsBZ9HOSuQvMiaCKu+NsV5O5Mfb/62M= github.com/dgraph-io/dgo/v2 v2.1.1-0.20191011032519-062f5605f6da/go.mod h1:R/MTZMGhTo60XSziuKpLXzI1OnVWQCZS5oJjxA8Q1bo= +github.com/dgraph-io/dgo/v2 v2.1.1-0.20191021171913-3efa60e5593b h1:p3gcEqQqQBp4jPIYO5x05sZbY0n8WVp+V1F/EnbJ1oo= +github.com/dgraph-io/dgo/v2 v2.1.1-0.20191021171913-3efa60e5593b/go.mod h1:LJCkLxm5fUMcU+yb8gHFjHt7ChgNuz3YnQQ6MQkmscI= github.com/dgraph-io/ristretto v0.0.0-20190903064322-eb48d2f7ca30 h1:FkdGlqxPjfHKdVUzS5dOSMeOkGjEG7PnR1RLbcEqw88= github.com/dgraph-io/ristretto v0.0.0-20190903064322-eb48d2f7ca30/go.mod h1:UvZmzj8odp3S1nli6yEb1vLME8iJFBrRcw8rAJEiu9Q= github.com/dgraph-io/ristretto v0.0.0-20191010170704-2ba187ef9534 h1:9G6fVccQriMJu4nXwpwLDoy9y31t/KUSLAbPcoBgv+4= @@ -90,6 +92,8 @@ github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/geo v0.0.0-20170810003146-31fb0106dc4a h1:DG/Rx1VnnaqyPhKoPFuU61p4N7lkF5//weoP7QwddNs= github.com/golang/geo v0.0.0-20170810003146-31fb0106dc4a/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= @@ -131,6 +135,7 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -302,6 +307,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= diff --git a/query/outputnode.go b/query/outputnode.go index 6259046d8dc..37df528780f 100644 --- a/query/outputnode.go +++ b/query/outputnode.go @@ -510,6 +510,7 @@ func processNodeUids(fj *fastJsonNode, sg *SubGraph) error { type Extensions struct { Latency *api.Latency `json:"server_latency,omitempty"` Txn *api.TxnContext `json:"txn,omitempty"` + Metrics *api.Metrics `json:"metrics,omitempty"` } func (sg *SubGraph) toFastJSON(l *Latency) ([]byte, error) { From 24eea69bd323ab26be02d7e19e702aaf3d07fc76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Tue, 22 Oct 2019 16:31:36 +0530 Subject: [PATCH 06/10] test added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- query/common_test.go | 10 ++++++++++ query/query4_test.go | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/query/common_test.go b/query/common_test.go index ed1c029b28c..b3c8368680b 100644 --- a/query/common_test.go +++ b/query/common_test.go @@ -69,6 +69,16 @@ func processQueryNoErr(t *testing.T, query string) string { return res } +// processQueryForMetrics works like processQuery but returns metrics instead of response. +func processQueryForMetrics(t *testing.T, query string) *api.Metrics { + txn := client.NewTxn() + defer txn.Discard(context.Background()) + + res, err := txn.Query(context.Background(), query) + require.NoError(t, err) + return res.Metrics +} + func processQueryWithVars(t *testing.T, query string, vars map[string]string) (string, error) { txn := client.NewTxn() diff --git a/query/query4_test.go b/query/query4_test.go index a24006cd2c2..90204fb2e82 100644 --- a/query/query4_test.go +++ b/query/query4_test.go @@ -1158,3 +1158,17 @@ func TestCountUIDNestedMultiple(t *testing.T) { } }`, js) } + +func TestNumUids(t *testing.T) { + query := `{ + me(func:has(name), first:10){ + name + friend{ + name + } + } + }` + metrics := processQueryForMetrics(t, query) + require.Equal(t, metrics.NumUids["friend"], uint64(10)) + require.Equal(t, metrics.NumUids["name"], uint64(16)) +} From 9e43fb3f6ca5335ac68c55e55606218cb111aa9c Mon Sep 17 00:00:00 2001 From: balaji jinnah Date: Tue, 22 Oct 2019 22:08:01 +0530 Subject: [PATCH 07/10] don't return Signed-off-by: balaji jinnah --- query/query.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/query/query.go b/query/query.go index 12f7a486397..440007f19f3 100644 --- a/query/query.go +++ b/query/query.go @@ -2746,12 +2746,11 @@ func StripBlankNode(mp map[string]uint64) map[string]uint64 { func calculateMetrics(sg *SubGraph, metrics map[string]uint64) { // skip internal nodes. - if sg.IsInternal() { - return + if !sg.IsInternal() { + // we'll calculate srcUid of the each attribute. because, these are number of uids + // processed by this attribute. + metrics[sg.Attr] = metrics[sg.Attr] + uint64(len(sg.SrcUIDs.GetUids())) } - // we'll calculate srcUid of the each attribute. because, these are number of uids - // processed by this attribute. - metrics[sg.Attr] = metrics[sg.Attr] + uint64(len(sg.SrcUIDs.GetUids())) // add all the uids gathered by filters for _, filter := range sg.Filters { calculateMetrics(filter, metrics) From 255092210e58e9ae624e43c6759eb66b4f3c050d Mon Sep 17 00:00:00 2001 From: balaji jinnah Date: Tue, 22 Oct 2019 22:10:12 +0530 Subject: [PATCH 08/10] typo fixed Signed-off-by: balaji jinnah --- query/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/query.go b/query/query.go index 440007f19f3..2d8a933e904 100644 --- a/query/query.go +++ b/query/query.go @@ -2755,7 +2755,7 @@ func calculateMetrics(sg *SubGraph, metrics map[string]uint64) { for _, filter := range sg.Filters { calculateMetrics(filter, metrics) } - // calculate metrics for the childres as well. + // calculate metrics for the children as well. for _, child := range sg.Children { calculateMetrics(child, metrics) } From ffa28fc7d196226bc631a4455a52e7aac328d2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Tue, 5 Nov 2019 13:49:01 +0530 Subject: [PATCH 09/10] fix sys test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- contrib/scripts/goldendata-queries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/scripts/goldendata-queries.sh b/contrib/scripts/goldendata-queries.sh index 4b852d5dc87..2fb9d93b195 100755 --- a/contrib/scripts/goldendata-queries.sh +++ b/contrib/scripts/goldendata-queries.sh @@ -31,7 +31,7 @@ function run_index_test { timeout=$(( timeout * 2 )) done - NUM=$(echo $N | python -m json.tool | grep $GREPFOR | wc -l) + NUM=$(echo $N | python -m json.tool | grep $GREPFOR | wc -l | head -1) if [[ ! "$NUM" -eq "$ANS" ]]; then echo "Index test failed: ${X} Expected: $ANS Got: $NUM" exit 1 From 071e164753d53d720b713e89928676fba6a9681b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AA=E0=AE=BE=E0=AE=B2=E0=AE=BE=E0=AE=9C=E0=AE=BF?= Date: Tue, 5 Nov 2019 14:24:28 +0530 Subject: [PATCH 10/10] increment one for the systest index test. beacuse, num_uid will give one more attribute name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: பாலாஜி --- contrib/scripts/goldendata-queries.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/scripts/goldendata-queries.sh b/contrib/scripts/goldendata-queries.sh index 2fb9d93b195..f29dfa99b8b 100755 --- a/contrib/scripts/goldendata-queries.sh +++ b/contrib/scripts/goldendata-queries.sh @@ -31,7 +31,7 @@ function run_index_test { timeout=$(( timeout * 2 )) done - NUM=$(echo $N | python -m json.tool | grep $GREPFOR | wc -l | head -1) + NUM=$(echo $N | python -m json.tool | grep $GREPFOR | wc -l) if [[ ! "$NUM" -eq "$ANS" ]]; then echo "Index test failed: ${X} Expected: $ANS Got: $NUM" exit 1 @@ -41,15 +41,15 @@ function run_index_test { } echo -e "Running some queries and checking count of results returned." -run_index_test basic name 138676 -run_index_test allof_the name 25431 -run_index_test allof_the_a name 367 -run_index_test allof_the_first name 4383 -run_index_test releasedate release_date 137858 -run_index_test releasedate_sort release_date 137858 -run_index_test releasedate_sort_first_offset release_date 2315 -run_index_test releasedate_geq release_date 60991 -run_index_test gen_anyof_good_bad name 1103 +run_index_test basic name 138677 +run_index_test allof_the name 25432 +run_index_test allof_the_a name 368 +run_index_test allof_the_first name 4384 +run_index_test releasedate release_date 137859 +run_index_test releasedate_sort release_date 137859 +run_index_test releasedate_sort_first_offset release_date 2316 +run_index_test releasedate_geq release_date 60992 +run_index_test gen_anyof_good_bad name 1104 popd &> /dev/null