Skip to content
Snippets Groups Projects
Commit e1d3da50 authored by sivan's avatar sivan
Browse files

use limit received in request

parent 1c83db0d
No related branches found
No related tags found
No related merge requests found
......@@ -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\tFOR x IN n%v \n", name, relation.EntityFrom)
forStatement := fmt.Sprintf("\tFOR 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 := "\tLIMIT 1000 \nRETURN DISTINCT p )\n"
footer := fmt.Sprintf("\tLIMIT %v \nRETURN 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\tFOR x IN n%v \n", name, relation.EntityTo)
forStatement := fmt.Sprintf("\tFOR 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 := "\tOPTIONS { uniqueEdges: \"path\" }\n"
relationFilterStmnt := *createConstraintStatements(&relation.Constraints, "p", true)
footer := "\tLIMIT 1000 \nRETURN DISTINCT p )\n"
footer := fmt.Sprintf("\tLIMIT %v \nRETURN DISTINCT p )\n", limit)
ret := header + forStatement + optionStmtn + relationFilterStmnt + footer
return &ret
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment