Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Cypher.Map #3147

Merged
merged 6 commits into from
Apr 5, 2023
Merged

Refactor Cypher.Map #3147

merged 6 commits into from
Apr 5, 2023

Conversation

angrykoala
Copy link
Member

Description

This is a brief refactor of Cypher.Map and Cypher.MapProjection to use a Map internally to better match the actual use case and add support for .size() method.

@changeset-bot
Copy link

changeset-bot bot commented Apr 3, 2023

🦋 Changeset detected

Latest commit: 633d713

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@neo4j/cypher-builder Minor
@neo4j/graphql Patch
@neo4j/graphql-toolbox Patch
@neo4j/graphql-ogm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-advanced-security
Copy link

You have successfully added a new CodeQL configuration .github/workflows/pull-requests.yml:code-scanning. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@angrykoala angrykoala requested a review from a-alle April 3, 2023 17:13
@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Apr 3, 2023

Performance Report

No Performance Changes

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregate 3403 3403 43 82 1134
aggregations.NestedAggregation 14551 14551 85 93 2174
aggregations.AggregationWithWhere 11979 11979 54 64 2174
aggregations.AggregationWhereWithinNestedRelationships 22116987 22116987 3531 3311 2008534
aggregations.AggregationWhereWithinNestedConnections 22116987 22116987 3176 3260 2008534
aggregations.NestedCountFromMovieToActors 9734 9734 52 71 2174
aggregations.NestedCountFromActorsToMovie 9937 9937 54 66 2174
aggregations.DeeplyNestedCount 13070331 13070331 5716 5693 2008534
batch-create.BatchCreate 4200 4200 155 252 600
connect.createAndConnect 14424 14424 240 299 3003
connections.Connection 14082 14082 73 66 2174
connections.NestedConnection 41468 41466 135 208 4516
connections.ConnectionWithSort 2282 2282 77 105 1040
connections.ConnectionWithSortAndCypher 2282 2282 235 458 1040
create.SimpleMutation 7 7 64 77 1
cypher-directive.TopLevelCypherDirective 116092 116092 707 709 12241
cypher-directive.TopLevelCypherDirectiveWithColumnName 147609 147609 198 260 12241
delete.SimpleDelete 19401 19401 298 383 1040
delete.NestedDeleteInUpdate 22200 22200 187 239 2040
2925.SingleRelationshipFilter 6468 6468 89 48 1040
2925.NestedSingleRelationshipFilter 22900 22900 82 104 2174
2925.SingleRelationshipRequiredFilter 3450 3450 32 34 1134
2925.NestedSingleRelationshipRequiredFilter 9383 9383 53 79 1040
query.SimpleQuery 15160 15160 51 69 2174
query.QueryWhere 9716 9708 39 48 2167
query.SimpleQueryWithNestedWhere 9894 9886 57 95 2167
query.Nested 10092037 10092037 10186 10688 2008534
query.NestedWithFilter 40401 40401 176 144 4511
query.OrFilterOnRelationships 43231 43161 195 238 1974
query.OrFilterOnRelationshipsAndNested 37121 37061 237 293 1974
query.QueryWithNestedIn 13951 13865 81 147 1402
query.NestedConnectionWhere 9834 9834 61 191 2174
query.DeeplyNestedConnectionWhere 10044 9965 93 174 2174
query.DeeplyNestedWithRelationshipFilters 19230 19164 157 200 1630
query.NestedWithRelationshipSingleFilters 3024400 3024400 864 814 1003942
query.Fulltext 96 96 31 34 16
query.FulltextWithNestedQuery 587 587 50 54 84
sorting.SortMultipleTypes 2513 2513 82 88 1040
sorting.SortMultipleTypesWithCypherWithCypher 1444 1472 210 325 1040
sorting.SortOnNestedFields 14082 14082 81 63 2174
sorting.SortDeeplyNestedFields 42196 42196 102 129 4516
sorting.SortWithTopLevelCypher 2119 2119 135 426 1040
unions.SimpleUnionQuery 321 321 72 76 35
unions.SimpleUnionQueryWithMissingFields 293 293 80 85 35
unions.NestedUnion 410637 410637 313 310 33033
unions.NestedUnionWithMissingFields 384611 384611 288 373 33033
update.NestedUpdate 2119 2119 67 81 1040

Old Schema Generation: 49.689s
Schema Generation: 49.056s
Old Subgraph Schema Generation: 1:03.655 (m:ss.mmm)
Subgraph Schema Generation: 1:05.056 (m:ss.mmm)

MacondoExpress
MacondoExpress previously approved these changes Apr 4, 2023
Copy link
Contributor

@MacondoExpress MacondoExpress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left some minor comments.
I just drop something that I have in mind for this area.
As future improvements, I suggest accepting entries as a parameter, to avoid the client potentially building a Record from a list of entries that will be destructured in an array of entries anyway in Cypher Builder, an example of that is present in create-projection-and-params.ts where it could be easier to refactor with Cypher Builder if Map Projection accepts a list of entries, from create-projection-and-params.ts

if (alias !== field.name || dbFieldName !== field.name || literalElements) {
    res.projection.push(
        new Cypher.RawCypher(
            (env) =>
                `${alias}: ${varName.property(dbFieldName).getCypher(env)}`
        )
    );
} 

@angrykoala
Copy link
Member Author

@MacondoExpress
That's an interesting point, we can discuss other possible Map constructors for future improvements

@angrykoala angrykoala merged commit 2bc2c70 into neo4j:dev Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants