Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dgraph
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
c51f9208
Unverified
Commit
c51f9208
authored
8 years ago
by
Ashwin Ramesh
Browse files
Options
Downloads
Patches
Plain Diff
Ensure DestUids is sorted
parent
a61cafcf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.travis.yml
+1
-1
1 addition, 1 deletion
.travis.yml
algo/uidlist.go
+22
-0
22 additions, 0 deletions
algo/uidlist.go
algo/uidlist_test.go
+24
-0
24 additions, 0 deletions
algo/uidlist_test.go
query/query.go
+19
-5
19 additions, 5 deletions
query/query.go
query/query_test.go
+29
-0
29 additions, 0 deletions
query/query_test.go
with
95 additions
and
6 deletions
.travis.yml
+
1
−
1
View file @
c51f9208
language
:
go
go
:
-
1.
7
-
1.
8
dist
:
trusty
sudo
:
required
notifications
:
...
...
This diff is collapsed.
Click to expand it.
algo/uidlist.go
+
22
−
0
View file @
c51f9208
...
...
@@ -27,6 +27,28 @@ type WriteIterator struct {
}
// AsList implements sort.Interface by for block lists
type
AsList
struct
{
l
*
task
.
List
}
func
(
s
AsList
)
Len
()
int
{
return
ListLen
(
s
.
l
)
}
func
(
s
AsList
)
Swap
(
i
,
j
int
)
{
p
,
q
:=
ridx
(
s
.
l
,
i
)
m
,
n
:=
ridx
(
s
.
l
,
j
)
s
.
l
.
Blocks
[
p
]
.
List
[
q
],
s
.
l
.
Blocks
[
m
]
.
List
[
n
]
=
s
.
l
.
Blocks
[
m
]
.
List
[
n
],
s
.
l
.
Blocks
[
p
]
.
List
[
q
]
}
func
(
s
AsList
)
Less
(
i
,
j
int
)
bool
{
p
,
q
:=
ridx
(
s
.
l
,
i
)
m
,
n
:=
ridx
(
s
.
l
,
j
)
return
s
.
l
.
Blocks
[
p
]
.
List
[
q
]
<
s
.
l
.
Blocks
[
m
]
.
List
[
n
]
}
func
Sort
(
ul
*
task
.
List
)
{
sort
.
Sort
(
AsList
{
ul
})
for
_
,
it
:=
range
ul
.
Blocks
{
it
.
MaxInt
=
it
.
List
[
len
(
it
.
List
)
-
1
]
}
}
func
NewWriteIterator
(
l
*
task
.
List
,
whence
int
)
WriteIterator
{
blen
:=
len
(
l
.
Blocks
)
var
cur
*
task
.
Block
...
...
This diff is collapsed.
Click to expand it.
algo/uidlist_test.go
+
24
−
0
View file @
c51f9208
...
...
@@ -27,6 +27,30 @@ func newList(data []uint64) *task.List {
return
SortedListToBlock
(
data
)
}
func
TestSort1
(
t
*
testing
.
T
)
{
input
:=
newList
([]
uint64
{
55
})
Sort
(
input
)
require
.
Equal
(
t
,
BlockToList
(
input
),
[]
uint64
{
55
})
}
func
TestSort2
(
t
*
testing
.
T
)
{
input
:=
newList
([]
uint64
{})
Sort
(
input
)
require
.
Equal
(
t
,
BlockToList
(
input
),
[]
uint64
{})
}
func
TestSort3
(
t
*
testing
.
T
)
{
input
:=
newList
([]
uint64
{
55
,
392
,
1
,
123
})
Sort
(
input
)
require
.
Equal
(
t
,
BlockToList
(
input
),
[]
uint64
{
1
,
55
,
123
,
392
})
}
func
TestSort4
(
t
*
testing
.
T
)
{
input
:=
newList
([]
uint64
{
55
,
1
,
100000
})
Sort
(
input
)
require
.
Equal
(
t
,
BlockToList
(
input
),
[]
uint64
{
1
,
55
,
100000
})
}
func
TestMergeSorted1
(
t
*
testing
.
T
)
{
input
:=
[]
*
task
.
List
{
newList
([]
uint64
{
55
}),
...
...
This diff is collapsed.
Click to expand it.
query/query.go
+
19
−
5
View file @
c51f9208
...
...
@@ -282,7 +282,6 @@ func (sg *SubGraph) preTraverse(uid uint64, dst, parent outputNode) error {
continue
}
uc
:=
dst
.
New
(
fieldName
)
if
rerr
:=
pc
.
preTraverse
(
childUID
,
uc
,
dst
);
rerr
!=
nil
{
if
rerr
.
Error
()
==
"_INV_"
{
invalidUids
[
childUID
]
=
true
...
...
@@ -638,13 +637,18 @@ func newGraph(ctx context.Context, gq *gql.GraphQuery) (*SubGraph, error) {
}
if
len
(
gq
.
UID
)
>
0
{
o
:=
new
(
task
.
List
)
it
:=
algo
.
NewWriteIterator
(
o
,
0
)
sg
.
SrcUIDs
=
new
(
task
.
List
)
ito
:=
algo
.
NewWriteIterator
(
o
,
0
)
itsg
:=
algo
.
NewWriteIterator
(
sg
.
SrcUIDs
,
0
)
for
_
,
uid
:=
range
gq
.
UID
{
it
.
Append
(
uid
)
ito
.
Append
(
uid
)
itsg
.
Append
(
uid
)
}
it
.
End
()
sg
.
SrcUIDs
=
o
it
o
.
End
()
it
sg
.
End
()
sg
.
uidMatrix
=
[]
*
task
.
List
{
o
}
// User specified list may not be sorted.
algo
.
Sort
(
sg
.
SrcUIDs
)
}
sg
.
values
=
createNilValuesList
(
1
)
// Copy roots filter.
...
...
@@ -903,7 +907,17 @@ func (sg *SubGraph) fillVars(mp map[string]*task.List) {
func
ProcessGraph
(
ctx
context
.
Context
,
sg
,
parent
*
SubGraph
,
rch
chan
error
)
{
var
err
error
if
len
(
sg
.
Params
.
NeedsVar
)
!=
0
&&
len
(
sg
.
SrcFunc
)
==
0
{
// Retain the actual order in uidMatrix. But sort the destUids.
sg
.
uidMatrix
=
[]
*
task
.
List
{
sg
.
DestUIDs
}
it
:=
algo
.
NewListIterator
(
sg
.
DestUIDs
)
var
o
task
.
List
wit
:=
algo
.
NewWriteIterator
(
&
o
,
0
)
for
;
it
.
Valid
();
it
.
Next
()
{
wit
.
Append
(
it
.
Val
())
}
wit
.
End
()
algo
.
Sort
(
&
o
)
sg
.
DestUIDs
=
&
o
}
else
if
len
(
sg
.
Attr
)
==
0
{
// If we have a filter SubGraph which only contains an operator,
// it won't have any attribute to work on.
...
...
This diff is collapsed.
Click to expand it.
query/query_test.go
+
29
−
0
View file @
c51f9208
...
...
@@ -470,6 +470,24 @@ func TestShortestPath(t *testing.T) {
js
)
}
func
TestShortestPathRev
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
query
:=
`
{
A as shortest(from:23, to:1) {
friend
}
me(var: A) {
name
}
}`
js
:=
processToFastJSON
(
t
,
query
)
require
.
JSONEq
(
t
,
`{"me":[{"name":"Rick Grimes"},{"name":"Michonne"}]}`
,
js
)
}
func
TestShortestPathWeightsMultiFacet_Error
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
query
:=
`
...
...
@@ -2816,6 +2834,17 @@ func TestRootList1(t *testing.T) {
require
.
JSONEq
(
t
,
`{"me":[{"name":"Michonne"},{"name":"Rick Grimes"},{"name":"Glenn Rhee"},{"name":"Alice"}]}`
,
js
)
}
func
TestRootList2
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
query
:=
`{
me(id:[0x01, 23, a.bc, 24]) {
name
}
}`
js
:=
processToFastJSON
(
t
,
query
)
require
.
JSONEq
(
t
,
`{"me":[{"name":"Michonne"},{"name":"Rick Grimes"},{"name":"Alice"},{"name":"Glenn Rhee"}]}`
,
js
)
}
func
TestGeneratorMultiRootFilter1
(
t
*
testing
.
T
)
{
populateGraph
(
t
)
query
:=
`
...
...
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