Skip to content

Commit

Permalink
change to intoField
Browse files Browse the repository at this point in the history
  • Loading branch information
DieMyst committed Jun 5, 2024
1 parent 27b199b commit ecff7d6
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ object ApplyStreamMapRawInliner {
private def mang[S: Mangler](name: String, suffix: String): State[S, String] =
Mangler[S].findAndForbidName(s"-${name}_$suffix")

private def intoField(vm: VarModel, field: String, errorMsg: String): VarModel =
vm.intoField(field).getOrElse(internalError(errorMsg))

// - fold a map in parallel
// - when a key matches index, push result to a stream
// - return the stream
Expand All @@ -49,18 +52,12 @@ object ApplyStreamMapRawInliner {
ForModel(iter.name, mapVar, ForModel.Mode.Never).wrap(
XorModel.wrap(
MatchMismatchModel(
iter
.withProperty(
IntoFieldModel("key", ScalarType.string)
),
intoField(iter, "key", "Unexpected. No 'key' field in 'getStream'"),
idxVar,
true
).wrap(
PushToStreamModel(
iter
.withProperty(
IntoFieldModel("value", mapType.element)
),
intoField(iter, "value", "Unexpected. No 'value' field in 'getStream'"),
CallModel.Export(streamVar)
).leaf
)
Expand All @@ -87,10 +84,7 @@ object ApplyStreamMapRawInliner {
ParModel.wrap(
ForModel(iter.name, mapVar, ForModel.Mode.Never).wrap(
PushToStreamModel(
iter
.withProperty(
IntoFieldModel("key", ScalarType.string)
),
intoField(iter, "key", "Unexpected. No 'key' field in 'getKeysStream'"),
CallModel.Export(streamVar.name, streamVar.`type`)
).leaf,
NextModel(iter.name).leaf
Expand Down Expand Up @@ -121,10 +115,7 @@ object ApplyStreamMapRawInliner {
CanonicalizeModel(mapVar, CallModel.Export(canonMap)).leaf,
ForModel(iter.name, canonMap).wrap(
PushToStreamModel(
iter
.withProperty(
IntoFieldModel("key", ScalarType.string)
),
intoField(iter, "key", "Unexpected. No 'key' field in 'keys'"),
CallModel.Export(streamVar)
).leaf,
NextModel(iter.name).leaf
Expand Down

0 comments on commit ecff7d6

Please sign in to comment.