[erlang-questions] why the mnesia operations are divided into two parts?

devdoer bird devdoer2@REDACTED
Sun Jul 20 05:35:30 CEST 2008


HI:

I'm reading mnesia  source code right now. I found all the mnesia operation
such as read/write/transform_table are divided into two parts.One part  is
in mnesia_shcema:read ,the other part is in mnesia_shcmma:prepare_op.

Take transform_table for example,the transform_table function calls
make_transform_table to return  "[{op, transform, Fun, cs2list(Cs2)}];".
And the real transform_table is done in

"prepare_op(_Tid, {op, transform, Fun, TabDef}, _WaitFor) "

,then the prepare_op finally call the Fun the do the transform.

Now I know the the two parts are done in sperate process,the make_transform
is done in user-process,the prepare_op is in mnesia kernel process .The
function  make_transform insert op "transform " into a ets table,the
prepare_ops parse the op "transform" to many small ops on the fly.

 My problem is
1. I can't see why the main work is put into prepare_op. Why don't do all
the work  in make_transform function?
2. What the function prepare_op is used for? I see many mnesia operations
are done in this way.

Could someone explain more to me?

Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080720/a5d1c531/attachment.htm>


More information about the erlang-questions mailing list