Hello,
 
  It also looks to my that the interface should be something as as simple as:
 
  db aggregate_function step_func final_func
 
 
> But it seemed to me that all  it should take is to create a normal TCL
 > function to be called for each  row selected (say, to compute the sums
 > and squares  and products), with  some initialization code  run before
 > the select, and some more code to run when the select is done (say, to
 > compute the correlation coeffiecient between two columns).
 
I would like to expain the type of problem that I am trying to solve in order to
recieve comments and opinions about its feasibility.
 
I work in the field of computer simulation for engineering, notably Finite
Element analysis. These types of problems have traditionally been solved
programming in either FORTRAN or C/C++ due to the big amount of
data to deal with and that they are very computer intensive. One run can
be of minutes, hours or even days.
 
The approach has some disadvantages. For example, the amount of developing
time just dedicated to deal with data structs is huge and also, any change
to the logic of the program can require a big amount of programming.
 
I want to experiment with a new way of dealing with the problem, by using
sqlite and a mixure of C++ and TCL.
 
Instead of just fetch data from the database and operate on it, I want to try
a different approach: make the process database driven.
 
So, instead of:
 
     loop on "select ...."
     do my algorithm
     end loop
 
I want to try something like:
 
   db eval {
            select add_elem_k_triangle(e.num,
            e.euler1,e.euler2,e.euler3,
            m.units,m.thickness,m.specific_weight,m.E,m.nu,
            n1.num*6,n2.num*6,n3.num*6,
            n1.x,n1.y,n1.z,n2.x,n2.y,n2.z,n3.x,n3.y,n3.z)
            from elements_triangles as e
            join material_isotropic_shell as m on m.num = e.mat
            join nodes as n1 on e.c1 = n1.num
            join nodes as n2 on e.c2 = n2.num
            join nodes as n3 on e.c3 = n3.num
        }
 
  where function "add_elem_k_triangle" is the one that make the
real algorithm work and can be implemented either in TCL or in C++
 
Currently "add_elem_k_triangle" is a normal function that operates on
external structures and has nothing to return for every element. I think
that in this case, it would be better that "add_elem_k_triangle" was an
aggregate function that returned something trivial, like the number of
elements that has operated with. In this way, A lot of void returns could
be avoided.
 
I understand that it is not simple to explain a problem like this in a few
lines but I hope that some "big picture" has been given.
 
> What version are you looking at?  The latest Tcl bindings already
> do this.
 
 I looked at version 3.2.1 and the code is:
 
static void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){
  SqlFunc *p = sqlite3_user_data(context);
  Tcl_DString cmd;
  int i;
  int rc;
 
  Tcl_DStringInit(&cmd);
  Tcl_DStringAppend(&cmd, p->zScript, -1);
  for(i=0; i<argc; i++){
    if( SQLITE_NULL==sqlite3_value_type(argv[i]) ){
      Tcl_DStringAppendElement(&cmd, "");
    }else{
      Tcl_DStringAppendElement(&cmd, sqlite3_value_text(argv[i]));
    }
  }
  rc = Tcl_Eval(p->interp, Tcl_DStringValue(&cmd));
  if( rc ){
    sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1); 
  }else{
    sqlite3_result_text(context, Tcl_GetStringResult(p->interp), -1, 
        SQLITE_TRANSIENT);
  }
}
 
So, it uses strings for the arguments.
 
  Best regards,
 



▬▬▬▬


Compass Ing. y Sistemas

Dr. Ramon Ribó


http://www.compassis.com <http://www.compassis.com/> 

[EMAIL PROTECTED] <outbind://116/[EMAIL PROTECTED]> 


c/ Tuset, 8 7-2

tel. +34 93 218 19 89


08006 Barcelona, Spain

fax. +34 93 396 97 46

 

 

Reply via email to