-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(compiler): CRDT-maps implementation #1142
Merged
Merged
Changes from 90 commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
7fbb552
WIP
DieMyst 2aa40ff
use more MutableStreamType instead of StreamType, fix arrow inlining
DieMyst ec6cbf4
add `get` function inliner, WIP
DieMyst e7945f8
fix return type for `get`, add integration test
DieMyst 1ca49ec
Merge remote-tracking branch 'origin/main' into stream-maps-implement…
DieMyst f3b1c07
fix type
DieMyst 5d3f029
fix compilation
DieMyst fdde502
change `get` strategy
DieMyst 8f571ef
use var for idx
DieMyst 9c1e4d6
extend test
DieMyst e913982
fix compilation
DieMyst 1c5d4c6
`getStream` func implementation and test
DieMyst 90cae35
fix test
DieMyst 331d199
fix test
DieMyst be1aa5e
keys implementation and test
DieMyst 6b46780
fix test
DieMyst bca70e4
contains func implementation
DieMyst b728af5
fold over map and tests
DieMyst b6cc9a5
fix compilation
DieMyst fb2f1a8
change canon "#" to "#$"
DieMyst f00ea6e
are values not arrays?
DieMyst 7ff3f57
fix compilation
DieMyst a2d8394
fix test value
DieMyst 0273a5d
fix value test
DieMyst c3b2c01
refactoring
DieMyst e6ab134
keysStream implementation
DieMyst 3bb8b79
Merge branch 'main' into stream-maps-implementation
DieMyst 4c73704
fix unit tests
DieMyst 9c5e241
refactoring
DieMyst 4be3156
parsing stream map unit test
DieMyst 2c2caa4
error on exporting function that returns or accepts stream map
DieMyst 5b40397
add comments
DieMyst 80e9f69
parseq test
DieMyst 77f63c7
fix compilation
DieMyst ddf6f61
parseq for map test
DieMyst 925bcfa
fix compilation
DieMyst 6ccfe7b
fix compilation
DieMyst 4c8eefe
Update integration-tests/src/__test__/examples.spec.ts
DieMyst ba9fa6e
fix PR
DieMyst dd3661b
for and parseq with tuples
DieMyst 421452a
fix
DieMyst 5436e9f
fix compilation
DieMyst 17eafe2
fix
DieMyst 0854adc
canon map before for
DieMyst e95ff0d
fix unit tests
DieMyst 06ec9be
fix unit test
DieMyst 3a9aec6
fix unit tests
DieMyst bf12d9b
fix
DieMyst 6b1d105
println
DieMyst b1e0e96
println
DieMyst 84f6b91
fix
DieMyst 292ad58
let -> const
DieMyst a4195a4
PR fixes
DieMyst 97ecb13
fix
DieMyst 1e30e6f
fix test
DieMyst ea034dc
use canon stream instead of array
DieMyst 5fa5e61
try to fix
DieMyst 3313802
try to fix
DieMyst fc6dd43
use scalar in `keys` func
DieMyst ce63777
return to canonstreammap
DieMyst d5f1752
add comment
DieMyst 21fc97c
Update types/src/main/scala/aqua/types/Type.scala
DieMyst d3cc038
Update types/src/main/scala/aqua/types/Type.scala
DieMyst 28a4858
PR fixes
DieMyst 3953bf0
PR fixes
DieMyst 4eb1a60
Merge branch 'main' into stream-maps-implementation
DieMyst e314f06
Update model/inline/src/main/scala/aqua/model/inline/tag/ForTagInline…
DieMyst 2f55f72
Update semantics/src/main/scala/aqua/semantics/expr/func/ForSem.scala
DieMyst 7642198
Merge branch 'main' into stream-maps-implementation
DieMyst 971fc15
fix compilation
DieMyst 40dba48
PR fixes
DieMyst 0cd02f1
try without flattens
DieMyst fbd2d49
fix compilation
DieMyst 5f73ac6
revert flatten, add test
DieMyst a4f890f
fix compilation, flat indexes for IntoIndexModel
DieMyst ba26e35
fix test
DieMyst a4ae5f7
add comment
DieMyst 111a2a0
semantic error on using `<-` with maps
DieMyst 1c0992f
don't use braces
DieMyst 05b9d73
fix parsing, unskip old test
DieMyst 9088610
add capture tests for stream map, fix unit tests for parser
DieMyst 100473a
restrictions test
DieMyst 2fb193e
fix compilation
DieMyst 701fe54
fix compilation
DieMyst 3b5b392
check if map on the left when pushing tuple
DieMyst 2ffeff8
test streams and maps in abilities
DieMyst aae9be0
fix ts compilation
DieMyst 5eb29f1
skip test
DieMyst 27b199b
fix tests
DieMyst ecff7d6
change to `intoField`
DieMyst 0801091
refactoring
DieMyst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,128 @@ | ||
aqua Job declares * | ||
aqua StreamMapTest declares * | ||
|
||
use "declare" | ||
export testGetFunc, testGetStreamFunc, testKeysFunc, testKeysStreamFunc | ||
export testContainsFunc, testForFunc, testParSeqMap, testForTupleFunc | ||
|
||
export timeout | ||
import "builtin.aqua" | ||
|
||
func timeout() -> AquaName.Worker: | ||
w <- AquaName.getWorker() | ||
a = w.host_id | ||
<- w | ||
func testGetFunc() -> []string, []string, []string, u32: | ||
streamMap: %string | ||
key = "key" | ||
resEmpty = streamMap.get(key) | ||
streamMap <<- key, "first value" | ||
resFirst = streamMap.get(key) | ||
streamMap <<- key, "second value" | ||
resSecond = streamMap.get(key) | ||
<- resEmpty, resFirst, resSecond, resSecond.length | ||
|
||
func testGetStreamFunc() -> []string, string, string: | ||
streamMap: %string | ||
key = "key" | ||
resEmptyStream = streamMap.getStream(key) | ||
streamMap <<- key, "first value" | ||
resFirstStream = streamMap.getStream(key) | ||
streamMap <<- key, "second value" | ||
resSecondStream = streamMap.getStream(key) | ||
resFirst = resFirstStream[0] | ||
resSecond = resSecondStream[1] | ||
<- resEmptyStream, resFirst, resSecond | ||
|
||
func testKeysFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
resEmpty = streamMap.keys() | ||
streamMap <<- "key one", "" | ||
resFirst = streamMap.keys() | ||
streamMap <<- "key two", "" | ||
streamMap <<- "key one", "" | ||
streamMap <<- "key one", "text" | ||
resSecond = streamMap.keys() | ||
<- resEmpty, resFirst, resSecond | ||
|
||
func testKeysStreamFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
resEmpty = streamMap.keysStream() | ||
streamMap <<- "key one", "" | ||
resFirst = streamMap.keysStream() | ||
streamMap <<- "key one", "new" | ||
streamMap <<- "key two", "" | ||
resSecond = streamMap.keysStream() | ||
<- resEmpty, resFirst, resSecond | ||
|
||
func testContainsFunc() -> bool, bool, bool, bool, bool: | ||
keys = ["key one", "key two"] | ||
streamMap: %string | ||
resFirst = streamMap.contains(keys[0]) | ||
streamMap <<- keys[0], "" | ||
resSecond = streamMap.contains(keys[0]) | ||
resThird = streamMap.contains(keys[1]) | ||
streamMap <<- keys[0], "new" | ||
streamMap <<- keys[1], "" | ||
resFourth = streamMap.contains(keys[0]) | ||
resFifth = streamMap.contains(keys[1]) | ||
<- resFirst, resSecond, resThird, resFourth, resFifth | ||
|
||
func testForFunc() -> []string, []string: | ||
streamMap: %string | ||
streamMap <<- "key one", "1" | ||
streamMap <<- "key one", "2" | ||
|
||
streamMap <<- "key two", "3" | ||
streamMap <<- "key two", "4" | ||
streamMap <<- "key two", "5" | ||
|
||
streamMap <<- "key three", "6" | ||
|
||
streamMap <<- "key four", "7" | ||
|
||
streamKeys: *string | ||
streamValues: *string | ||
|
||
for kv <- streamMap: | ||
streamKeys <<- kv.key | ||
streamValues <<- kv.value | ||
<- streamKeys, streamValues | ||
|
||
func testParSeqMap(relay1: string, relay2: string, relay3: string) -> string: | ||
relays = [relay1, relay2, relay3] | ||
map: %u64 | ||
map2: %u64 | ||
parseq r <- relays on r: | ||
map <<- "time", Peer.timestamp_ms() | ||
|
||
for r <- relays par: | ||
on r: | ||
join map.get("time")[relays.length - 1] | ||
map2 <<- "time", Peer.timestamp_ms() | ||
|
||
join map2.get("time")[relays.length - 1] | ||
<- "ok" | ||
|
||
func testForTupleFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
streamMap <<- "key one", "1" | ||
streamMap <<- "key one", "2" | ||
|
||
streamMap <<- "key two", "3" | ||
streamMap <<- "key two", "4" | ||
streamMap <<- "key two", "5" | ||
|
||
streamMap <<- "key three", "6" | ||
|
||
streamMap <<- "key four", "7" | ||
|
||
streamFirst: *string | ||
streamSecond: *string | ||
streamThird: *string | ||
|
||
for k, v <- streamMap: | ||
streamFirst <<- k | ||
streamSecond <<- v | ||
|
||
for k, v <- streamMap: | ||
streamFirst <<- v | ||
streamSecond <<- k | ||
|
||
for k, v <- streamMap: | ||
streamThird <<- streamMap.get(k)! | ||
|
||
<- streamFirst, streamSecond, streamThird |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
aqua Builtin declares * | ||
|
||
-- Default public interface of Fluence nodes | ||
|
||
alias Field : []string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
aqua StreamMapTest declares * | ||
|
||
export testGetFunc, testGetStreamFunc, testKeysFunc, testKeysStreamFunc | ||
export testContainsFunc, testForFunc, testParSeqMap, testForTupleFunc | ||
|
||
import "@fluencelabs/aqua-lib/builtin.aqua" | ||
|
||
func testGetFunc() -> []string, []string, []string, u32: | ||
streamMap: %string | ||
key = "key" | ||
resEmpty = streamMap.get(key) | ||
streamMap <<- key, "first value" | ||
resFirst = streamMap.get(key) | ||
streamMap <<- key, "second value" | ||
resSecond = streamMap.get(key) | ||
<- resEmpty, resFirst, resSecond, resSecond.length | ||
|
||
func testGetStreamFunc() -> []string, string, string: | ||
streamMap: %string | ||
key = "key" | ||
resEmptyStream = streamMap.getStream(key) | ||
streamMap <<- key, "first value" | ||
resFirstStream = streamMap.getStream(key) | ||
streamMap <<- key, "second value" | ||
resSecondStream = streamMap.getStream(key) | ||
resFirst = resFirstStream[0] | ||
resSecond = resSecondStream[1] | ||
<- resEmptyStream, resFirst, resSecond | ||
|
||
func testKeysFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
resEmpty = streamMap.keys() | ||
streamMap <<- "key one", "" | ||
resFirst = streamMap.keys() | ||
streamMap <<- "key two", "" | ||
streamMap <<- "key one", "" | ||
streamMap <<- "key one", "text" | ||
resSecond = streamMap.keys() | ||
<- resEmpty, resFirst, resSecond | ||
|
||
func testKeysStreamFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
resEmpty = streamMap.keysStream() | ||
streamMap <<- "key one", "" | ||
resFirst = streamMap.keysStream() | ||
streamMap <<- "key one", "new" | ||
streamMap <<- "key two", "" | ||
resSecond = streamMap.keysStream() | ||
join resFirst[0] | ||
join resSecond[2] | ||
<- resEmpty, resFirst, resSecond | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not we join on result streams? |
||
|
||
func testContainsFunc() -> bool, bool, bool, bool, bool: | ||
keys = ["key one", "key two"] | ||
streamMap: %string | ||
resFirst = streamMap.contains(keys[0]) | ||
streamMap <<- keys[0], "" | ||
resSecond = streamMap.contains(keys[0]) | ||
resThird = streamMap.contains(keys[1]) | ||
streamMap <<- keys[0], "new" | ||
streamMap <<- keys[1], "" | ||
resFourth = streamMap.contains(keys[0]) | ||
resFifth = streamMap.contains(keys[1]) | ||
<- resFirst, resSecond, resThird, resFourth, resFifth | ||
|
||
func testForFunc() -> []string, []string: | ||
streamMap: %string | ||
streamMap <<- "key one", "1" | ||
streamMap <<- "key one", "2" | ||
|
||
streamMap <<- "key two", "3" | ||
streamMap <<- "key two", "4" | ||
streamMap <<- "key two", "5" | ||
|
||
streamMap <<- "key three", "6" | ||
|
||
streamMap <<- "key four", "7" | ||
|
||
streamKeys: *string | ||
streamValues: *string | ||
|
||
for kv <- streamMap: | ||
streamKeys <<- kv.key | ||
streamValues <<- kv.value | ||
<- streamKeys, streamValues | ||
|
||
func testParSeqMap(relay1: string, relay2: string, relay3: string) -> string: | ||
relays = [relay1, relay2, relay3] | ||
map: %u64 | ||
map2: %u64 | ||
parseq r <- relays on r: | ||
map <<- "time", Peer.timestamp_ms() | ||
|
||
for r <- relays par: | ||
on r: | ||
join map.getStream("time")[relays.length - 1] | ||
map2 <<- "time", Peer.timestamp_ms() | ||
|
||
join map2.getStream("time")[relays.length - 1] | ||
<- "ok" | ||
|
||
func testForTupleFunc() -> []string, []string, []string: | ||
streamMap: %string | ||
streamMap <<- "key one", "1" | ||
streamMap <<- "key one", "2" | ||
|
||
streamMap <<- "key two", "3" | ||
streamMap <<- "key two", "4" | ||
streamMap <<- "key two", "5" | ||
|
||
streamMap <<- "key three", "6" | ||
|
||
streamMap <<- "key four", "7" | ||
|
||
streamFirst: *string | ||
streamSecond: *string | ||
streamThird: *string | ||
|
||
for k, v <- streamMap: | ||
streamFirst <<- k | ||
streamSecond <<- v | ||
|
||
for k, v <- streamMap: | ||
streamFirst <<- v | ||
streamSecond <<- k | ||
|
||
for k, v <- streamMap: | ||
streamThird <<- streamMap.get(k)! | ||
|
||
<- streamFirst, streamSecond, streamThird |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
aqua StreamMapAbilities | ||
|
||
export streamMapAbilityTest | ||
|
||
ability Streams: | ||
stream: *string | ||
map: %string | ||
|
||
ability Adds: | ||
addToStream(s: string) | ||
addToMap(k: string, v: string) | ||
|
||
func addToStreamClosure(str: *string) -> string -> (): | ||
cl = func (s: string): | ||
str <<- s | ||
<- cl | ||
|
||
func addToMapClosure(str: %string) -> string, string -> (): | ||
cl = func (k: string, v: string): | ||
str <<- k, v | ||
<- cl | ||
|
||
func addTo{Streams}() -> Adds: | ||
addStream = addToStreamClosure(Streams.stream) | ||
addMap = addToMapClosure(Streams.map) | ||
adds = Adds(addToStream = addStream, addToMap = addMap) | ||
<- adds | ||
|
||
func add{Adds}(s: string, k: string): | ||
Adds.addToStream(s) | ||
Adds.addToMap(k, k) | ||
|
||
func streamMapAbilityTest() -> []string, []string: | ||
stream: *string | ||
map: %string | ||
ab = Streams(stream = stream, map = map) | ||
adds <- addTo{ab}() | ||
add{adds}("one", "1") | ||
add{adds}("two", "2") | ||
add{adds}("three", "3") | ||
<- stream, map.keys() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
<-
seems more canonical for function call