Re: easy way of copying regex_t - Mailing list pgsql-hackers

From Artur Zakirov
Subject Re: easy way of copying regex_t
Date
Msg-id 56A53DAA.7030406@postgrespro.ru
Whole thread Raw
Responses Re: easy way of copying regex_t
List pgsql-hackers
> Hi all,
>
> I've been working on moving an extension that allows to move the ispell
> dictionaries to shared segment. It's almost complete, the last FIXME is
> about copying regex_t structure (stored in AFFIX).
>
> According to regex.h the structure is fairly complex and not exactly easy
> to understand, so I'd like to know if anyone here already implemented that
> or something that may serve the same purpose. Any ideas?
>
> kind regards
> Tomas

This message is the reply to the message
http://www.postgresql.org/message-id/dd02a31fdeffbf5cb24771e34213b40f.squirrel@sq.gransy.com
Sorry, I can't reply to it directly. I can't get it from archive.

Thank you for your extension shared_ispell. It is very useful. I have
got it from https://github.com/tvondra/shared_ispell
With this message I want to send some patch to your repository with
draft of a code, which allows shared_ispell to copy regex_t.

The main idea of the patch is:
- we doesn't need copy all regex_t structure
- most of fields and structures used only in a compile time
- we need copy structures: guts, colormap, subre, cnfa
- from the subre structure we need only cnfa

colormap represents a directed acyclic graph. cnfa represents a
nondeterministic finite automaton.

In this patch also was done the following:
- added regression tests
- deleted spell.h and spell.c since they have duplicate code
- added shared_ispell.h which declares some structures
- fix an issue when stopFile can be NULL
- fixed countCMPDAffixes since theoretically could be zero affix
- added copyCMPDAffix

Question to hackers. Can such patch be useful as a PostgreSQL patch to
Full-Text search? Is it needed?

shared_ispell loads dictionaries into a shared memory. The main benefits
are:
- saving of memory. Every dictionary is loaded only once. Dictionaries
are not loaded for each backend. In current version of PostgreSQL
dictionaires are loaded for each backend where it was requested.
- saving of time. The first load of a dictionary takes much time. With
this patch dictionaries will be loaded only once.

--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Removing Functionally Dependent GROUP BY Columns
Next
From: Tom Lane
Date:
Subject: Re: Removing Functionally Dependent GROUP BY Columns