weld-project / weld

High-performance runtime for data analytics applications

Home Page:https://www.weld.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Struct builders

segeljakt opened this issue · comments

The docs say:

Any struct whose fields are builders can also be used as a builder. This is used to build multiple results at the same time.

But, when I compile:

|source: vec[i32]|
    let final = for(source, {appender[i32], appender[i32]}, |sink, index, element|
        merge(sink, {element, element})
    );
    {result(final.$0), result(final.$1)}

I get:

[info] 15:49:09.591: Started weld_module_compile
[info] 15:49:09.594: Started parsing program
[info] 15:49:09.608: Done parsing program
[info] 15:49:09.608: Started compiling program
[debug] 15:49:09.611: After macro substitution:
|source:vec[i32]|
  (let final:?=(for(
    source:?,
    {appender[i32],appender[i32]},
    |sink:?,index:?,element:?|
      merge(sink:?,{element:?,element:?})
  ));{result(
    final.$0
  ),result(
    final.$1
  )})

[info] 15:49:09.612: Done compiling program
REPL: Compile error: Internal error: Merge called on non-builder
>>>

My expectation was that you could merge structs which only contain builders, and also call result on structs which only contain builders.

Ok, thanks, makes sense :)

I have another question regarding builders. What happens internally in Weld when you swap the field positions of two builders? E.g:

|source: vec[i32]|
    let final = for(source, {appender[i32], appender[i32]}, |sink, index, element|
        {merge(sink.$1, 1), merge(sink.$0, 0)}
    );
    {result(final.$0), result(final.$1)}