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

Implement more flows ops methods part 3 #76

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

emil-bar
Copy link
Contributor

@emil-bar emil-bar commented Dec 20, 2024

Closes #68

@emil-bar emil-bar force-pushed the implement-more-flows-ops-methods-part-3 branch 3 times, most recently from 68b814c to 03d328c Compare December 30, 2024 13:15
* groupBy
* groupedWithin
* groupedWeightedWithin
* mapStateful
* mapStatefulConcat
+ alsoTo small fix
@emil-bar emil-bar force-pushed the implement-more-flows-ops-methods-part-3 branch from 03d328c to 2498438 Compare December 30, 2024 13:27
@emil-bar emil-bar marked this pull request as ready for review December 30, 2024 13:33
* @param element current input flow element
* @return pair of new state and `element` mapped to new type `U`
*/
Map.Entry<S, U> apply(S state, T element);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can stick with Map.Entry or create custom Pair implementation (I believe there is no point in depending on other library for this).

The main problem with Map.Entry is that it does not allow null as first/key argument (which makes sense from Map implementation point of view), but it created some problems for next implementations.

Copy link
Member

Choose a reason for hiding this comment

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

Map.Entry sounds good - do we really use null anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In ox we used null as marker for lines method.
I used Optional for workaround https://github.com/softwaremill/jox/pull/77/files#diff-46d2537d747d24775cf70630d584ac42326ea6902d3ddd10f5a861841c2c3b6cR722

Overall we can leave it as it is

Copy link
Member

Choose a reason for hiding this comment

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

Ah, Optional is better :) 👍

* @param <U> type of output flow
*/
@FunctionalInterface
public interface StatefulMapper<T, S, U> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Overall I've added those interfaces to make the code more readable. If it makes it more blurry for you, I can remove it.

Copy link
Member

Choose a reason for hiding this comment

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

No, this looks good :)

import com.softwaremill.jox.structured.Scopes;
import com.softwaremill.jox.structured.UnsupervisedScope;

class GroupByImpl<T, V, U> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewritten from Scala

import java.util.NoSuchElementException;
import java.util.Optional;

class WeightedHeap<T> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewritten from scala

import com.softwaremill.jox.flows.WeightedHeap.HeapNode;
import org.junit.jupiter.api.Test;

class WeightedHeapTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All rewritten from Scala

@adamw adamw merged commit c7fb12d into main Dec 31, 2024
2 checks passed
@adamw adamw deleted the implement-more-flows-ops-methods-part-3 branch December 31, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement more flows ops methods - part 3
2 participants