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

Commitb0df6a3

Browse files
author
Alexander Korotkov
committed
Solution of inverted task.
1 parenteba125c commitb0df6a3

File tree

6 files changed

+957
-2
lines changed

6 files changed

+957
-2
lines changed

‎.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.deps
2+
*.o
3+
*.so
4+
results

‎Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# contrib/rum/Makefile
22

33
MODULE_big = rum
4-
OBJS = rumsort.o rum_ts_utils.o\
4+
OBJS = rumsort.o rum_ts_utils.orumtsquery.o\
55
rumbtree.o rumbulk.o rumdatapage.o\
66
rumentrypage.o rumfast.o rumget.o ruminsert.o\
77
rumscan.o rumutil.o rumvacuum.o rumvalidate.o\
@@ -11,7 +11,7 @@ EXTENSION = rum
1111
DATA = rum--1.0.sql
1212
PGFILEDESC = "RUM index access method"
1313

14-
REGRESS = rum timestamp orderby
14+
REGRESS = rumruminvtimestamp orderby
1515

1616
ifdefUSE_PGXS
1717
PG_CONFIG = pg_config

‎expected/ruminv.out

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
CREATE TABLE test_invrum(q tsquery);
2+
INSERT INTO test_invrum VALUES ('a|b'::tsquery);
3+
INSERT INTO test_invrum VALUES ('a&b'::tsquery);
4+
INSERT INTO test_invrum VALUES ('!(a|b)'::tsquery);
5+
INSERT INTO test_invrum VALUES ('!(a&b)'::tsquery);
6+
INSERT INTO test_invrum VALUES ('!a|b'::tsquery);
7+
INSERT INTO test_invrum VALUES ('a&!b'::tsquery);
8+
INSERT INTO test_invrum VALUES ('(a|b)&c'::tsquery);
9+
INSERT INTO test_invrum VALUES ('(!(a|b))&c'::tsquery);
10+
INSERT INTO test_invrum VALUES ('(a|b)&(c|d)'::tsquery);
11+
INSERT INTO test_invrum VALUES ('!a'::tsquery);
12+
SELECT * FROM test_invrum WHERE q @@ ''::tsvector;
13+
q
14+
---
15+
(0 rows)
16+
17+
SELECT * FROM test_invrum WHERE q @@ 'a'::tsvector;
18+
q
19+
----------------
20+
'a' | 'b'
21+
!( 'a' & 'b' )
22+
'a' & !'b'
23+
(3 rows)
24+
25+
SELECT * FROM test_invrum WHERE q @@ 'b'::tsvector;
26+
q
27+
----------------
28+
'a' | 'b'
29+
!( 'a' & 'b' )
30+
!'a' | 'b'
31+
!'a'
32+
(4 rows)
33+
34+
SELECT * FROM test_invrum WHERE q @@ 'a b'::tsvector;
35+
q
36+
------------
37+
'a' | 'b'
38+
'a' & 'b'
39+
!'a' | 'b'
40+
(3 rows)
41+
42+
SELECT * FROM test_invrum WHERE q @@ 'c'::tsvector;
43+
q
44+
----------------------
45+
!( 'a' | 'b' )
46+
!( 'a' & 'b' )
47+
!'a' | 'b'
48+
!( 'a' | 'b' ) & 'c'
49+
!'a'
50+
(5 rows)
51+
52+
SELECT * FROM test_invrum WHERE q @@ 'a c'::tsvector;
53+
q
54+
-------------------------------
55+
'a' | 'b'
56+
!( 'a' & 'b' )
57+
'a' & !'b'
58+
( 'a' | 'b' ) & 'c'
59+
( 'a' | 'b' ) & ( 'c' | 'd' )
60+
(5 rows)
61+
62+
SELECT * FROM test_invrum WHERE q @@ 'b c'::tsvector;
63+
q
64+
-------------------------------
65+
'a' | 'b'
66+
!( 'a' & 'b' )
67+
!'a' | 'b'
68+
( 'a' | 'b' ) & 'c'
69+
( 'a' | 'b' ) & ( 'c' | 'd' )
70+
!'a'
71+
(6 rows)
72+
73+
SELECT * FROM test_invrum WHERE q @@ 'a b c'::tsvector;
74+
q
75+
-------------------------------
76+
'a' | 'b'
77+
'a' & 'b'
78+
!'a' | 'b'
79+
( 'a' | 'b' ) & 'c'
80+
( 'a' | 'b' ) & ( 'c' | 'd' )
81+
(5 rows)
82+
83+
SELECT * FROM test_invrum WHERE q @@ 'd'::tsvector;
84+
q
85+
----------------
86+
!( 'a' | 'b' )
87+
!( 'a' & 'b' )
88+
!'a' | 'b'
89+
!'a'
90+
(4 rows)
91+
92+
SELECT * FROM test_invrum WHERE q @@ 'a d'::tsvector;
93+
q
94+
-------------------------------
95+
'a' | 'b'
96+
!( 'a' & 'b' )
97+
'a' & !'b'
98+
( 'a' | 'b' ) & ( 'c' | 'd' )
99+
(4 rows)
100+
101+
SELECT * FROM test_invrum WHERE q @@ 'b d'::tsvector;
102+
q
103+
-------------------------------
104+
'a' | 'b'
105+
!( 'a' & 'b' )
106+
!'a' | 'b'
107+
( 'a' | 'b' ) & ( 'c' | 'd' )
108+
!'a'
109+
(5 rows)
110+
111+
SELECT * FROM test_invrum WHERE q @@ 'a b d'::tsvector;
112+
q
113+
-------------------------------
114+
'a' | 'b'
115+
'a' & 'b'
116+
!'a' | 'b'
117+
( 'a' | 'b' ) & ( 'c' | 'd' )
118+
(4 rows)
119+
120+
SELECT * FROM test_invrum WHERE q @@ 'c d'::tsvector;
121+
q
122+
----------------------
123+
!( 'a' | 'b' )
124+
!( 'a' & 'b' )
125+
!'a' | 'b'
126+
!( 'a' | 'b' ) & 'c'
127+
!'a'
128+
(5 rows)
129+
130+
SELECT * FROM test_invrum WHERE q @@ 'a c d'::tsvector;
131+
q
132+
-------------------------------
133+
'a' | 'b'
134+
!( 'a' & 'b' )
135+
'a' & !'b'
136+
( 'a' | 'b' ) & 'c'
137+
( 'a' | 'b' ) & ( 'c' | 'd' )
138+
(5 rows)
139+
140+
CREATE INDEX test_invrum_idx ON test_invrum USING rum(q);
141+
SET enable_seqscan = OFF;
142+
SELECT * FROM test_invrum WHERE q @@ ''::tsvector;
143+
q
144+
---
145+
(0 rows)
146+
147+
SELECT * FROM test_invrum WHERE q @@ 'a'::tsvector;
148+
q
149+
----------------
150+
'a' | 'b'
151+
!( 'a' & 'b' )
152+
'a' & !'b'
153+
(3 rows)
154+
155+
SELECT * FROM test_invrum WHERE q @@ 'b'::tsvector;
156+
q
157+
----------------
158+
'a' | 'b'
159+
!( 'a' & 'b' )
160+
!'a' | 'b'
161+
!'a'
162+
(4 rows)
163+
164+
SELECT * FROM test_invrum WHERE q @@ 'a b'::tsvector;
165+
q
166+
------------
167+
'a' | 'b'
168+
'a' & 'b'
169+
!'a' | 'b'
170+
(3 rows)
171+
172+
SELECT * FROM test_invrum WHERE q @@ 'c'::tsvector;
173+
q
174+
----------------------
175+
!( 'a' | 'b' )
176+
!( 'a' & 'b' )
177+
!'a' | 'b'
178+
!( 'a' | 'b' ) & 'c'
179+
!'a'
180+
(5 rows)
181+
182+
SELECT * FROM test_invrum WHERE q @@ 'a c'::tsvector;
183+
q
184+
-------------------------------
185+
'a' | 'b'
186+
!( 'a' & 'b' )
187+
'a' & !'b'
188+
( 'a' | 'b' ) & 'c'
189+
( 'a' | 'b' ) & ( 'c' | 'd' )
190+
(5 rows)
191+
192+
SELECT * FROM test_invrum WHERE q @@ 'b c'::tsvector;
193+
q
194+
-------------------------------
195+
'a' | 'b'
196+
!( 'a' & 'b' )
197+
!'a' | 'b'
198+
( 'a' | 'b' ) & 'c'
199+
( 'a' | 'b' ) & ( 'c' | 'd' )
200+
!'a'
201+
(6 rows)
202+
203+
SELECT * FROM test_invrum WHERE q @@ 'a b c'::tsvector;
204+
q
205+
-------------------------------
206+
'a' | 'b'
207+
'a' & 'b'
208+
!'a' | 'b'
209+
( 'a' | 'b' ) & 'c'
210+
( 'a' | 'b' ) & ( 'c' | 'd' )
211+
(5 rows)
212+
213+
SELECT * FROM test_invrum WHERE q @@ 'd'::tsvector;
214+
q
215+
----------------
216+
!( 'a' | 'b' )
217+
!( 'a' & 'b' )
218+
!'a' | 'b'
219+
!'a'
220+
(4 rows)
221+
222+
SELECT * FROM test_invrum WHERE q @@ 'a d'::tsvector;
223+
q
224+
-------------------------------
225+
'a' | 'b'
226+
!( 'a' & 'b' )
227+
'a' & !'b'
228+
( 'a' | 'b' ) & ( 'c' | 'd' )
229+
(4 rows)
230+
231+
SELECT * FROM test_invrum WHERE q @@ 'b d'::tsvector;
232+
q
233+
-------------------------------
234+
'a' | 'b'
235+
!( 'a' & 'b' )
236+
!'a' | 'b'
237+
( 'a' | 'b' ) & ( 'c' | 'd' )
238+
!'a'
239+
(5 rows)
240+
241+
SELECT * FROM test_invrum WHERE q @@ 'a b d'::tsvector;
242+
q
243+
-------------------------------
244+
'a' | 'b'
245+
'a' & 'b'
246+
!'a' | 'b'
247+
( 'a' | 'b' ) & ( 'c' | 'd' )
248+
(4 rows)
249+
250+
SELECT * FROM test_invrum WHERE q @@ 'c d'::tsvector;
251+
q
252+
----------------------
253+
!( 'a' | 'b' )
254+
!( 'a' & 'b' )
255+
!'a' | 'b'
256+
!( 'a' | 'b' ) & 'c'
257+
!'a'
258+
(5 rows)
259+
260+
SELECT * FROM test_invrum WHERE q @@ 'a c d'::tsvector;
261+
q
262+
-------------------------------
263+
'a' | 'b'
264+
!( 'a' & 'b' )
265+
'a' & !'b'
266+
( 'a' | 'b' ) & 'c'
267+
( 'a' | 'b' ) & ( 'c' | 'd' )
268+
(5 rows)
269+
270+
INSERT INTO test_invrum VALUES ('a:*'::tsquery);
271+
ERROR: Indexing of prefix tsqueries isn't supported yet
272+
INSERT INTO test_invrum VALUES ('a <-> b'::tsquery);
273+
ERROR: Indexing of phrase tsqueries isn't supported yet

‎rum--1.0.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,33 @@ AS
172172
STORAGEtext;
173173

174174

175+
CREATEFUNCTIONruminv_extract_tsquery(tsquery,internal,internal,internal,internal)
176+
RETURNS internal
177+
AS'MODULE_PATHNAME'
178+
LANGUAGE C IMMUTABLE STRICT;
179+
180+
CREATEFUNCTIONruminv_extract_tsvector(tsvector,internal,smallint,internal,internal,internal,internal)
181+
RETURNS internal
182+
AS'MODULE_PATHNAME'
183+
LANGUAGE C IMMUTABLE STRICT;
184+
185+
CREATEFUNCTIONruminv_tsvector_consistent(internal,smallint, tsvector,integer, internal, internal, internal, internal)
186+
RETURNS bool
187+
AS'MODULE_PATHNAME'
188+
LANGUAGE C IMMUTABLE STRICT;
189+
190+
CREATEFUNCTIONruminv_tsquery_config(internal)
191+
RETURNS void
192+
AS'MODULE_PATHNAME'
193+
LANGUAGE C IMMUTABLE STRICT;
194+
195+
CREATEOPERATOR CLASSrum_tsquery_ops
196+
DEFAULT FOR TYPE tsquery USING rum
197+
AS
198+
OPERATOR1 @@ (tsquery, tsvector),
199+
FUNCTION1 gin_cmp_tslexeme(text,text),
200+
FUNCTION2 ruminv_extract_tsquery(tsquery,internal,internal,internal,internal),
201+
FUNCTION3 ruminv_extract_tsvector(tsvector,internal,smallint,internal,internal,internal,internal),
202+
FUNCTION4 ruminv_tsvector_consistent(internal,smallint,tsvector,int,internal,internal,internal,internal),
203+
FUNCTION6 ruminv_tsquery_config(internal),
204+
STORAGEtext;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp