Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2204614

Browse files
committed
first commit
0 parents  commit2204614

File tree

8 files changed

+2668
-0
lines changed

8 files changed

+2668
-0
lines changed

‎META.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name":"shared_ispell",
3+
"abstract":"Provides a shared ispell dictionary - initialized once and stored in shared segment.",
4+
"description":"Allows you to allocate area within a shared segment and use it for ispell dictionaries.",
5+
"version":"1.0.0",
6+
"maintainer":"Tomas Vondra <tv@fuzzy.cz>",
7+
"license":"bsd",
8+
"prereqs": {
9+
"runtime": {
10+
"requires": {
11+
"PostgreSQL":"9.0.0"
12+
}
13+
}
14+
},
15+
"provides": {
16+
"query_histogram": {
17+
"file":"shared_ispell--1.0.0.sql",
18+
"version":"1.0.0"
19+
}
20+
},
21+
"resources": {
22+
"repository": {
23+
"url":"https://github.com:tvondra/shared_ispell.git",
24+
"web":"http://github.com/tvondra/shared_ispell",
25+
"type":"git"
26+
}
27+
},
28+
"tags" : ["ispell","shared","fulltext","dictionary"],
29+
"meta-spec": {
30+
"version":"1.0.0",
31+
"url":"http://pgxn.org/meta/spec.txt"
32+
},
33+
"release_status" :"testing"
34+
}

‎Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
MODULE_big = shared_ispell
2+
OBJS = src/shared_ispell.o src/spell.o
3+
4+
EXTENSION = shared_ispell
5+
DATA = sql/shared_ispell--1.0.0.sql
6+
MODULES = shared_ispell
7+
8+
CFLAGS=`pg_config --includedir-server`
9+
10+
PG_CONFIG = pg_config
11+
PGXS :=$(shell$(PG_CONFIG) --pgxs)
12+
include$(PGXS)
13+
14+
all: shared_ispell.so
15+
16+
shared_ispell.so:$(OBJS)
17+
18+
%.o : src/%.c

‎README

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Shared ISpell Dictionary
2+
========================
3+
This PostgreSQL extension provides a shared ispell dictionary, i.e.
4+
a dictionary that's stored in shared segment. The traditional ispell
5+
implementation means that each session initializes and stores the
6+
dictionary on it's own, which means a lot of CPU/RAM is wasted.
7+
8+
This extension allocates an area in shared segment (you have to
9+
choose the size in advance) and then loads the dictionary into it
10+
when it's used for the first time.
11+
12+
If you need just snowball-type dictionaries, this extension is not
13+
really interesting for you. But if you really need an ispell
14+
dictionary, this may save you a lot of resources.
15+
16+
17+
Install
18+
-------
19+
Installing the extension is quite simple, especially if you're on 9.1.
20+
In that case all you need to do is this:
21+
22+
$ make install
23+
24+
and then (after connecting to the database)
25+
26+
db=# CREATE EXTENSION shared_ispell;
27+
28+
If you're on pre-9.1 version, you'll have to do the second part manually
29+
by running the SQL script (shared_ispell--x.y.sql) in the database. If
30+
needed, replace MODULE_PATHNAME by $libdir.
31+
32+
33+
Config
34+
------
35+
No the functions are created, but you still need to load the shared
36+
module. This needs to be done from postgresql.conf, as the module
37+
needs to allocate space in the shared memory segment. So add this to
38+
the config file (or update the current values)
39+
40+
# libraries to load
41+
shared_preload_libraries = 'shared_ispell'
42+
43+
# known GUC prefixes
44+
custom_variable_classes = 'shared_ispell'
45+
46+
# config of the shared memory
47+
shared_ispell.max_size = 30MB
48+
49+
Yes, there's a single GUC variable that defines the maximum size of
50+
the shared segment. This is a hard limit, the shared segment is not
51+
extensible and you need to set it so that all the dictionaries fit
52+
into it and not much memory is wasted.
53+
54+
Set it higher than you need, load all the dictionaries and check the
55+
log - after loading each dictionary, there's a LOG message with info
56+
about how much memory is available. Use that to tweak the GUC.
57+
58+
The shared segment can contain seve
59+
60+
Using the dictionary
61+
--------------------
62+
Technically, the extension defines a 'shared_ispell' template that
63+
you may use to define custom dictionaries. E.g. you may do this
64+
65+
CREATE TEXT SEARCH DICTIONARY czech_shared (
66+
TEMPLATE = shared_ispell,
67+
DictFile = czech,
68+
AffFile = czech,
69+
StopWords = czech
70+
);
71+
72+
CREATE TEXT SEARCH CONFIGURATION public.czech_shared
73+
( COPY = pg_catalog.simple );
74+
75+
ALTER TEXT SEARCH CONFIGURATION czech_shared
76+
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
77+
word, hword, hword_part
78+
WITH czech_shared;
79+
80+
and then do the usual stuff, e.g.
81+
82+
SELECT ts_lexize('czech_shared', 'automobile');
83+
84+
or whatever you want.

‎shared_ispell.control

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# shared ispell dictionary
2+
comment = 'Provides shared ispell dictionaries.'
3+
default_version = '1.0.0'
4+
relocatable = true
5+
6+
module_pathname = '$libdir/shared_ispell'

‎sql/shared_ispell--1.0.0.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
CREATE OR REPLACEFUNCTIONshared_dispell_init(internal)
2+
RETURNS internal
3+
AS'MODULE_PATHNAME','dispell_init'
4+
LANGUAGE C IMMUTABLE;
5+
6+
CREATE OR REPLACEFUNCTIONshared_dispell_lexize(internal,internal,internal,internal)
7+
RETURNS internal
8+
AS'MODULE_PATHNAME','dispell_lexize'
9+
LANGUAGE C IMMUTABLE;
10+
11+
CREATETEXT SEARCH TEMPLATE shared_ispell (
12+
INIT= shared_dispell_init,
13+
LEXIZE= shared_dispell_lexize
14+
);
15+
16+
CREATETEXT SEARCH DICTIONARY czech_shared (
17+
TEMPLATE= shared_ispell,
18+
DictFile= czech,
19+
AffFile= czech,
20+
StopWords= czech
21+
);
22+
23+
CREATETEXT SEARCH CONFIGURATIONpublic.czech_shared ( COPY=pg_catalog.simple );
24+
25+
ALTERTEXT SEARCH CONFIGURATION czech_shared
26+
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
27+
word, hword, hword_part
28+
WITH czech_shared;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp