Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Q
query-conversion
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
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
query-conversion
Commits
638f7a9e
Commit
638f7a9e
authored
3 years ago
by
Geurtjens,D. (Douwe Geurtjens)
Browse files
Options
Downloads
Patches
Plain Diff
Quick push new new format
parent
700b62c2
No related branches found
No related tags found
1 merge request
!1
Big merge
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aql/createConstraints.go
+2
-2
2 additions, 2 deletions
aql/createConstraints.go
aql/hierarchy.go
+0
-60
0 additions, 60 deletions
aql/hierarchy.go
entity/queryStruct.go
+20
-24
20 additions, 24 deletions
entity/queryStruct.go
with
22 additions
and
86 deletions
aql/createConstraints.go
+
2
−
2
View file @
638f7a9e
...
...
@@ -13,7 +13,7 @@ isRelation is a boolean specifying if this constraint comes from a node or relat
Return: a string containing a FILTER-statement with all the constraints
*/
func
createConstraintStatements
(
constraints
*
[]
entity
.
Query
Filter
Struct
,
name
string
,
isRelation
bool
)
*
string
{
func
createConstraintStatements
(
constraints
*
[]
entity
.
Query
Constraint
Struct
,
name
string
,
isRelation
bool
)
*
string
{
s
:=
""
if
len
(
*
constraints
)
==
0
{
return
&
s
...
...
@@ -38,7 +38,7 @@ isRelation is a boolean specifying if this constraint comes from a node or relat
Return: a string containing an boolean expression of a single constraint
*/
func
createConstraintBoolExpression
(
constraint
*
entity
.
Query
Filter
Struct
,
name
string
,
isRelation
bool
)
*
string
{
func
createConstraintBoolExpression
(
constraint
*
entity
.
Query
Constraint
Struct
,
name
string
,
isRelation
bool
)
*
string
{
var
(
match
string
value
string
...
...
This diff is collapsed.
Click to expand it.
aql/hierarchy.go
+
0
−
60
View file @
638f7a9e
...
...
@@ -43,7 +43,6 @@ func search(JSONQuery *entity.IncomingQueryJSON, index int) []entity.PdictList {
}
fmt
.
Println
(
""
)
}
listoflists
=
addFilters
(
JSONQuery
,
listoflists
)
fmt
.
Println
(
listoflists
)
return
listoflists
}
...
...
@@ -273,52 +272,6 @@ func funcToAllRel(JSONQuery *entity.IncomingQueryJSON, listoflists []entity.Pdic
return
listoflists
}
func
addFilters
(
JSONQuery
*
entity
.
IncomingQueryJSON
,
listoflists
[]
entity
.
PdictList
)
[]
entity
.
PdictList
{
for
i
,
filter
:=
range
JSONQuery
.
Filters
{
if
_
,
ok
:=
filterDone
[
i
];
!
ok
{
p
:=
makePdict
(
filter
.
FromType
,
filter
.
FromID
)
f
:=
makePdict
(
FILTERSTRING
,
filter
.
ID
)
listoflists
=
addOneFilter
(
f
,
JSONQuery
,
listoflists
,
p
,
&
filterDone
)
}
}
return
listoflists
}
func
addOneFilter
(
filterPDict
entity
.
Pdict
,
JSONQuery
*
entity
.
IncomingQueryJSON
,
listoflists
[]
entity
.
PdictList
,
p
entity
.
Pdict
,
filterDone
*
map
[
int
]
bool
)
[]
entity
.
PdictList
{
if
p
.
Typename
==
FILTERSTRING
&&
(
*
filterDone
)[
p
.
Pointer
]
{
l
:=
findCurrentLayer
(
listoflists
,
p
)
k
:=
entity
.
PdictList
{
filterPDict
}
if
len
(
listoflists
)
>
l
+
1
&&
listoflists
[
l
+
1
][
0
]
.
Typename
==
FILTERSTRING
{
listoflists
[
l
+
1
]
=
append
(
listoflists
[
l
+
1
],
filterPDict
)
}
else
{
listoflists
=
filterAppend
(
listoflists
,
l
,
k
)
}
(
*
filterDone
)[
filterPDict
.
Pointer
]
=
true
}
else
if
p
.
Typename
==
FILTERSTRING
{
pnew
:=
makePdict
(
JSONQuery
.
Filters
[
p
.
Pointer
]
.
FromType
,
JSONQuery
.
Filters
[
p
.
Pointer
]
.
FromID
)
addOneFilter
(
p
,
JSONQuery
,
listoflists
,
pnew
,
filterDone
)
l
:=
findCurrentLayer
(
listoflists
,
p
)
k
:=
entity
.
PdictList
{
filterPDict
}
if
len
(
listoflists
)
>
l
+
1
&&
listoflists
[
l
+
1
][
0
]
.
Typename
==
FILTERSTRING
{
listoflists
[
l
+
1
]
=
append
(
listoflists
[
l
+
1
],
filterPDict
)
}
else
{
listoflists
=
filterAppend
(
listoflists
,
l
,
k
)
}
(
*
filterDone
)[
filterPDict
.
Pointer
]
=
true
}
else
{
l
:=
findCurrentLayer
(
listoflists
,
p
)
k
:=
entity
.
PdictList
{
filterPDict
}
if
len
(
listoflists
)
>
l
+
1
&&
listoflists
[
l
+
1
][
0
]
.
Typename
==
FILTERSTRING
{
listoflists
[
l
+
1
]
=
append
(
listoflists
[
l
+
1
],
filterPDict
)
}
else
{
listoflists
=
filterAppend
(
listoflists
,
l
,
k
)
}
(
*
filterDone
)[
filterPDict
.
Pointer
]
=
true
}
return
listoflists
}
// A function that appends 1 level above (if index is 0 this won't work)
func
aboveAppend
(
listoflists
[]
entity
.
PdictList
,
index
int
,
values
entity
.
PdictList
)
[]
entity
.
PdictList
{
if
index
==
0
{
...
...
@@ -349,19 +302,6 @@ func belowAppend(listoflists []entity.PdictList, index int, values entity.PdictL
}
}
func
filterAppend
(
listoflists
[]
entity
.
PdictList
,
index
int
,
values
entity
.
PdictList
)
[]
entity
.
PdictList
{
if
len
(
listoflists
)
-
1
==
index
{
// nil or empty slice or after last element
return
append
(
listoflists
,
values
)
}
k
:=
make
([]
entity
.
PdictList
,
len
(
listoflists
[
index
+
1
:
]))
copy
(
k
,
listoflists
[
index
+
1
:
])
l
:=
make
([]
entity
.
PdictList
,
len
(
listoflists
[
:
index
+
1
]))
copy
(
l
,
listoflists
[
:
index
+
1
])
listoflists
=
append
(
l
,
values
)
// index < len(a)
return
append
(
listoflists
,
k
...
)
}
// A simple double-for loop that finds the layer in which an element resides in the hierarchy
// Because we only append elements relative to another element, we can freely use this to keep track of layers
func
findCurrentLayer
(
list
[]
entity
.
PdictList
,
element
entity
.
Pdict
)
int
{
...
...
This diff is collapsed.
Click to expand it.
entity/queryStruct.go
+
20
−
24
View file @
638f7a9e
...
...
@@ -7,7 +7,6 @@ type IncomingQueryJSON struct {
Entities
[]
QueryEntityStruct
Relations
[]
QueryRelationStruct
GroupBys
[]
QueryGroupByStruct
Filters
[]
QueryFilterStruct
MachineLearning
[]
QueryMLStruct
// Limit is for limiting the amount of paths AQL will return in a relation let statement
Limit
int
...
...
@@ -24,19 +23,21 @@ type QueryReturnStruct struct {
// QueryEntityStruct encapsulates a single entity with its corresponding constraints
type
QueryEntityStruct
struct
{
ID
int
Name
string
ID
int
Name
string
Constraints
[]
QueryConstraintStruct
}
// QueryRelationStruct encapsulates a single relation with its corresponding constraints
type
QueryRelationStruct
struct
{
ID
int
Name
string
FromType
string
FromID
int
ToType
string
ToID
int
Depth
QuerySearchDepthStruct
ID
int
Name
string
FromType
string
FromID
int
ToType
string
ToID
int
Depth
QuerySearchDepthStruct
QueryConstraintStruct
[]
QueryConstraintStruct
}
type
QueryGroupByStruct
struct
{
...
...
@@ -49,20 +50,21 @@ type QueryGroupByStruct struct {
ByAttribute
string
AppliedModifier
string
RelationID
int
Constraints
[]
QueryConstraintStruct
}
type
Query
FilterStruct
struct
{
ID
int
FromType
string
FromID
int
ToType
string
ToID
int
//
Query
ConstraintStruct holds the information of the constraint
// Constraint datatypes
// string MatchTypes: exact/contains/startswith/endswith
// int MatchTypes: GT/LT/EQ
// bool MatchTypes: EQ/NEQ
type
QueryConstraintStruct
struct
{
Attribute
string
Value
string
DataType
string
MatchType
string
Value
string
InType
string
InID
int
InType
string
}
type
QueryMLStruct
struct
{
...
...
@@ -83,9 +85,3 @@ type QuerySearchDepthStruct struct {
Min
int
Max
int
}
// QueryConstraintStruct holds the information of the constraint
// Constraint datatypes
// string MatchTypes: exact/contains/startswith/endswith
// int MatchTypes: GT/LT/EQ/
// bool MatchTypes: EQ/NEQ
This diff is collapsed.
Click to expand it.
Heijden,T.A.J. van der (Thijs)
@t.a.j.vanderheijden
mentioned in commit
82d6956b
·
3 years ago
mentioned in commit
82d6956b
mentioned in commit 82d6956b25f2a5a9942b9ef3014309c1aefed134
Toggle commit list
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