/usr/share/perl5/Tangram/Expr/Coll/FromOne.pm is in libtangram-perl 2.10-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | package Tangram::Expr::Coll::FromOne;
use strict;
use Tangram::Expr::Coll;
use vars qw(@ISA);
@ISA = qw( Tangram::Expr::Coll );
sub includes
{
my ($self, $item) = @_;
my ($coll, $memdef) = @$self;
my $coll_tid = $coll->root_table;
my $item_class = $memdef->{class};
my $storage = $coll->{storage};
my $schema = $storage->{schema};
my $item_id;
if (ref($item))
{
if ($item->isa('Tangram::Expr::QueryObject'))
{
my $item_tid = $item->object->table($item_class);
return Tangram::Expr::Filter->new
(
expr => "t$item_tid.$memdef->{coll} = t$coll_tid.$schema->{sql}{id_col}",
tight => 100,
objects => Set::Object->new($coll, $item->object),
)
}
$item_id = $storage->export_object($item);
}
else
{
$item_id = $storage->{export_id}->($item);
}
my $remote = $storage->remote($item_class);
# FIXME - style inconsistency
return ($self->includes($remote) & ($remote->{id} == $item_id));
}
sub includes_or
{
my ($self, @items) = @_;
my ($coll, $memdef) = @$self;
my $coll_tid = $coll->root_table;
my $item_class = $memdef->{class};
my $item_tid;
my $storage = $coll->{storage};
my $schema = $storage->{schema};
my (@targets_fwd, @targets_rev);
my $objects = Set::Object->new
($coll,
);
foreach my $item (@items) {
if (ref($item))
{
if ($item->isa('Tangram::Expr::QueryObject'))
{
$item_tid = $item->object->table($item_class);
push @targets_fwd, ("t".$item_tid.".$memdef->{coll}");
$objects->insert($item->object);
}
else
{
#
#push @targets, ($storage->export_object($item));
push @targets_rev, ($storage->export_object($item));
}
}
else
{
push @targets_rev, $storage->{export_id}->($item);
}
}
my $expr;
if (@targets_fwd) {
my $joined_targets = join(',', @targets_fwd);
$expr =
Tangram::Expr::Filter->new
(
expr => "(t$coll_tid.$schema->{sql}{id_col} IN ($joined_targets))",
tight => 120,
objects => $objects,
);
}
if (@targets_rev) {
my $remote = $storage->remote($item_class);
#$objects->insert($remote);
my $item_tid = $remote->object->table($item_class);
my $joined_targets = join(',', @targets_rev);
my $new_expr =
Tangram::Expr::Filter->new
(
expr => "(t$item_tid.$schema->{sql}{id_col} in ($joined_targets))",
tight => 100,
objects => $objects,
);
if ($expr) {
return ( ( $self->includes($remote) & $new_expr ) | $expr );
}
return ( $self->includes($remote) & $new_expr );
}
return $expr;
}
|