Ets Question

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Ets Question

Alex Peake
I am using ets at the "top level" as I experiment and develop my program.

Unfortunatley, every time I make an error, I lose all my dictionaries and
have to re-initialize.

How am I supposed to do this?

Thanks,

Alex




Reply | Threaded
Open this post in threaded view
|

Ets Question

Håkan Mattsson-6
On Thu, 23 May 2002, Alex Peake wrote:

Alex> I am using ets at the "top level" as I experiment and develop my program.
Alex>
Alex> Unfortunatley, every time I make an error, I lose all my dictionaries and
Alex> have to re-initialize.
Alex>
Alex> How am I supposed to do this?

The trick is to keep the process that owns your ets-tables alive.
Misspellings and other errors may easily cause your shell process to die.

When working interactively in the Erlang shell you can use two shells.
Create the tables in one shell, start yet another shell (control-g, s, c)
and go ahead and make all the errors that you need. ;-)

/H?kan

---
H?kan Mattsson
Ericsson
Computer Science Laboratory
http://www.ericsson.com/cslab/~hakan/



Reply | Threaded
Open this post in threaded view
|

Ets Question

Alex Peake
Thanks for the suggestion Hakan,

Trouble is, in the second shell, the table is not visible.

1>  ets:lookup(vbDecl, varchar).
** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
                    {erl_eval,expr,3},
                    {erl_eval,exprs,4},
                    {shell,eval_loop,2}]} **

=ERROR REPORT==== 24-May-2002::22:30:40 ===
Error in process <0.22.0> with exit value:
{badarg,[{ets,lookup,[vbDecl,varchar]},{erl_eval,expr,3},{erl_eval,exprs,4},
{shell,eval_loop,2}]}

But in the shell I start it in:

1> vbDecl:init().
true
2> ets:lookup(vbDecl, varchar).
[{varchar,"As String"}]

The above was in XEmacs. In the regular (werl) shell:

Erlang (BEAM) emulator version 5.1.1 [threads:0]

Eshell V5.1.1  (abort with ^G)
1> ets:lookup(vbDecl, varchar).

=ERROR REPORT==== 24-May-2002::22:33:49 ===
Error in process <0.25.0> with exit value:
{badarg,[{ets,lookup,[vbDecl,varchar]
},{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
                    {erl_eval,expr,3},
                    {erl_eval,exprs,4},
                    {shell,eval_loop,2}]} **

Am I missing something?

Alex


> -----Original Message-----
> From: hakan [mailto:hakan]On Behalf Of
> Hakan Mattsson
> Sent: Thursday, May 23, 2002 11:20 PM
> To: Alex Peake
> Cc: erlang-questions
> Subject: Re: Ets Question
>
>
> On Thu, 23 May 2002, Alex Peake wrote:
>
> Alex> I am using ets at the "top level" as I experiment and
> develop my program.
> Alex>
> Alex> Unfortunatley, every time I make an error, I lose all my
> dictionaries and
> Alex> have to re-initialize.
> Alex>
> Alex> How am I supposed to do this?
>
> The trick is to keep the process that owns your ets-tables alive.
> Misspellings and other errors may easily cause your shell process to die.
>
> When working interactively in the Erlang shell you can use two shells.
> Create the tables in one shell, start yet another shell (control-g, s, c)
> and go ahead and make all the errors that you need. ;-)
>
> /H?kan
>
> ---
> H?kan Mattsson
> Ericsson
> Computer Science Laboratory
> http://www.ericsson.com/cslab/~hakan/
>
>




Reply | Threaded
Open this post in threaded view
|

Ets Question

Matthias Lang-2
Hi,

I can but guess what your vbDecl module is doing, perhaps you forgot
to make the table a named table:

   Erlang (BEAM) emulator version 5.1.1 [source]
   
   Eshell V5.1.1  (abort with ^G)
   1> self().
   <0.23.0>
   2> ets:new(mytable, [public, named_table]).
   mytable
   3>
   User switch command
    --> s
    --> c
   Eshell V5.1.1  (abort with ^G)
   1> self().
   <0.43.0>
   2> ets:lookup(mytable, bla).
   []

Matthias

--------------------

Alex Peake writes:

 > Trouble is, in the second shell, the table is not visible.
 >
 > 1>  ets:lookup(vbDecl, varchar).
 > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
 >                     {erl_eval,expr,3},
 >                     {erl_eval,exprs,4},
 >                     {shell,eval_loop,2}]} **
 >
 > =ERROR REPORT==== 24-May-2002::22:30:40 ===
 > Error in process <0.22.0> with exit value:
 > {badarg,[{ets,lookup,[vbDecl,varchar]},{erl_eval,expr,3},{erl_eval,exprs,4},
 > {shell,eval_loop,2}]}
 >
 > But in the shell I start it in:
 >
 > 1> vbDecl:init().
 > true
 > 2> ets:lookup(vbDecl, varchar).
 > [{varchar,"As String"}]
 >
 > The above was in XEmacs. In the regular (werl) shell:
 >
 > Erlang (BEAM) emulator version 5.1.1 [threads:0]
 >
 > Eshell V5.1.1  (abort with ^G)
 > 1> ets:lookup(vbDecl, varchar).
 >
 > =ERROR REPORT==== 24-May-2002::22:33:49 ===
 > Error in process <0.25.0> with exit value:
 > {badarg,[{ets,lookup,[vbDecl,varchar]
 > },{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
 > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
 >                     {erl_eval,expr,3},
 >                     {erl_eval,exprs,4},
 >                     {shell,eval_loop,2}]} **
 >
 > Am I missing something?
 >
 > Alex


Reply | Threaded
Open this post in threaded view
|

Ets Question

Alex Peake
Thanks for the suggestion, but no, that is not the problem:

    ets:new(vbDecl,[set,public,named_table,{keypos,1}])
    ets:insert(vbDecl,{varchar, "As String"}),


Alex


> -----Original Message-----
> From: owner-erlang-questions
> [mailto:owner-erlang-questions]On Behalf Of Matthias Lang
> Sent: Saturday, May 25, 2002 3:42 AM
> To: Alex Peake
> Cc: Hakan Mattsson; erlang-questions
> Subject: RE: Ets Question
>
>
> Hi,
>
> I can but guess what your vbDecl module is doing, perhaps you forgot
> to make the table a named table:
>
>    Erlang (BEAM) emulator version 5.1.1 [source]
>    
>    Eshell V5.1.1  (abort with ^G)
>    1> self().
>    <0.23.0>
>    2> ets:new(mytable, [public, named_table]).
>    mytable
>    3>
>    User switch command
>     --> s
>     --> c
>    Eshell V5.1.1  (abort with ^G)
>    1> self().
>    <0.43.0>
>    2> ets:lookup(mytable, bla).
>    []
>
> Matthias
>
> --------------------
>
> Alex Peake writes:
>
>  > Trouble is, in the second shell, the table is not visible.
>  >
>  > 1>  ets:lookup(vbDecl, varchar).
>  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
>  >                     {erl_eval,expr,3},
>  >                     {erl_eval,exprs,4},
>  >                     {shell,eval_loop,2}]} **
>  >
>  > =ERROR REPORT==== 24-May-2002::22:30:40 ===
>  > Error in process <0.22.0> with exit value:
>  >
> {badarg,[{ets,lookup,[vbDecl,varchar]},{erl_eval,expr,3},{erl_eval
> ,exprs,4},
>  > {shell,eval_loop,2}]}
>  >
>  > But in the shell I start it in:
>  >
>  > 1> vbDecl:init().
>  > true
>  > 2> ets:lookup(vbDecl, varchar).
>  > [{varchar,"As String"}]
>  >
>  > The above was in XEmacs. In the regular (werl) shell:
>  >
>  > Erlang (BEAM) emulator version 5.1.1 [threads:0]
>  >
>  > Eshell V5.1.1  (abort with ^G)
>  > 1> ets:lookup(vbDecl, varchar).
>  >
>  > =ERROR REPORT==== 24-May-2002::22:33:49 ===
>  > Error in process <0.25.0> with exit value:
>  > {badarg,[{ets,lookup,[vbDecl,varchar]
>  > },{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
>  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
>  >                     {erl_eval,expr,3},
>  >                     {erl_eval,exprs,4},
>  >                     {shell,eval_loop,2}]} **
>  >
>  > Am I missing something?
>  >
>  > Alex
>



Reply | Threaded
Open this post in threaded view
|

Ets Question

Thomas Lange
Your problem is that you are running two erlang
nodes ( different processes in OS ).
They can never exchange data since you have no erlang
distribution running.

Every time you run werl, you launch a new node.

In order to have 2 shells in the same node, do like
Matthias did in his example ( ctrl-G ) to launch
a second shell.

/Thomas


Alex Peake wrote:

>
> Thanks for the suggestion, but no, that is not the problem:
>
>     ets:new(vbDecl,[set,public,named_table,{keypos,1}])
>     ets:insert(vbDecl,{varchar, "As String"}),
>
> Alex
>
> > -----Original Message-----
> > From: owner-erlang-questions
> > [mailto:owner-erlang-questions]On Behalf Of Matthias Lang
> > Sent: Saturday, May 25, 2002 3:42 AM
> > To: Alex Peake
> > Cc: Hakan Mattsson; erlang-questions
> > Subject: RE: Ets Question
> >
> >
> > Hi,
> >
> > I can but guess what your vbDecl module is doing, perhaps you forgot
> > to make the table a named table:
> >
> >    Erlang (BEAM) emulator version 5.1.1 [source]
> >
> >    Eshell V5.1.1  (abort with ^G)
> >    1> self().
> >    <0.23.0>
> >    2> ets:new(mytable, [public, named_table]).
> >    mytable
> >    3>
> >    User switch command
> >     --> s
> >     --> c
> >    Eshell V5.1.1  (abort with ^G)
> >    1> self().
> >    <0.43.0>
> >    2> ets:lookup(mytable, bla).
> >    []
> >
> > Matthias
> >
> > --------------------
> >
> > Alex Peake writes:
> >
> >  > Trouble is, in the second shell, the table is not visible.
> >  >
> >  > 1>  ets:lookup(vbDecl, varchar).
> >  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
> >  >                     {erl_eval,expr,3},
> >  >                     {erl_eval,exprs,4},
> >  >                     {shell,eval_loop,2}]} **
> >  >
> >  > =ERROR REPORT==== 24-May-2002::22:30:40 ===
> >  > Error in process <0.22.0> with exit value:
> >  >
> > {badarg,[{ets,lookup,[vbDecl,varchar]},{erl_eval,expr,3},{erl_eval
> > ,exprs,4},
> >  > {shell,eval_loop,2}]}
> >  >
> >  > But in the shell I start it in:
> >  >
> >  > 1> vbDecl:init().
> >  > true
> >  > 2> ets:lookup(vbDecl, varchar).
> >  > [{varchar,"As String"}]
> >  >
> >  > The above was in XEmacs. In the regular (werl) shell:
> >  >
> >  > Erlang (BEAM) emulator version 5.1.1 [threads:0]
> >  >
> >  > Eshell V5.1.1  (abort with ^G)
> >  > 1> ets:lookup(vbDecl, varchar).
> >  >
> >  > =ERROR REPORT==== 24-May-2002::22:33:49 ===
> >  > Error in process <0.25.0> with exit value:
> >  > {badarg,[{ets,lookup,[vbDecl,varchar]
> >  > },{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
> >  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
> >  >                     {erl_eval,expr,3},
> >  >                     {erl_eval,exprs,4},
> >  >                     {shell,eval_loop,2}]} **
> >  >
> >  > Am I missing something?
> >  >
> >  > Alex
> >


Reply | Threaded
Open this post in threaded view
|

Ets Question

Alex Peake
Great! Thank you Thomas.

Is there a way to do this in XEmacs (which is a *much* more friendly way to
develop)?

Alex


> -----Original Message-----
> From: tle [mailto:tle]On Behalf Of
> Thomas Lange
> Sent: Saturday, May 25, 2002 9:28 AM
> To: Alex Peake
> Cc: erlang-questions
> Subject: Re: Ets Question
>
>
> Your problem is that you are running two erlang
> nodes ( different processes in OS ).
> They can never exchange data since you have no erlang
> distribution running.
>
> Every time you run werl, you launch a new node.
>
> In order to have 2 shells in the same node, do like
> Matthias did in his example ( ctrl-G ) to launch
> a second shell.
>
> /Thomas
>
>
> Alex Peake wrote:
> >
> > Thanks for the suggestion, but no, that is not the problem:
> >
> >     ets:new(vbDecl,[set,public,named_table,{keypos,1}])
> >     ets:insert(vbDecl,{varchar, "As String"}),
> >
> > Alex
> >
> > > -----Original Message-----
> > > From: owner-erlang-questions
> > > [mailto:owner-erlang-questions]On Behalf Of Matthias Lang
> > > Sent: Saturday, May 25, 2002 3:42 AM
> > > To: Alex Peake
> > > Cc: Hakan Mattsson; erlang-questions
> > > Subject: RE: Ets Question
> > >
> > >
> > > Hi,
> > >
> > > I can but guess what your vbDecl module is doing, perhaps you forgot
> > > to make the table a named table:
> > >
> > >    Erlang (BEAM) emulator version 5.1.1 [source]
> > >
> > >    Eshell V5.1.1  (abort with ^G)
> > >    1> self().
> > >    <0.23.0>
> > >    2> ets:new(mytable, [public, named_table]).
> > >    mytable
> > >    3>
> > >    User switch command
> > >     --> s
> > >     --> c
> > >    Eshell V5.1.1  (abort with ^G)
> > >    1> self().
> > >    <0.43.0>
> > >    2> ets:lookup(mytable, bla).
> > >    []
> > >
> > > Matthias
> > >
> > > --------------------
> > >
> > > Alex Peake writes:
> > >
> > >  > Trouble is, in the second shell, the table is not visible.
> > >  >
> > >  > 1>  ets:lookup(vbDecl, varchar).
> > >  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
> > >  >                     {erl_eval,expr,3},
> > >  >                     {erl_eval,exprs,4},
> > >  >                     {shell,eval_loop,2}]} **
> > >  >
> > >  > =ERROR REPORT==== 24-May-2002::22:30:40 ===
> > >  > Error in process <0.22.0> with exit value:
> > >  >
> > > {badarg,[{ets,lookup,[vbDecl,varchar]},{erl_eval,expr,3},{erl_eval
> > > ,exprs,4},
> > >  > {shell,eval_loop,2}]}
> > >  >
> > >  > But in the shell I start it in:
> > >  >
> > >  > 1> vbDecl:init().
> > >  > true
> > >  > 2> ets:lookup(vbDecl, varchar).
> > >  > [{varchar,"As String"}]
> > >  >
> > >  > The above was in XEmacs. In the regular (werl) shell:
> > >  >
> > >  > Erlang (BEAM) emulator version 5.1.1 [threads:0]
> > >  >
> > >  > Eshell V5.1.1  (abort with ^G)
> > >  > 1> ets:lookup(vbDecl, varchar).
> > >  >
> > >  > =ERROR REPORT==== 24-May-2002::22:33:49 ===
> > >  > Error in process <0.25.0> with exit value:
> > >  > {badarg,[{ets,lookup,[vbDecl,varchar]
> > >  > },{erl_eval,expr,3},{erl_eval,exprs,4},{shell,eval_loop,2}]}
> > >  > ** exited: {badarg,[{ets,lookup,[vbDecl,varchar]},
> > >  >                     {erl_eval,expr,3},
> > >  >                     {erl_eval,exprs,4},
> > >  >                     {shell,eval_loop,2}]} **
> > >  >
> > >  > Am I missing something?
> > >  >
> > >  > Alex
> > >
>