Martin Kersten wrote:
Steffen Goeldner wrote:
BTW: I'm not very enthusiastic about the DBI/MIL 'marriage' too. I support it because it was already there. A separate perl module, more in the spirit of MIL, may be more convenient. (Is it true that you plan a MIL successor? It may be wiser to delay my musing until then ...)
There is (a lot of) work in progress...
I'm curious!
but could you give a hint towards your ideas of an 'ideal' world? Would you opt for a direct linkage of the kernel routines with a Perl wrapper?
Yeah, BAT's in perl space would be great (or - even better - n-ary relations). And ideally, we would have location transparency, i.e. we would be able to, say, join a local temporary relation with a remote persistent one. Back to reality though. What I find most annoying with SQL/CLI, ODBC, JDBC, DBI etc. is it's host language integration (or lack thereof). For instance, SQL statements are embedded in strings - I consider this as a low level protocol layer. People try to invent host language counterparts, e.g. Schema::Table->find( key => 'value') It's possible to elaborate this approach somewhat, but you'll encounter difficulties soon. For MIL, I think, the chances are somewhat better (at least for the algebra module). A perlish counterpart could look like: use MonetDB::IL(); my $b = MonetDB::IL->bat('int','int'); $b->insert( 2, 22 ); $b->insert( 1, 11 ); $b->print; $b->sort->print; my $c = $b->slice( 1, 1 ); $c->print; $b->diff( $c )->print; my $d = $b->reverse; $d->print; $d->union( $c )->print; $d->project( 77 )->print; The attached module supports these sketchy trials. Perhaps, eventually, I try to push this approach as far as it can go (and maybe a little beyond ;-) Steffen package MonetDB::IL; sub bat { my $class = shift; MonetDB::IL::BAT->new("new( $_[0], $_[1] )"); } package MonetDB::IL::BAT; use MapiLib(); my $mapi = MapiLib::mapi_connect( (undef) x 5 ) or die 'Cxn failed!'; die MapiLib::mapi_error_str( $mapi ) if MapiLib::mapi_error( $mapi ); my $hdl = MapiLib::mapi_new_handle( $mapi ); my $i = 1; sub _do { my $statement = shift; print "\n>$statement\n"; MapiLib::mapi_query_handle( $hdl,"$statement;"); my $err = MapiLib::mapi_result_error( $hdl ); die $err if $err; die MapiLib::mapi_error_str( $mapi ) if MapiLib::mapi_error( $mapi ); } sub new { my $class = shift; my $statement = shift; my $name = "my_bat_$i"; $i++; _do("var $name := $statement"); bless { Name => $name }, $class; } sub print { my $self = shift; _do("print( $self->{Name} )"); while ( MapiLib::mapi_fetch_row( $hdl ) ) { printf "[ %s %s ]\n", MapiLib::mapi_fetch_field( $hdl, 0 ) , MapiLib::mapi_fetch_field( $hdl, 1 ); } } sub DESTROY { } sub AUTOLOAD { my $self = shift; my $s = $AUTOLOAD; $s =~ s/.*:://; my @p = map { ref $_ ? $_->{Name} : $_ } @_; $s .= '( ' . join(', ', $self->{Name}, @p ) . ' )'; return ref( $self )->new( $s ) if defined wantarray and not wantarray; _do( $s ); } 1;