-
Notifications
You must be signed in to change notification settings - Fork 168
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
Add Seq.fullOuterJoin() #275
Labels
Milestone
Comments
Below is a rough example of a workaround: import static java.util.Optional.*;
import static org.jooq.lambda.Seq.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.jooq.lambda.Seq;
import org.jooq.lambda.tuple.Tuple2;
import org.junit.Test;
import lombok.Value;
public class JoolTest {
@Test
public void matchPositions() {
List<Position> client1Positions = Stream.of(Position.of("ticker1", "client1", 0.0),
Position.of("ticker2", "client1", 0.0), Position.of("ticker4", "client1", 0.0))
.collect(Collectors.toList());
List<Position> client2Positions = Stream.of(Position.of("ticker1", "client2", 0.0),
Position.of("ticker3", "client2", 0.0), Position.of("ticker4", "client2", 0.0))
.collect(Collectors.toList());
Seq<Tuple2<Position, Position>> leftJoinClient1ToClient2 = seq(client1Positions).leftOuterJoin(client2Positions,
Position::sameTicker);
Seq<Tuple2<Position, Position>> rightJoinClient1ToClient2 = seq(client1Positions)
.rightOuterJoin(client2Positions, Position::sameTicker);
// Expected Output:
//
// (JoolTest.Position(ticker=ticker1, client=client1, notional=0.0), JoolTest.Position(ticker=ticker1,
// client=client2, notional=0.0))
// (JoolTest.Position(ticker=ticker2, client=client1, notional=0.0), null)
// (JoolTest.Position(ticker=ticker4, client=client1, notional=0.0), JoolTest.Position(ticker=ticker4,
// client=client2, notional=0.0))
// (null, JoolTest.Position(ticker=ticker3, client=client2, notional=0.0))
leftJoinClient1ToClient2.concat(rightJoinClient1ToClient2)
.distinct()
.stream()
.forEach(System.out::println);
}
@Value(staticConstructor = "of")
static class Position {
String ticker;
String client;
double notional;
public boolean sameTicker(Position that) {
return ofNullable(that).filter(t -> getTicker().equals(t.getTicker()))
.isPresent();
}
} |
Thanks, @jmax01 |
YETSDD
added a commit
to YETSDD/jOOL
that referenced
this issue
May 31, 2020
Add the fullOuterJoin and fullOuterSelfJoin functions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: