diff --git a/cypher/convertQuery.go b/cypher/convertQuery.go index a0c998c44b173f62064c5dfa682c3529b12378e9..28f36199ace47650fa3fd5cb850910955d272460 100644 --- a/cypher/convertQuery.go +++ b/cypher/convertQuery.go @@ -171,10 +171,10 @@ func createQuery(JSONQuery *entity.IncomingQueryJSON) *string { if !nodeSet[entityIndex] { // If not, return this node name := fmt.Sprintf("n%v", entityIndex) - ret += *createNodeMatch(&JSONQuery.Entities[entityIndex], &name) - + ret += *createNodeMatch(&JSONQuery.Entities[entityIndex], &name) // Add this node to the list nodesToReturn = append(nodesToReturn, name) + ret += fmt.Sprintf("RETURN %v", name) } } diff --git a/cypher/convertQueryBenchmark_test.go b/cypher/convertQueryBenchmark_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a33e73b2d2ce1e5b6a2b95598d5e0db9b663fa34 --- /dev/null +++ b/cypher/convertQueryBenchmark_test.go @@ -0,0 +1,169 @@ +package cypher + +import ( + "encoding/json" + "testing" + + "git.science.uu.nl/datastrophe/query-conversion/entity" +) + +func BenchmarkConvertEmptyQuery(b *testing.B) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [], + "relations": [] + }, + "entities": [], + "relations": [], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + service.ConvertQuery(&JSONQuery) + } +} + +func BenchmarkConvertOneAttributeQuery(b *testing.B) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + service.ConvertQuery(&JSONQuery) + } +} + +func BenchmarkConvertTwoRelationQuery(b *testing.B) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0, + 1, + 2 + ], + "relations": [ + 0, + 1 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "New York", + "dataType": "text", + "matchType": "exact" + } + ] + }, + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + }, + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 3 + }, + "entityFrom": 2, + "entityTo": 1, + "constraints": [ + { + "attribute": "Day", + "value": "15", + "dataType": "number", + "matchType": "EQ" + } + ] + }, + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 0, + "entityTo": -1, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + service.ConvertQuery(&JSONQuery) + } +} diff --git a/cypher/convertQuery_test.go b/cypher/convertQuery_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8f595f02f6a2f54a61e735f6a3aba86557fc7b67 --- /dev/null +++ b/cypher/convertQuery_test.go @@ -0,0 +1,894 @@ +package cypher + +import ( + "encoding/json" + "errors" + "strings" + "testing" + + "git.science.uu.nl/datastrophe/query-conversion/entity" + "github.com/stretchr/testify/assert" +) + +func TestEmptyQueryConversion(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [], + "relations": [] + }, + "entities": [], + "relations": [], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `` + assert.Equal(t, correctConvertedResult, *convertedResult) +} + +func TestEntityOneAttributeQuery(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n0:airports)WHERE n0.state = "HI" RETURN n0` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +func TestRelationWithConstraint(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 0, + "entityTo": -1, + "constraints": [ + { + "attribute": "Day", + "value": "15", + "dataType": "number", + "matchType": "EQ" + } + ] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n0:airports)WHERE n0.state = "HI" MATCH p0 = (n0)-[r0:flights*1..1]->()WHERE r0.Day = 15 RETURN n0,p0;` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +// func TestModifierCountEntity(t *testing.T) { +// // Setup for test +// // Create query conversion service +// service := NewService() + +// query := []byte(`{ +// "return": { +// "entities": [ +// 0 +// ], +// "relations": [] +// }, +// "entities": [ +// { +// "type": "airports", +// "constraints": [ +// { +// "attribute": "state", +// "value": "HI", +// "dataType": "text", +// "matchType": "exact" +// } +// ] +// } +// ], +// "relations": [], +// "limit": 5000, +// "modifiers": [ +// { +// "type": "COUNT", +// "selectedType": "entity", +// "id": 0, +// "attributeIndex": -1 +// } +// ] +// }`) + +// // Unmarshall the incoming message into an IncomingJSONQuery object +// var JSONQuery entity.IncomingQueryJSON +// json.Unmarshal(query, &JSONQuery) + +// convertedResult, err := service.ConvertQuery(&JSONQuery) + +// // Assert that there is no error +// assert.NoError(t, err) + +// // Assert that the result and the expected result are the same +// correctConvertedResult := `LET n0 = (FOR x IN airports FILTER x.state == "HI" RETURN x)RETURN LENGTH (n0)` +// cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") +// cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") +// assert.Equal(t, correctConvertedResult, cleanedResult) +// } + +// func TestModifierCountEntityAttribute(t *testing.T) { +// // Setup for test +// // Create query conversion service +// service := NewService() + +// query := []byte(`{ +// "return": { +// "entities": [ +// 0 +// ], +// "relations": [] +// }, +// "entities": [ +// { +// "type": "airports", +// "constraints": [ +// { +// "attribute": "state", +// "value": "HI", +// "dataType": "text", +// "matchType": "exact" +// } +// ] +// } +// ], +// "relations": [], +// "limit": 5000, +// "modifiers": [ +// { +// "type": "SUM", +// "selectedType": "entity", +// "id": 0, +// "attributeIndex": 0 +// } +// ] +// }`) + +// // Unmarshall the incoming message into an IncomingJSONQuery object +// var JSONQuery entity.IncomingQueryJSON +// json.Unmarshal(query, &JSONQuery) + +// convertedResult, err := service.ConvertQuery(&JSONQuery) + +// // Assert that there is no error +// assert.NoError(t, err) + +// // Assert that the result and the expected result are the same +// correctConvertedResult := `LET n0 = (FOR x IN airports FILTER x.state == "HI" RETURN x)RETURN SUM (n0[*].state)` +// cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") +// cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") +// assert.Equal(t, correctConvertedResult, cleanedResult) +// } + +// func TestModifierCountRelation(t *testing.T) { +// // Setup for test +// // Create query conversion service +// service := NewService() + +// query := []byte(`{ +// "return": { +// "entities": [ +// 0 +// ], +// "relations": [ +// 0 +// ] +// }, +// "entities": [ +// { +// "type": "airports", +// "constraints": [ +// { +// "attribute": "state", +// "value": "HI", +// "dataType": "text", +// "matchType": "exact" +// } +// ] +// } +// ], +// "relations": [ +// { +// "type": "flights", +// "depth": { +// "min": 1, +// "max": 1 +// }, +// "entityFrom": 0, +// "entityTo": -1, +// "constraints": [ +// { +// "attribute": "Day", +// "value": "15", +// "dataType": "number", +// "matchType": "EQ" +// } +// ] +// } +// ], +// "limit": 5000, +// "modifiers": [ +// { +// "type": "COUNT", +// "selectedType": "relation", +// "id": 0, +// "attributeIndex": -1 +// } +// ] +// }`) + +// // Unmarshall the incoming message into an IncomingJSONQuery object +// var JSONQuery entity.IncomingQueryJSON +// json.Unmarshal(query, &JSONQuery) + +// convertedResult, err := service.ConvertQuery(&JSONQuery) + +// // Assert that there is no error +// assert.NoError(t, err) + +// // Assert that the result and the expected result are the same +// correctConvertedResult := `LET n0 = (FOR x IN airports FILTER x.state == "HI" RETURN x)LET r0 = (FOR x IN n0 FOR v, e, p IN 1..1 OUTBOUND x flights OPTIONS { uniqueEdges: "path" }FILTER p.edges[*].Day ALL == 15 RETURN DISTINCT p )RETURN LENGTH (unique(r0[*].edges[**]))` +// cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") +// cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") +// assert.Equal(t, correctConvertedResult, cleanedResult) +// } +// func TestModifierCountRelationAttribute(t *testing.T) { +// // Setup for test +// // Create query conversion service +// service := NewService() + +// query := []byte(`{ +// "return": { +// "entities": [ +// 0 +// ], +// "relations": [ +// 0 +// ] +// }, +// "entities": [ +// { +// "type": "airports", +// "constraints": [ +// { +// "attribute": "state", +// "value": "HI", +// "dataType": "text", +// "matchType": "exact" +// } +// ] +// } +// ], +// "relations": [ +// { +// "type": "flights", +// "depth": { +// "min": 1, +// "max": 1 +// }, +// "entityFrom": 0, +// "entityTo": -1, +// "constraints": [ +// { +// "attribute": "Day", +// "value": "15", +// "dataType": "number", +// "matchType": "EQ" +// } +// ] +// } +// ], +// "limit": 5000, +// "modifiers": [ +// { +// "type": "AVG", +// "selectedType": "relation", +// "id": 0, +// "attributeIndex": 0 +// } +// ] +// }`) + +// // Unmarshall the incoming message into an IncomingJSONQuery object +// var JSONQuery entity.IncomingQueryJSON +// json.Unmarshal(query, &JSONQuery) + +// convertedResult, err := service.ConvertQuery(&JSONQuery) + +// // Assert that there is no error +// assert.NoError(t, err) + +// // Assert that the result and the expected result are the same +// correctConvertedResult := `LET n0 = (FOR x IN airports FILTER x.state == "HI" RETURN x)LET r0 = (FOR x IN n0 FOR v, e, p IN 1..1 OUTBOUND x flights OPTIONS { uniqueEdges: "path" }FILTER p.edges[*].Day ALL == 15 RETURN DISTINCT p )RETURN AVG (r0[*].edges[**].Day)` +// cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") +// cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") +// assert.Equal(t, correctConvertedResult, cleanedResult) +// } + +func TestRelationWithInOutConstraint(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0, + 1 + ], + "relations": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + }, + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 3 + }, + "entityFrom": 1, + "entityTo": 0, + "constraints": [ + { + "attribute": "Day", + "value": "15", + "dataType": "number", + "matchType": "EQ" + } + ] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n1:airports)WHERE n1.state = "HI" MATCH p0 = (n1)-[r0:flights*1..3]->(n0)WHERE r0.Day = 15 RETURN n1,n0,p0;` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +func TestTwoRelations(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0, + 1, + 2 + ], + "relations": [ + 0, + 1 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "New York", + "dataType": "text", + "matchType": "exact" + } + ] + }, + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + }, + { + "type": "airports", + "constraints": [ + { + "attribute": "state", + "value": "HI", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 3 + }, + "entityFrom": 2, + "entityTo": 1, + "constraints": [ + { + "attribute": "Day", + "value": "15", + "dataType": "number", + "matchType": "EQ" + } + ] + }, + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": 0, + "entityTo": -1, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n2:airports)WHERE n2.state = "HI" MATCH p0 = (n2)-[r0:flights*1..3]->(n1)WHERE r0.Day = 15 RETURN n2,n1,p0;MATCH (n0:airports)WHERE n0.city = "New York" MATCH p0 = (n0)-[r0:flights*1..1]->()RETURN n0,p0;` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +func TestRelationWithOnlyToNode(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": -1, + "entityTo": 0, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n0:airports)WHERE n0.city = "San Francisco" MATCH p0 = (n0)-[r0:flights*1..1]->()RETURN n0,p0;` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +func TestTooManyReturnEntities(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0, + 1, + 2 + ], + "relations": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": -1, + "entityTo": 0, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + _, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.Equal(t, errors.New("non-existing entity referenced in return"), err) +} + +func TestTooManyReturnRelations(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [ + 0, + 1, + 2 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": -1, + "entityTo": 0, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + _, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.Equal(t, errors.New("non-existing relation referenced in return"), err) +} + +func TestNegativeReturnEntities(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0, + -1 + ], + "relations": [ + 0, + 1, + 2 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": -1, + "entityTo": 0, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + _, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.Equal(t, errors.New("non-existing entity referenced in return"), err) +} + +func TestNoRelationsField(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + convertedResult, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) + + // Assert that the result and the expected result are the same + correctConvertedResult := `MATCH (n0:airports)WHERE n0.city = "San Francisco" RETURN n0` + cleanedResult := strings.ReplaceAll(*convertedResult, "\n", "") + cleanedResult = strings.ReplaceAll(cleanedResult, "\t", "") + assert.Equal(t, correctConvertedResult, cleanedResult) +} + +func TestEntityFromLowerThanNegativeOneInRelation(t *testing.T) { + // Setup for test + // Create query conversion service + service := NewService() + + query := []byte(`{ + "return": { + "entities": [ + 0 + ], + "relations": [ + 0 + ] + }, + "entities": [ + { + "type": "airports", + "constraints": [ + { + "attribute": "city", + "value": "San Francisco", + "dataType": "text", + "matchType": "exact" + } + ] + } + ], + "relations": [ + { + "type": "flights", + "depth": { + "min": 1, + "max": 1 + }, + "entityFrom": -4, + "entityTo": 0, + "constraints": [] + } + ], + "limit": 5000 + }`) + + // Unmarshall the incoming message into an IncomingJSONQuery object + var JSONQuery entity.IncomingQueryJSON + json.Unmarshal(query, &JSONQuery) + + _, err := service.ConvertQuery(&JSONQuery) + + // Assert that there is no error + assert.NoError(t, err) +} diff --git a/main/main.go b/main/main.go index 1d4b065fdfb1b8602bb179896e98ad07067c3290..918738a23658e4f1b0458858d99216b230ec5c87 100644 --- a/main/main.go +++ b/main/main.go @@ -14,27 +14,10 @@ func main() { js := []byte(`{ "return": { "entities": [ - 0, - 1, - 2 - ], - "relations": [ - 0, - 1 + 0 ] }, "entities": [ - { - "type": "airports", - "constraints": [ - { - "attribute": "city", - "value": "New York", - "dataType": "text", - "matchType": "exact" - } - ] - }, { "type": "airports", "constraints": [ @@ -45,51 +28,90 @@ func main() { "matchType": "exact" } ] - }, - { - "type": "airports", - "constraints": [ - { - "attribute": "state", - "value": "HI", - "dataType": "text", - "matchType": "exact" - } - ] - } - ], - "relations": [ - { - "type": "flights", - "depth": { - "min": 1, - "max": 3 - }, - "entityFrom": 2, - "entityTo": 1, - "constraints": [ - { - "attribute": "Day", - "value": "15", - "dataType": "number", - "matchType": "EQ" - } - ] - }, - { - "type": "flights", - "depth": { - "min": 1, - "max": 1 - }, - "entityFrom": 0, - "entityTo": -1, - "constraints": [] } ], "limit": 5000 }`) + // js := []byte(`{ + // "return": { + // "entities": [ + // 0, + // 1, + // 2 + // ], + // "relations": [ + // 0, + // 1 + // ] + // }, + // "entities": [ + // { + // "type": "airports", + // "constraints": [ + // { + // "attribute": "city", + // "value": "New York", + // "dataType": "text", + // "matchType": "exact" + // } + // ] + // }, + // { + // "type": "airports", + // "constraints": [ + // { + // "attribute": "city", + // "value": "San Francisco", + // "dataType": "text", + // "matchType": "exact" + // } + // ] + // }, + // { + // "type": "airports", + // "constraints": [ + // { + // "attribute": "state", + // "value": "HI", + // "dataType": "text", + // "matchType": "exact" + // } + // ] + // } + // ], + // "relations": [ + // { + // "type": "flights", + // "depth": { + // "min": 1, + // "max": 3 + // }, + // "entityFrom": 2, + // "entityTo": 1, + // "constraints": [ + // { + // "attribute": "Day", + // "value": "15", + // "dataType": "number", + // "matchType": "EQ" + // } + // ] + // }, + // { + // "type": "flights", + // "depth": { + // "min": 1, + // "max": 1 + // }, + // "entityFrom": 0, + // "entityTo": -1, + // "constraints": [] + // } + // ], + // "limit": 5000 + // }`) + var inc entity.IncomingQueryJSON json.Unmarshal(js, &inc) result, _ := queryservice.ConvertQuery(&inc) diff --git a/main/node_modules/.yarn-integrity b/main/node_modules/.yarn-integrity new file mode 100644 index 0000000000000000000000000000000000000000..1a3aded6105fb67caa747e15081dd1543f4cb74b --- /dev/null +++ b/main/node_modules/.yarn-integrity @@ -0,0 +1,10 @@ +{ + "systemParams": "win32-x64-72", + "modulesFolders": [], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/main/yarn.lock b/main/yarn.lock new file mode 100644 index 0000000000000000000000000000000000000000..fb57ccd13afbd082ad82051c2ffebef4840661ec --- /dev/null +++ b/main/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +