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: Decouple db.db from gql #912

Merged
merged 8 commits into from
Oct 28, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Resolves #566 #905

Description

Further reorganizes a few areas to internally decouple defra.db from our GQL query language. It does not expose our query-model via the collection abi, as we may want further discussion around how to best do that from an UX perspective.

Change also enables the solving of #566, and brings the mapper package into the planner package.

Suggest reviewing commit-by-commit.

@AndrewSisley AndrewSisley added area/query Related to the query component area/parser Related to the parser components refactor This issue specific to or requires *notable* refactoring of existing codebases and components area/planner Related to the planner system labels Oct 24, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.4 milestone Oct 24, 2022
@AndrewSisley AndrewSisley requested a review from a team October 24, 2022 15:45
@AndrewSisley AndrewSisley self-assigned this Oct 24, 2022
@codecov
Copy link

codecov bot commented Oct 24, 2022

Codecov Report

Merging #912 (8546150) into develop (6c2c15f) will decrease coverage by 0.03%.
The diff coverage is 77.35%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #912      +/-   ##
===========================================
- Coverage    59.84%   59.80%   -0.04%     
===========================================
  Files          159      159              
  Lines        17335    17335              
===========================================
- Hits         10374    10368       -6     
- Misses        6036     6041       +5     
- Partials       925      926       +1     
Impacted Files Coverage Δ
planner/arbitrary_join.go 79.55% <ø> (ø)
planner/average.go 85.45% <ø> (ø)
planner/commit.go 83.13% <ø> (ø)
planner/count.go 95.95% <ø> (ø)
planner/create.go 63.63% <ø> (ø)
planner/datasource.go 55.88% <ø> (ø)
planner/delete.go 71.66% <ø> (ø)
planner/group.go 83.51% <ø> (ø)
planner/limit.go 97.77% <ø> (ø)
planner/mapper/aggregate.go 0.00% <ø> (ø)
... and 29 more

@source-devs
Copy link

Benchmark Results

Summary

  • 113 Benchmarks successfully compared.
  • 45 Benchmarks were ✅ Better.
  • 68 Benchmarks were ❌ Worse .
  • 0 Benchmarks were ✨ Unchanged.
✅ See Better Results...
time/opdelta
_Collection_UserSimple_CreateMany_Sync_0_100-4559ms ± 0%503ms ± 0%−9.89%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-4211ms ± 0%160ms ± 0%−24.30%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-4100ms ± 0%76ms ± 0%−23.70%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4881ms ± 0%686ms ± 0%−22.19%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-48.22s ± 0%7.83s ± 0%−4.65%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4768µs ± 0%539µs ± 0%−29.82%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-481.0ms ± 0%68.9ms ± 0%−14.90%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4572µs ± 0%548µs ± 0%−4.14%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-44.10ms ± 0%3.64ms ± 0%−11.12%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-439.0ms ± 0%36.4ms ± 0%−6.65%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-43.31ms ± 0%2.99ms ± 0%−9.56%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-42.56ms ± 0%2.40ms ± 0%−5.99%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-416.7ms ± 0%13.4ms ± 0%−19.92%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-413.9ms ± 0%12.7ms ± 0%−8.96%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4866µs ± 0%808µs ± 0%−6.64%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-41.38ms ± 0%1.33ms ± 0%−3.43%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-41.17ms ± 0%1.03ms ± 0%−11.33%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-415.1ms ± 0%14.5ms ± 0%−3.44%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4672µs ± 0%632µs ± 0%−5.87%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4765µs ± 0%615µs ± 0%−19.54%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-424.8µs ± 0%22.9µs ± 0%−7.95%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-428.5µs ± 0%26.2µs ± 0%−8.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4279µs ± 0%278µs ± 0%−0.09%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-435.2µs ± 0%34.1µs ± 0%−3.23%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4240µs ± 0%233µs ± 0%−2.57%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-490.4µs ± 0%78.9µs ± 0%−12.74%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-493.3µs ± 0%89.8µs ± 0%−3.84%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4242µs ± 0%207µs ± 0%−14.31%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4227µs ± 0%219µs ± 0%−3.61%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-42.10ms ± 0%1.98ms ± 0%−5.81%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-42.70ms ± 0%2.37ms ± 0%−12.05%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-42.06ms ± 0%1.98ms ± 0%−3.94%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4207µs ± 0%198µs ± 0%−4.37%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4203µs ± 0%186µs ± 0%−8.69%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4264µs ± 0%227µs ± 0%−14.06%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-42.15ms ± 0%2.14ms ± 0%−0.42%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-42.84ms ± 0%2.33ms ± 0%−17.84%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-413.8µs ± 0%13.0µs ± 0%−5.77%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-432.2µs ± 0%25.8µs ± 0%−19.89%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-4184µs ± 0%157µs ± 0%−14.29%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4192µs ± 0%192µs ± 0%−0.14%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4206µs ± 0%206µs ± 0%−0.22%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4227µs ± 0%186µs ± 0%−18.13%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.81ms ± 0%1.67ms ± 0%−8.01%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-42.21ms ± 0%2.08ms ± 0%−5.91%(p=1.000 n=1+1)
 
❌ See Worse Results...
time/opdelta
_Collection_UserSimple_Create_Sync_0_10-422.7ms ± 0%23.8ms ± 0%+4.92%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-41.83s ± 0%2.07s ± 0%+13.33%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-46.16ms ± 0%7.32ms ± 0%+18.83%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-46.06ms ± 0%6.78ms ± 0%+11.92%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4533µs ± 0%563µs ± 0%+5.67%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4395µs ± 0%434µs ± 0%+9.89%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4816µs ± 0%865µs ± 0%+6.02%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-42.12ms ± 0%2.45ms ± 0%+15.63%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4692µs ± 0%744µs ± 0%+7.52%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4668µs ± 0%727µs ± 0%+8.70%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-41.24ms ± 0%1.38ms ± 0%+11.65%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4706µs ± 0%867µs ± 0%+22.74%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-42.24ms ± 0%2.71ms ± 0%+21.11%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4504µs ± 0%541µs ± 0%+7.33%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-425.7µs ± 0%30.8µs ± 0%+20.14%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-433.6µs ± 0%39.7µs ± 0%+17.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4175µs ± 0%229µs ± 0%+30.94%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4205µs ± 0%232µs ± 0%+13.30%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4242µs ± 0%282µs ± 0%+16.64%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4346µs ± 0%396µs ± 0%+14.53%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-423.7µs ± 0%29.8µs ± 0%+25.36%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-422.2µs ± 0%28.0µs ± 0%+26.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-424.2µs ± 0%31.1µs ± 0%+28.68%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-437.7µs ± 0%41.5µs ± 0%+10.16%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4216µs ± 0%218µs ± 0%+0.95%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4275µs ± 0%284µs ± 0%+3.02%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4270µs ± 0%289µs ± 0%+7.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4356µs ± 0%448µs ± 0%+26.08%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-485.2µs ± 0%90.5µs ± 0%+6.26%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-494.6µs ± 0%128.9µs ± 0%+36.26%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-4133µs ± 0%165µs ± 0%+23.59%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4714µs ± 0%730µs ± 0%+2.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4766µs ± 0%776µs ± 0%+1.23%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4726µs ± 0%921µs ± 0%+26.87%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4820µs ± 0%833µs ± 0%+1.53%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4873µs ± 0%986µs ± 0%+12.99%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-483.5µs ± 0%110.7µs ± 0%+32.59%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-479.0µs ± 0%108.5µs ± 0%+37.34%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-494.3µs ± 0%132.5µs ± 0%+40.46%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-4106µs ± 0%114µs ± 0%+8.21%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-4114µs ± 0%162µs ± 0%+41.90%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4581µs ± 0%639µs ± 0%+9.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4636µs ± 0%799µs ± 0%+25.67%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4785µs ± 0%904µs ± 0%+15.22%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4817µs ± 0%898µs ± 0%+9.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4932µs ± 0%1220µs ± 0%+30.89%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4192µs ± 0%205µs ± 0%+7.12%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4211µs ± 0%214µs ± 0%+1.41%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4238µs ± 0%275µs ± 0%+15.68%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-42.09ms ± 0%2.15ms ± 0%+2.85%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-42.33ms ± 0%2.84ms ± 0%+22.13%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4206µs ± 0%214µs ± 0%+3.83%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4188µs ± 0%230µs ± 0%+22.34%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.77ms ± 0%2.17ms ± 0%+22.39%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-42.23ms ± 0%2.59ms ± 0%+16.24%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-42.25ms ± 0%2.31ms ± 0%+2.46%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-413.9µs ± 0%15.8µs ± 0%+13.67%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-418.9µs ± 0%20.4µs ± 0%+7.93%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-420.6µs ± 0%20.9µs ± 0%+1.26%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-4146µs ± 0%152µs ± 0%+3.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-4162µs ± 0%191µs ± 0%+18.00%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4253µs ± 0%269µs ± 0%+6.15%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4312µs ± 0%405µs ± 0%+29.76%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4211µs ± 0%222µs ± 0%+4.96%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4172µs ± 0%242µs ± 0%+40.89%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.93ms ± 0%2.10ms ± 0%+8.92%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.63ms ± 0%1.93ms ± 0%+18.82%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.91ms ± 0%1.92ms ± 0%+0.58%(p=1.000 n=1+1)
 
✨ See Unchanged Results...
time/opdelta
 
🐋 See Full Results...
develop.txtcurrent.txt
time/opdelta
pkg:collection goos:linux goarch:amd64
_Collection_UserSimple_CreateMany_Sync_0_10-423.0ms ± 0%22.5ms ± 0%−1.78%(p=1.000 n=1+1)
_Collection_UserSimple_CreateMany_Sync_0_100-4559ms ± 0%503ms ± 0%−9.89%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_10-422.7ms ± 0%23.8ms ± 0%+4.92%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-4211ms ± 0%160ms ± 0%−24.30%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-41.83s ± 0%2.07s ± 0%+13.33%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-4100ms ± 0%76ms ± 0%−23.70%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4881ms ± 0%686ms ± 0%−22.19%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-48.22s ± 0%7.83s ± 0%−4.65%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4768µs ± 0%539µs ± 0%−29.82%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-46.16ms ± 0%7.32ms ± 0%+18.83%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-481.0ms ± 0%68.9ms ± 0%−14.90%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4572µs ± 0%548µs ± 0%−4.14%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-46.06ms ± 0%6.78ms ± 0%+11.92%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4533µs ± 0%563µs ± 0%+5.67%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-44.10ms ± 0%3.64ms ± 0%−11.12%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-439.0ms ± 0%36.4ms ± 0%−6.65%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4395µs ± 0%434µs ± 0%+9.89%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-43.31ms ± 0%2.99ms ± 0%−9.56%(p=1.000 n=1+1)
pkg:query/simple goos:linux goarch:amd64
_Query_UserSimple_Query_Sync_10-4600µs ± 0%635µs ± 0%+5.76%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-42.56ms ± 0%2.40ms ± 0%−5.99%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-416.7ms ± 0%13.4ms ± 0%−19.92%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4816µs ± 0%865µs ± 0%+6.02%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-42.12ms ± 0%2.45ms ± 0%+15.63%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-413.9ms ± 0%12.7ms ± 0%−8.96%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4692µs ± 0%744µs ± 0%+7.52%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4866µs ± 0%808µs ± 0%−6.64%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4668µs ± 0%727µs ± 0%+8.70%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-41.38ms ± 0%1.33ms ± 0%−3.43%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-41.24ms ± 0%1.38ms ± 0%+11.65%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-41.17ms ± 0%1.03ms ± 0%−11.33%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4706µs ± 0%867µs ± 0%+22.74%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-42.24ms ± 0%2.71ms ± 0%+21.11%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-415.1ms ± 0%14.5ms ± 0%−3.44%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4672µs ± 0%632µs ± 0%−5.87%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4765µs ± 0%615µs ± 0%−19.54%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4504µs ± 0%541µs ± 0%+7.33%(p=1.000 n=1+1)
pkg:storage goos:linux goarch:amd64
_Storage_Simple_Read_Sync_1_10/ValueSize:0064-423.6µs ± 0%19.9µs ± 0%−15.66%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-424.8µs ± 0%22.9µs ± 0%−7.95%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-428.5µs ± 0%26.2µs ± 0%−8.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-425.7µs ± 0%30.8µs ± 0%+20.14%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-433.6µs ± 0%39.7µs ± 0%+17.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4175µs ± 0%229µs ± 0%+30.94%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4205µs ± 0%232µs ± 0%+13.30%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4242µs ± 0%282µs ± 0%+16.64%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4279µs ± 0%278µs ± 0%−0.09%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4346µs ± 0%396µs ± 0%+14.53%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-423.7µs ± 0%29.8µs ± 0%+25.36%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-422.2µs ± 0%28.0µs ± 0%+26.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-424.2µs ± 0%31.1µs ± 0%+28.68%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-435.2µs ± 0%34.1µs ± 0%−3.23%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-437.7µs ± 0%41.5µs ± 0%+10.16%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4216µs ± 0%218µs ± 0%+0.95%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4240µs ± 0%233µs ± 0%−2.57%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4275µs ± 0%284µs ± 0%+3.02%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4270µs ± 0%289µs ± 0%+7.18%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4356µs ± 0%448µs ± 0%+26.08%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-490.4µs ± 0%78.9µs ± 0%−12.74%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-485.2µs ± 0%90.5µs ± 0%+6.26%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-493.3µs ± 0%89.8µs ± 0%−3.84%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-494.6µs ± 0%128.9µs ± 0%+36.26%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-4133µs ± 0%165µs ± 0%+23.59%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4714µs ± 0%730µs ± 0%+2.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4766µs ± 0%776µs ± 0%+1.23%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4726µs ± 0%921µs ± 0%+26.87%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4820µs ± 0%833µs ± 0%+1.53%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4873µs ± 0%986µs ± 0%+12.99%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-483.5µs ± 0%110.7µs ± 0%+32.59%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-479.0µs ± 0%108.5µs ± 0%+37.34%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-494.3µs ± 0%132.5µs ± 0%+40.46%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-4106µs ± 0%114µs ± 0%+8.21%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-4114µs ± 0%162µs ± 0%+41.90%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4581µs ± 0%639µs ± 0%+9.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4636µs ± 0%799µs ± 0%+25.67%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4785µs ± 0%904µs ± 0%+15.22%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4817µs ± 0%898µs ± 0%+9.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4932µs ± 0%1220µs ± 0%+30.89%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4242µs ± 0%207µs ± 0%−14.31%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4192µs ± 0%205µs ± 0%+7.12%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4211µs ± 0%214µs ± 0%+1.41%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4227µs ± 0%219µs ± 0%−3.61%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4238µs ± 0%275µs ± 0%+15.68%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-42.10ms ± 0%1.98ms ± 0%−5.81%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-42.70ms ± 0%2.37ms ± 0%−12.05%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-42.06ms ± 0%1.98ms ± 0%−3.94%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-42.09ms ± 0%2.15ms ± 0%+2.85%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-42.33ms ± 0%2.84ms ± 0%+22.13%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4207µs ± 0%198µs ± 0%−4.37%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4203µs ± 0%186µs ± 0%−8.69%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4206µs ± 0%214µs ± 0%+3.83%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4188µs ± 0%230µs ± 0%+22.34%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4264µs ± 0%227µs ± 0%−14.06%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-42.15ms ± 0%2.14ms ± 0%−0.42%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.77ms ± 0%2.17ms ± 0%+22.39%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-42.23ms ± 0%2.59ms ± 0%+16.24%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-42.25ms ± 0%2.31ms ± 0%+2.46%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-42.84ms ± 0%2.33ms ± 0%−17.84%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-413.9µs ± 0%15.8µs ± 0%+13.67%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-413.8µs ± 0%13.0µs ± 0%−5.77%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-418.9µs ± 0%20.4µs ± 0%+7.93%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-420.6µs ± 0%20.9µs ± 0%+1.26%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-432.2µs ± 0%25.8µs ± 0%−19.89%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-4146µs ± 0%152µs ± 0%+3.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-4184µs ± 0%157µs ± 0%−14.29%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-4162µs ± 0%191µs ± 0%+18.00%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4253µs ± 0%269µs ± 0%+6.15%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4312µs ± 0%405µs ± 0%+29.76%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4192µs ± 0%192µs ± 0%−0.14%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4206µs ± 0%206µs ± 0%−0.22%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4227µs ± 0%186µs ± 0%−18.13%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4211µs ± 0%222µs ± 0%+4.96%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4172µs ± 0%242µs ± 0%+40.89%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.93ms ± 0%2.10ms ± 0%+8.92%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.63ms ± 0%1.93ms ± 0%+18.82%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.81ms ± 0%1.67ms ± 0%−8.01%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.91ms ± 0%1.92ms ± 0%+0.58%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-42.21ms ± 0%2.08ms ± 0%−5.91%(p=1.000 n=1+1)
 

@AndrewSisley AndrewSisley added the action/no-benchmark Skips the action that runs the benchmark. label Oct 24, 2022
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

Mostly looks good, sorry I think I got carried away with the Request and Query terminology suggestions, specially since we have introduced the request terminology more throughout the code. Feel free to ignore some of those as I think some of my comments might be out of scope, but would be nice to take care of some of those if they are fresh in your head at the moment.

_, err := exec.ParseRequestString(query)
if err != nil {
return errors.Wrap("failed to parse query string", err)
_, errs := parser.Parse(query)
Copy link
Member

Choose a reason for hiding this comment

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

todo: Rename Parse to ParseRequest?

Suggested change
_, errs := parser.Parse(query)
_, errs := parser.ParseRequest(query)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer Parse, as I dont think the suffix Request adds anything here, as well as being shorter and Request being covered by the type info (which shouldn't IMO be baked into the name unless avoiding collisions)

Copy link
Member

Choose a reason for hiding this comment

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

I prefer ParseRequest as previously it was ParseRequestString we also have two other methods on the interface called:

  • IsIntrospectionRequest(request string)
  • ExecuteIntrospectionRequest(request string)

I think it's clearer to have Request suffix, as right now the input variable is named query and can cause a confusion as well until we sort out the terminology properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I really doubt anyone will confuse Parse with IsIntrospectionRequest or ExecuteIntrospectionRequest, leaving as is unless someone else chimes in here.

Copy link
Member

Choose a reason for hiding this comment

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

I really doubt anyone will confuse Parse with IsIntrospectionRequest or ExecuteIntrospectionRequest, leaving as is unless someone else chimes in here.

I am not saying Parse can be confused with them, I meant that the Request suffix is already being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah... If all the functions on an interface have the same suffix, the suffix should probably be dropped from all of them as it adds nothing

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah... If all the functions on an interface have the same suffix, the suffix should probably be dropped from all of them as it adds nothing

I agree with that. The parser package's purpose is to handle requests. Adding the Request suffix doesn't improve clarity. I support dropping the suffix.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 27, 2022

Choose a reason for hiding this comment

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

  • Drop Request suffix from interface params (if they survive other discussion-threads)

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

👍Happy with dropping suffixes from all names, for sake of consistency.

tests/bench/query/planner/utils.go Outdated Show resolved Hide resolved
client/descriptions.go Show resolved Hide resolved
core/parser.go Outdated Show resolved Hide resolved
core/parser.go Show resolved Hide resolved
query/graphql/parser.go Show resolved Hide resolved
planner/query.go Show resolved Hide resolved
query/graphql/parser.go Show resolved Hide resolved
tests/bench/query/planner/utils.go Outdated Show resolved Hide resolved
@AndrewSisley AndrewSisley force-pushed the sisley/refactor/I905-decouple-from-gql-2 branch from 9582392 to e398c10 Compare October 25, 2022 15:03
@shahzadlone
Copy link
Member

shahzadlone commented Oct 25, 2022

Question: wondering from the commit title (refactor: Decouple defra.db from gql) what is meant by defra.db? are you talking about the specific package name db?

@AndrewSisley
Copy link
Contributor Author

Question: wondering from the commit title (refactor: Decouple defra.db from gql) what is meant by defra.db? are you talking about the specific package name db?

Ops, I am referring to the type db in package db, I'll tweak the name.

@AndrewSisley AndrewSisley changed the title refactor: Decouple defra.db from gql refactor: Decouple db.db from gql Oct 25, 2022
Copy link
Member

@shahzadlone shahzadlone left a comment

Choose a reason for hiding this comment

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

I do still prefer the ParseRequest over Parse. But it's a minor thing.

@shahzadlone
Copy link
Member

Question: wondering from the commit title (refactor: Decouple defra.db from gql) what is meant by defra.db? are you talking about the specific package name db?

Ops, I am referring to the type db in package db, I'll tweak the name.

Thanks, Cheers.

@AndrewSisley AndrewSisley force-pushed the sisley/refactor/I905-decouple-from-gql-2 branch from 95b348f to 2ffd5f3 Compare October 25, 2022 21:01
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

Looks good. Just one thought and one question.

Comment on lines +30 to +36
type Schema struct {
// The individual declarations of types defined by this schema.
Definitions []SchemaDefinition

// The collection descriptions created from/defined by this schema.
Descriptions []client.CollectionDescription
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: It seems weird to me that a Schema can have multiple definitions and descriptions. Maybe it's because I'm missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were defined and iterated over separately before I made the change, I think I mostly just needed/wanted a single return type instead of returning two params

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe then it would be appropriate to name it Schemas?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A single Schema supports multiple collections - this struct is a single Schema. SchemaDefinition and Definitions are a bit poorly named, but they are the old names and I want to avoid fixing everything in this PR. If any suggestions pop up I'll probably change these though if I'm about anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, they can be refactored in a future PR. Was actually thinking about just this the other day when working through some other stuff.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 28, 2022

Choose a reason for hiding this comment

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

I'll create a ticket and sort this out pretty soon after merge, it is important - as per discord discussion, but it is localized and not worth blocking the rest of the changes from going in

  • create ticket once other convos resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ticket: #922


// Parser represents the object responsible for handling stuff specific to
// a query language. This includes schema and query parsing, and introspection.
type Parser interface {
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Can you explain why you decided to put this interface in the core package? Ideally, interfaces are defined in the package where they are used. Since it's used in the db package, why not define it there?

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 27, 2022

Choose a reason for hiding this comment

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

Ideally, interfaces are defined in the package where they are used

This is very much a different mind set to most other langs IMO :) I can for sure see the merit with the way Golangs magic/inferred interfaces work though. I'll revisit this once the other structural threads have been resolved (in case I would otherwise end up changing this multiple times)

- [ ] Move Parser interface to db package?

Update: Leaving as is as mentioned deeper in the convo

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know it's different :) I may sound like a broken record at this point cuz I say this often, but I think it's important to follow the language recommended best practices as much as possible regardless of our habits with other langs. Bringing other cool pattern as additional gravy is fine though if it makes sense (i.e. Option type).

I agree with waiting on the other threads to be resolved.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 27, 2022

Choose a reason for hiding this comment

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

Ah :) I wasn't arguing with you one this one, as it is more a structural thing than just a styling thing - it'll probably be moved if it survives

Similar to the (positive) mindset shift RE pointers/ownership etc I experienced when learning Rust

Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you weren't ;)

Copy link
Member

Choose a reason for hiding this comment

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

I would also prefer to put these internal use packages into an internal/ directory.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Eg: If I (or anyone) wanted to play around in a new repo on some experimental tooling that maybe interacts with the core.Replicated type I wouldn't be able to as the internal stuff would block it.

yes. That's the point of internal. It block access by external packages. It does make the type accessible to any packages within the tree rooted at the parent of the internal directory. So if internal is a the root of defradb, then all our packages within defradb can access internal packages. But internal packages wont be part of our public APIs.

Copy link
Member

Choose a reason for hiding this comment

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

Lol.. Yes I'm aware, I'm saying I don't want that, as internal is too strict. I want the freedom to play with core (and other types) from other repos

Copy link
Collaborator

Choose a reason for hiding this comment

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

That does come with the requirement that we maintain those exposed types more carefully because external users can interact with them.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 28, 2022

Choose a reason for hiding this comment

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

That does come with the requirement that we maintain those exposed types more carefully because external users can interact with them.

50-50, we can declare that directly using anything but a subset of our packages is unsupported, but it is definitely not going to be clear enough to avoid the occasional support ticket coming through from someone external using pseudo-internal code, as well as occasional confusion for source devs.

Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

Overall looks great!

Main concern / change is to keep the GQL coupling for the schema stuff (as that is a FAR more complex aspect to decouple with respect to the future plans).

For the Query system, I think the decoupling looks great!

Lastly, wanted to add a comment on this PR (since its open) related to a previously closed PR for the parser. You moved mapper into the planner but I still think planner should be under query (note: just query, not query/graphql).

return strings.Contains(request, "IntrospectionQuery")
}

func (p *parser) ExecuteIntrospectionRequest(request string) *client.QueryResult {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: I don't think the "parser" should be responsible for executing Introspection Requests, even tho it has all the necessary information.

Fundementally, we should have a single execution API that runs Introspection, Explain, data requests, etc.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 27, 2022

Choose a reason for hiding this comment

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

Introspection is very much query-language dependent? You are introspecting the query language, not the collection/defra types

Copy link
Member

Choose a reason for hiding this comment

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

Indeed it's query language dependent. But from a DevEx perspective, having a single unified execution API feels more consistent. That entrypoint/API should of course delegate to the query language dependant implementation.

Moreover, having it on the Parser level, means that all implementations would need to support it, but its not necessarily the case that all future possible query langauges support the notion of "introspection".

If all requests are handed off to a language dependant Executor or Query or something, with an interface, then its up the the implementation to figure out what to do with the request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a DevEx perspective, this is internal code and provides a unified interface for doing anything query-language specific.

Moreover, having it on the Parser level, means that all implementations would need to support it, but its not necessarily the case that all future possible query langauges support the notion of "introspection".

That is not a problem specific to this PR and is present in develop. IMO the proposed code makes it easier to remove that need, but either way it is irrelevant to this PR.

Query introspection has nothing to do with our database or query execution, the only 'stuff' it touches is 100% query language dependent.

Copy link
Member

Choose a reason for hiding this comment

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

DevEx has to do with both external and internal developers. When I am making changes/working on the internals of the DB, it would be nice to have a single "Execute" API. The Introspection queries, are still queries, they just get their information from a diff location. All request execution should be through a single API as far as DevEx is concerned. That API implementation would of course go on to determine if its one of a series of kinds of queries supported by that query implementation, and take the appropriate action.

It just feels weird at the moment that an interface called "Parser" is handling a request exection.

Copy link
Member

Choose a reason for hiding this comment

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

For (future) language implementations that don't support "Introspection" would this just be an empty noop method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea, I dont see that as important to figure out now. That would be one possible solution, could also break up the interface and then check the type or something.

Copy link
Member

Choose a reason for hiding this comment

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

Since we've opened the door for this decoupled/abstracted layer for the query system, I think we could go full steam and really abstract everything related to processing requests.

If for example, we had a Requester in the query package, that works with a Parser and Executor interfaces, then we can make sure that the entire query lifecycle is handled by the respective implementation. This (imo) would solve the single execution API question, as well as having a more appropriate location for the Introspection on the executor, while leaving the parser for the parser.

Copy link
Member

Choose a reason for hiding this comment

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

note: Still using the one planner system tho obvi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could go full steam and really abstract everything related to processing requests

Not in this PR, it's scope is already large enough and it is starting to disrupt the team's dev flow.

I still strongly disagree that the introspection stuff should be in planner, as it has absolutely nothing to do with anything but the query language

core/parser.go Outdated
IsIntrospectionRequest(request string) bool

// Executes the given introspection request.
ExecuteIntrospectionRequest(request string) *client.QueryResult
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: (Commented on implementation in the query package, adding here) I don't think the parser should be responsible for Introspection execution. All execution should go through a single consistent API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesnt change the public API, and we can discuss the rest in the other comment on this topic

@@ -61,8 +60,7 @@ type db struct {

events client.Events

schema *schema.SchemaManager
Copy link
Member

Choose a reason for hiding this comment

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

thought: I think its OK to keep the GQL coupling on the schema level, as I don't see us supporting multiple schema languages. That isn't to say the query langauge can't have multiple implementations.

Therefore, I think its OK to keep a reference to the schema (manager) on the DB.

Copy link
Member

Choose a reason for hiding this comment

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

TLDR: The GQL coupling applies to queries, not schemas (imo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Therefore, I think its OK to keep a reference to the schema (manager) on the DB.

What for, it would be dead code atm (not to mention it contains types in the gql lib)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm in favour of decoupling if it doesn't impede our functionalities.

Copy link
Member

Choose a reason for hiding this comment

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

What for, it would be dead code atm (not to mention it contains types in the gql lib)

It would only be dead code if you kept everything about this PR the same. But this PR is two things, decouples Schema from GQL and decouples Query/Request language from GQL.

The query language should be decoupled as is written, but I don't think the schema should be decoupled. Thats a far more complex problem to be able to support different schema systems in one system. It should be a single consistent Schema approach, which can then be queried with whatever language (we implement).

Theres already enough complexities on the roadmap around schemas, I don't want to add this to it, if that makes sense. Perhaps once we get to a good place w.r.t to migration design.

For example/context: Fauna DB supports both FQL (their custom language) and GQL, so theyve decoupled their query language, but they only have a single language for schema definition. Dgraph does the same thing, supports DQL (their custom language) and GQL, but again, only a single schema definition language.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Oct 27, 2022

Choose a reason for hiding this comment

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

From what I can tell, youre (hoped) future plans would do the first step twice.

It would do a small subset of it (very roughly speaking) twice, FromSDL includes all the query input types (the bulk of the effort. Whereas the schema creation code only cares about field names and types (a simplification, but you get my point hopefully).

Copy link
Member

Choose a reason for hiding this comment

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

then we are not decoupled from gql

This is my point tho, "decoupled" is a somewhat loaded term, it is referring to two diff systems, schema and query. I'd prefer to not decouple the schema, as I feel like its unnecessary complicated and we don't get anything as there are no plans to ever not use SDL.

I'm 100% in favor of this PR as it relates to decoupling the query from GQL.

Copy link
Member

@jsimnz jsimnz Oct 27, 2022

Choose a reason for hiding this comment

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

Yes there would be duplication of effort. At the moment the code is conflating two different concepts and is using gql types (query-language dependent) to defined collectionDescriptions (query-language agnostic).

Indeed, the code conflates the two, as there was no need/goal to seperate them, but internally, they are actually seperated into two steps as seen here:

func (g *Generator) buildTypesFromAST(

Which is only responsible for taking the SDL, and returning structured GQL objects (without any query type generation, like filtering, sorting, aggregating, etc), just pure developer type as text (sdl) -> structured object.

Additionally, the collection descriptions use the gql objects defined above only, and only to then generate the descriptions, which themselves are free from GQL types technically (eg; we have our own definitions for Scalar types, field definitions, etc... independant from the GQL package).
https://github.com/sourcenetwork/defradb/blob/develop/query/graphql/schema/descriptions.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but internally, they are actually seperated into two steps as seen here

It is broken into two funcs sure, but if the first func calls the second it is not seperate.

We have two entirely separate systems collectionDescription generation and query-type generation, which have no reason to be coupled to each other, however they are and the collectionDescription code has been made dependent on the query-type generation code.

Conceptually there is no reason for this, and it causes some confusion. Technically the current system saves a few lines of code, but binds the two together - making substitution much harder, and increasing the damage done by any given bug (if query-generation fails in some way, collectionDescription-generation will likely also be impacted), as well as causing conceptual confusion. It also represents a significant complication to the maintaining of the code, as we now have one code block that must support the requirements of two entirely different systems/requirements/concepts (this IMO is the number one cause of crap and hard to maintain code in projects).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had a good chat on zoom with the team. Consensus largely achieved, there are some ways in which both the current and long-term goals can be more clearly described but they will be handled in a new issue (same issue as Schema type convo) to be picked up shortly after this is merged.

Comment on lines +626 to +634
return planner.MakePlan(&request.Request{
Queries: []*request.OperationDefinition{
{
Selections: []request.Selection{
slct,
},
},
},
})
Copy link
Member

Choose a reason for hiding this comment

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

thought: Might be nice to have some helpers on the request package to remove the labor in making such a request struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is a personal preference I think - I prefer this atm as you can see the structure that you are using

Copy link
Member

Choose a reason for hiding this comment

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

sounds good.

Parse(request string) (*request.Request, []error)

// Adds the given schema to this parser's model.
AddSchema(ctx context.Context, schema string) (*Schema, error)
Copy link
Member

Choose a reason for hiding this comment

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

thought: Might be able to drop the AddSchema API if based on my other comments, we don't remove the schema manager from the DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

parking this thought until the rest is resolved

Copy link
Member

Choose a reason for hiding this comment

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

👍

_, err := exec.ParseRequestString(query)
if err != nil {
return errors.Wrap("failed to parse query string", err)
_, errs := parser.Parse(query)
Copy link
Member

Choose a reason for hiding this comment

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

I think hes saying for consistency of naming of the interface methods. I have a slight preference for ParseRequest but not significantly.

Removes odd function from collection/db abi that uses gql schema manager for internal query logic.
Decouples the `defra.db` type from the gql.parser, allowing other query languages to (in theory) be swapped in instead.  Does not expose this decoupling to users, as that requires futher thought and design.
Function now uses the request model.  Keeps things more cleanly seperated, at a small performance cost.
Declares it's usage to be internal to the planner package, hopefull discouraging it's usage outside, and hopefully clarifying it's purpose. Is a straight cut-paste, no logic has changed in this commit.
@AndrewSisley AndrewSisley force-pushed the sisley/refactor/I905-decouple-from-gql-2 branch from 2ffd5f3 to b31db1b Compare October 28, 2022 16:51
@AndrewSisley
Copy link
Contributor Author

Last push was just a rebase on latest develop

@AndrewSisley AndrewSisley merged commit 42b7c0e into develop Oct 28, 2022
@AndrewSisley AndrewSisley deleted the sisley/refactor/I905-decouple-from-gql-2 branch October 28, 2022 18:44
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Replace relationManager call with collection logic

Removes odd function from collection/db abi that uses gql schema manager for internal query logic.

* Decouple db type from gql parser

Decouples the `defra.db` type from the gql.parser, allowing other query languages to (in theory) be swapped in instead.  Does not expose this decoupling to users, as that requires futher thought and design.

* Remove misuse of mapper types from collection func

Function now uses the request model.  Keeps things more cleanly seperated, at a small performance cost.

* Rename planner constructor

* Remove unhelpful func

* Remove executor

* Move mapper internal to planner

Declares it's usage to be internal to the planner package, hopefull discouraging it's usage outside, and hopefully clarifying it's purpose. Is a straight cut-paste, no logic has changed in this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/parser Related to the parser components area/planner Related to the planner system area/query Related to the query component refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revisit Select case in planner.newPlan
5 participants