-
Notifications
You must be signed in to change notification settings - Fork 5
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
Idea: index + join #22
Comments
I like it! Setting the Regarding |
Just for record, here is my proof of concept: use Modern::Perl;
use PDL;
sub join_demo {
my ($left_idx, $left_data, $right_idx, $right_data, $how) = @_;
my $all_idx;
if ($how eq 'inner') {
# inner join
$all_idx = setops($left_idx, 'AND', $right_idx);
}
elsif ($how eq 'outer') {
# full outer join
$all_idx = setops($left_idx, 'OR', $right_idx);
}
elsif ($how eq 'left') {
# left outer join
$all_idx = setops($left_idx, 'OR', setops($left_idx, 'AND', $right_idx));
}
elsif ($how eq 'right') {
# right outer join
$all_idx = setops($right_idx, 'OR', setops($left_idx, 'AND', $right_idx));
}
else {
die "invalid how='$how'";
}
my $new_left_idx = vsearch_match($all_idx, $left_idx);
$new_left_idx = $new_left_idx->setbadif($new_left_idx < 0);
my $new_left = $left_data->index1d($new_left_idx);
my $new_right_idx = vsearch_match($all_idx, $right_idx);
$new_right_idx = $new_right_idx->setbadif($new_right_idx < 0);
my $new_right = $right_data->index1d($new_right_idx);
say "OUT.I($how):", $all_idx;
say "OUT.L($how):", $new_left;
say "OUT.R($how):", $new_right;
}
my $lidx = pdl(long, [0, 1, 2, 4, 5, 6 ]);
my $ldata = pdl(double, [1.1, 2.2, 3.3, 4.4, 5.5, 6.6 ]);
my $ridx = pdl(long, [ 1, 2, 3, 4, 6, 7 ]);
my $rdata = pdl(double, [ 9.7, 9.6, 9.5, 9.4, 9.3, 9.2]);
say "IN.L:", $lidx, " ", $ldata;
say "IN.R:", $ridx, " ", $rdata;
join_demo($lidx, $ldata, $ridx, $rdata, 'outer');
join_demo($lidx, $ldata, $ridx, $rdata, 'inner');
join_demo($lidx, $ldata, $ridx, $rdata, 'left');
join_demo($lidx, $ldata, $ridx, $rdata, 'right'); The output:
|
Hi Zaki, UPDATE on this issue: after some experiments with your The code is available here https://gist.github.com/kmx/c46859f002b93a6c3683 - it is called --kmx |
Hi Zaki,
I would like to propose the following enhancements:
index
option that can be passed tonew()
join
See the code below which demonstrates what I am talking about. In my real use case the
index
will be a PDL (LongLong) with kind of a timestamps.At this moment it is just an idea (no patch, no pull request).
The text was updated successfully, but these errors were encountered: