Re: ETS retrieve all objects before deleting the table
Frank Muller <[email protected]> Wed, 19 Jan 2022 23:17:31 +0100
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAFA6GnDgzO+68R3JSTr=s514STpWFQ=Nptrg8FmGHizok-AM_g@mail.gmail.com> |
Hi Valentin, Have you read what I posted in earlier messages? I already explored first/next with other alternatives. Thanks anyway /F. > In addition to serialisation to disk (its:tab2file/2,3), one can always > use: > > *ets:first/1* followed by a number of calls to *ets:next/2* > > > e.g. > ets:first( Tab ) -> Key > ets:lookup( Tab, Key ) -> [TableRow] % to retrieve data associated with > this key > ets:next( Tab, Key ) -> NextKey, etc. > > NOTE: once the end of the table is reached, instead of a key an atom > ‘$end_of_table’ is returned by ets:next/2. > > > On 19 Jan 2022, at 23:33, [email protected] <[email protected]> > wrote: > > To serialize ETS to a file on the disk, one may use ets:tab2file/2,3. > > It does not destroy the table, but simply dumps a content of the table to > a file. I’ve used it a number of times and it works as advertised. > I don’t think there’s a tool available to traverse this file without > loading it back to ETS (via ets:file2tab/1,2). > > However, it may be a start. > > > V/ > > > > > On 18 Jan 2022, at 17:02, Hugo Mills <[email protected]> wrote: > > I may be wrong, but my reading of Frank's requirement was that the > table needs to be serialised to disk in some external format so that > it can be processed by some additional tool outside the current erlang > application. No amount of reparenting to another erlang process in the > same VM is going to accomplish that... > > Hugo. > > On Tue, Jan 18, 2022 at 03:49:51PM +0200, Led wrote: > > > I think this opinion stems from confusion about the GiftData argument > in ets:give_away/3. > > AFAIK this just passes whatever 'data' you set for the variable, not > the actual table data, through to the recipient of the 'ETS_TRANSFER' > message. > > > It gives all table data with full access to the process "for > processing". What else do you need? > > > On Tue, Jan 18, 2022 at 7:28 AM Frank Muller <[email protected]> > wrote: > > > No it doesn’t. It only charges the table owner > > > > > I’d like to retrieve all objects before deleting the table. > > > Strange task. Table is already "all objects". > > > > Nothing strange. Just a simple requirement. > Objects are sent elsewhere for processing before deleting the table > content. > > > What’s the most efficient way to do it? > > > ets:give_away/3 > > > > That’s strange indeed. How give_away/3 could help? It gives the ownership > to another proc. > > > It actually sends all objects elsewhere (to another proc) for processing. > > > -- > Hugo Mills | All hope abandon, Ye who press Enter here. > hugo@... carfax.org.uk | > http://carfax.org.uk/ | > PGP: E2AB1DE4 | > > > >