Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-datastore
Commits
d3720199
Unverified
Commit
d3720199
authored
Mar 22, 2019
by
Michael Avila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make new query for children
parent
16330520
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
17 deletions
+19
-17
mount/mount.go
mount/mount.go
+19
-17
No files found.
mount/mount.go
View file @
d3720199
...
...
@@ -220,18 +220,20 @@ func (d *Datastore) Delete(key ds.Key) error {
return
cds
.
Delete
(
k
)
}
func
(
d
*
Datastore
)
Query
(
q
query
.
Query
)
(
query
.
Results
,
error
)
{
prefix
:=
ds
.
NewKey
(
q
.
Prefix
)
dses
,
mounts
,
rests
:=
d
.
lookupAll
(
prefix
)
func
(
d
*
Datastore
)
Query
(
master
query
.
Query
)
(
query
.
Results
,
error
)
{
childQuery
:=
query
.
Query
{
Prefix
:
master
.
Prefix
,
Limit
:
master
.
Limit
,
Orders
:
master
.
Orders
,
KeysOnly
:
master
.
KeysOnly
,
ReturnExpirations
:
master
.
ReturnExpirations
,
}
// offset needs to be applied after the results are aggregated
offset
:=
q
.
Offset
q
.
Offset
=
0
filters
:=
q
.
Filters
q
.
Filters
=
[]
query
.
Filter
{}
prefix
:=
ds
.
NewKey
(
childQuery
.
Prefix
)
dses
,
mounts
,
rests
:=
d
.
lookupAll
(
prefix
)
queries
:=
&
querySet
{
query
:
q
,
query
:
childQuery
,
heads
:
make
([]
*
queryResults
,
0
,
len
(
dses
)),
}
...
...
@@ -240,7 +242,7 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
dstore
:=
dses
[
i
]
rest
:=
rests
[
i
]
qi
:=
q
qi
:=
childQuery
qi
.
Prefix
=
rest
.
String
()
results
,
err
:=
dstore
.
Query
(
qi
)
...
...
@@ -251,23 +253,23 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
queries
.
addResults
(
mount
,
results
)
}
qr
:=
query
.
ResultsFromIterator
(
q
,
query
.
Iterator
{
qr
:=
query
.
ResultsFromIterator
(
childQuery
,
query
.
Iterator
{
Next
:
queries
.
next
,
Close
:
queries
.
close
,
})
if
len
(
f
ilters
)
>
0
{
for
_
,
f
:=
range
f
ilters
{
if
len
(
master
.
F
ilters
)
>
0
{
for
_
,
f
:=
range
master
.
F
ilters
{
qr
=
query
.
NaiveFilter
(
qr
,
f
)
}
}
if
o
ffset
>
0
{
qr
=
query
.
NaiveOffset
(
qr
,
o
ffset
)
if
master
.
O
ffset
>
0
{
qr
=
query
.
NaiveOffset
(
qr
,
master
.
O
ffset
)
}
if
q
.
Limit
>
0
{
qr
=
query
.
NaiveLimit
(
qr
,
q
.
Limit
)
if
childQuery
.
Limit
>
0
{
qr
=
query
.
NaiveLimit
(
qr
,
childQuery
.
Limit
)
}
return
qr
,
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment