public static ComputeStepSyntaxElement<SplitDataset> splitDataset(
        final Collection<Dataset> parents,
        final EventCondition condition)
    {
        final ClassFields fields = new ClassFields();
        final ValueSyntaxElement ifData = fields.add(new ArrayList<>());
        final ValueSyntaxElement elseData = fields.add(new ArrayList<>());
        final ValueSyntaxElement right = fields.add(DatasetCompiler.Complement.class);
        final VariableDefinition event =
            new VariableDefinition(JrubyEventExtLibrary.RubyEvent.class, "event");
        fields.addAfterInit(
            Closure.wrap(
                SyntaxFactory.assignment(
                    right,
                    SyntaxFactory.cast(
                        DatasetCompiler.Complement.class, SyntaxFactory.constant(
                            DatasetCompiler.class, DatasetCompiler.Complement.class.getSimpleName()
                        ).call("from", SyntaxFactory.identifier("this"), elseData)
                    )
                )
            )
        );
        final ValueSyntaxElement conditionField = fields.add(condition);
        final DatasetCompiler.ComputeAndClear compute;
        if (parents.isEmpty()) {
            compute = withOutputBuffering(
                conditionalLoop(event, BATCH_ARG, conditionField, ifData, elseData),
                Closure.wrap(clear(elseData)), ifData, fields
            );
        } else {
            final Collection<ValueSyntaxElement> parentFields =
                parents.stream().map(fields::add).collect(Collectors.toList());
            final ValueSyntaxElement inputBuffer = fields.add(new ArrayList<>());
            compute = withOutputBuffering(
                withInputBuffering(
                    conditionalLoop(event, inputBuffer, conditionField, ifData, elseData),
                    parentFields, inputBuffer
                ),
                clearSyntax(parentFields).add(clear(elseData)), ifData, fields
            );
        }
        return ComputeStepSyntaxElement.create(
            Arrays.asList(compute.compute(), compute.clear(), MethodSyntaxElement.right(right)),
            compute.fields(), SplitDataset.class
        );
    }
@Test
    public void compilesSplitDataset() {
        final FieldReference key = FieldReference.from("foo");
        final SplitDataset left = DatasetCompiler.splitDataset(
            Collections.emptyList(), event -> event.getEvent().includes(key)
        ).instantiate();
        final Event trueEvent = new Event();
        trueEvent.setField(key, "val");
        final JrubyEventExtLibrary.RubyEvent falseEvent =
            JrubyEventExtLibrary.RubyEvent.newRubyEvent(RubyUtil.RUBY, new Event());
        final Dataset right = left.right();
        @SuppressWarnings("rawtypes")
        final RubyArray batch = RubyUtil.RUBY.newArray(
            JrubyEventExtLibrary.RubyEvent.newRubyEvent(RubyUtil.RUBY, trueEvent), falseEvent
        );
        assertThat(left.compute(batch, false, false).size(), is(1));
        assertThat(right.compute(batch, false, false).size(), is(1));
    }