Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-service
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GraphPolaris
Microservices
query-service
Commits
e1d3da50
Commit
e1d3da50
authored
3 years ago
by
sivan
Browse files
Options
Downloads
Patches
Plain Diff
use limit received in request
parent
1c83db0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
internal/usecases/convertquery/aql.go
+6
-6
6 additions, 6 deletions
internal/usecases/convertquery/aql.go
internal/usecases/convertquery/aqlStructs.go
+3
-0
3 additions, 0 deletions
internal/usecases/convertquery/aqlStructs.go
with
9 additions
and
6 deletions
internal/usecases/convertquery/aql.go
+
6
−
6
View file @
e1d3da50
...
...
@@ -68,13 +68,13 @@ func createQuery(jsonQuery *parsedJSON) *string {
fromName
:=
fmt
.
Sprintf
(
"n%v"
,
relation
.
EntityFrom
)
ret
+=
*
createNodeLet
(
&
jsonQuery
.
Entities
[
relation
.
EntityFrom
],
&
fromName
)
ret
+=
*
createRelationLetWithFromEntity
(
&
relation
,
relationName
,
&
jsonQuery
.
Entities
)
ret
+=
*
createRelationLetWithFromEntity
(
&
relation
,
relationName
,
&
jsonQuery
.
Entities
,
jsonQuery
.
Limit
)
}
else
if
relation
.
EntityTo
!=
-
1
{
// if there is only a to-node
toName
:=
fmt
.
Sprintf
(
"n%v"
,
relation
.
EntityTo
)
ret
+=
*
createNodeLet
(
&
jsonQuery
.
Entities
[
relation
.
EntityTo
],
&
toName
)
ret
+=
*
createRelationLetWithOnlyToEntity
(
&
relation
,
relationName
,
&
jsonQuery
.
Entities
)
ret
+=
*
createRelationLetWithOnlyToEntity
(
&
relation
,
relationName
,
&
jsonQuery
.
Entities
,
jsonQuery
.
Limit
)
// Add this relation to the list
}
else
{
fmt
.
Println
(
"Relation-only queries are currently not supported"
)
...
...
@@ -151,7 +151,7 @@ entities is a list of entityStructs that are needed to form the relation LET-sta
Return: a string containing a single LET-statement in AQL
*/
func
createRelationLetWithFromEntity
(
relation
*
relationStruct
,
name
string
,
entities
*
[]
entityStruct
)
*
string
{
func
createRelationLetWithFromEntity
(
relation
*
relationStruct
,
name
string
,
entities
*
[]
entityStruct
,
limit
int
)
*
string
{
header
:=
fmt
.
Sprintf
(
"LET %v = (
\n\t
FOR x IN n%v
\n
"
,
name
,
relation
.
EntityFrom
)
forStatement
:=
fmt
.
Sprintf
(
"
\t
FOR v, e, p IN %v..%v OUTBOUND x %s
\n
"
,
relation
.
Depth
.
Min
,
relation
.
Depth
.
Max
,
relation
.
Type
)
...
...
@@ -172,7 +172,7 @@ func createRelationLetWithFromEntity(relation *relationStruct, name string, enti
}
relationFilterStmnt
:=
*
createConstraintStatements
(
&
relation
.
Constraints
,
"p"
,
true
)
footer
:=
"
\t
LIMIT
1000
\n
RETURN DISTINCT p )
\n
"
footer
:=
fmt
.
Sprintf
(
"
\t
LIMIT
%v
\n
RETURN DISTINCT p )
\n
"
,
limit
)
ret
:=
header
+
forStatement
+
optionStmtn
+
vFilterStmnt
+
relationFilterStmnt
+
footer
return
&
ret
...
...
@@ -185,7 +185,7 @@ entities is a list of entityStructs that are needed to form the relation LET-sta
Return: a string containing a single LET-statement in AQL
*/
func
createRelationLetWithOnlyToEntity
(
relation
*
relationStruct
,
name
string
,
entities
*
[]
entityStruct
)
*
string
{
func
createRelationLetWithOnlyToEntity
(
relation
*
relationStruct
,
name
string
,
entities
*
[]
entityStruct
,
limit
int
)
*
string
{
header
:=
fmt
.
Sprintf
(
"LET %v = (
\n\t
FOR x IN n%v
\n
"
,
name
,
relation
.
EntityTo
)
forStatement
:=
fmt
.
Sprintf
(
"
\t
FOR v, e, p IN %v..%v INBOUND x %s
\n
"
,
relation
.
Depth
.
Min
,
relation
.
Depth
.
Max
,
relation
.
Type
)
...
...
@@ -194,7 +194,7 @@ func createRelationLetWithOnlyToEntity(relation *relationStruct, name string, en
optionStmtn
:=
"
\t
OPTIONS { uniqueEdges:
\"
path
\"
}
\n
"
relationFilterStmnt
:=
*
createConstraintStatements
(
&
relation
.
Constraints
,
"p"
,
true
)
footer
:=
"
\t
LIMIT
1000
\n
RETURN DISTINCT p )
\n
"
footer
:=
fmt
.
Sprintf
(
"
\t
LIMIT
%v
\n
RETURN DISTINCT p )
\n
"
,
limit
)
ret
:=
header
+
forStatement
+
optionStmtn
+
relationFilterStmnt
+
footer
return
&
ret
...
...
This diff is collapsed.
Click to expand it.
internal/usecases/convertquery/aqlStructs.go
+
3
−
0
View file @
e1d3da50
...
...
@@ -14,6 +14,9 @@ type parsedJSON struct {
Return
returnStruct
Entities
[]
entityStruct
Relations
[]
relationStruct
// Limit is for limiting the amount of paths AQL will return in a relation let statement
Limit
int
}
// returnStruct holds the indices of the entities and relations that need to be returned
...
...
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