Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
dgraph
Commits
daf62d60
Unverified
Commit
daf62d60
authored
9 years ago
by
Manish R Jain
Browse files
Options
Downloads
Patches
Plain Diff
Add comments to clarify how ToJson works.
parent
86510f1d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
query/query.go
+16
-1
16 additions, 1 deletion
query/query.go
with
16 additions
and
1 deletion
query/query.go
+
16
−
1
View file @
daf62d60
...
@@ -180,6 +180,17 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
...
@@ -180,6 +180,17 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
r
.
ValuesLength
(),
q
.
UidsLength
())
r
.
ValuesLength
(),
q
.
UidsLength
())
}
}
// Generate a matrix of maps
// Row -> .....
// Col
// |
// v
// map{_uid_ = uid}
// If some result is present from children results, then merge.
// Otherwise, this would only contain the _uid_ property.
// result[uid in row] = map[cur attribute ->
// list of maps of {uid, uid + children result}]
//
var
ul
task
.
UidList
var
ul
task
.
UidList
for
i
:=
0
;
i
<
r
.
UidmatrixLength
();
i
++
{
for
i
:=
0
;
i
<
r
.
UidmatrixLength
();
i
++
{
if
ok
:=
r
.
Uidmatrix
(
&
ul
,
i
);
!
ok
{
if
ok
:=
r
.
Uidmatrix
(
&
ul
,
i
);
!
ok
{
...
@@ -201,6 +212,7 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
...
@@ -201,6 +212,7 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
m
[
g
.
Attr
]
=
l
m
[
g
.
Attr
]
=
l
result
[
q
.
Uids
(
i
)]
=
m
result
[
q
.
Uids
(
i
)]
=
m
}
}
// TODO(manish): Check what happens if we handle len(l) == 1 separately.
}
}
var
tv
task
.
Value
var
tv
task
.
Value
...
@@ -210,6 +222,9 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
...
@@ -210,6 +222,9 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
}
}
val
:=
tv
.
ValBytes
()
val
:=
tv
.
ValBytes
()
if
bytes
.
Equal
(
val
,
nil
)
{
if
bytes
.
Equal
(
val
,
nil
)
{
// We do this, because we typically do set values, even though
// they might be nil. This is to ensure that the index of the query uids
// and the index of the results can remain in sync.
continue
continue
}
}
...
@@ -217,7 +232,7 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
...
@@ -217,7 +232,7 @@ func postTraverse(g *SubGraph) (result map[uint64]interface{}, rerr error) {
glog
.
WithField
(
"prev"
,
pval
)
.
glog
.
WithField
(
"prev"
,
pval
)
.
WithField
(
"_uid_"
,
q
.
Uids
(
i
))
.
WithField
(
"_uid_"
,
q
.
Uids
(
i
))
.
WithField
(
"new"
,
val
)
.
WithField
(
"new"
,
val
)
.
Fatal
(
"Previous value detected."
)
Fatal
(
"Previous value detected.
A uid -> list of uids / value. Not both.
"
)
}
}
m
:=
make
(
map
[
string
]
interface
{})
m
:=
make
(
map
[
string
]
interface
{})
m
[
"_uid_"
]
=
fmt
.
Sprintf
(
"%#x"
,
q
.
Uids
(
i
))
m
[
"_uid_"
]
=
fmt
.
Sprintf
(
"%#x"
,
q
.
Uids
(
i
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment