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

Commit157d137

Browse files
author
Artur Zakirov
committed
Added features and fix bugs:
- use index scan with order by without where clause.- added RumKey structure.- fix indentation.- fix tests.
1 parent209619e commit157d137

23 files changed

+1723
-1314
lines changed

‎.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.deps
22
*.o
33
*.so
4-
results
4+
results

‎README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ The **rum** module provides the access method **rum** and the operator class
3232

3333
The module provides new operators.
3434

35-
| Operator | Returns | Description
36-
| ------------------- | ------- | ----------------------------------------------
37-
| tsvector>< tsquery | float4 | Returns distance between tsvector and tsquery.
35+
| Operator| Returns | Description
36+
| -------------------- | ------- | ----------------------------------------------
37+
| tsvector<-> tsquery | float4 | Returns distance between tsvector and tsquery.
3838

3939
##Examples
4040

@@ -67,15 +67,21 @@ CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
6767
And we can execute the following queries:
6868

6969
```sql
70-
=# SELECT t, a >< to_tsquery('english', 'beautiful | place') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'beautiful | place') order by a >< to_tsquery('english', 'beautiful | place');
70+
=# SELECT t, a <-> to_tsquery('english', 'beautiful | place') AS rank
71+
FROM test_rum
72+
WHERE a @@ to_tsquery('english','beautiful | place')
73+
ORDER BY a<-> to_tsquery('english','beautiful | place');
7174
t | rank
7275
---------------------------------+-----------
7376
The situation is most beautiful |0.0303964
7477
It is a beautiful |0.0303964
7578
It lookslike a beautiful place |0.0607927
7679
(3 rows)
7780

78-
=# SELECT t, a >< to_tsquery('english', 'place | situation') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'place | situation') order by a >< to_tsquery('english', 'place | situation');
81+
=# SELECT t, a <-> to_tsquery('english', 'place | situation') AS rank
82+
FROM test_rum
83+
WHERE a @@ to_tsquery('english','place | situation')
84+
ORDER BY a<-> to_tsquery('english','place | situation');
7985
t | rank
8086
---------------------------------+-----------
8187
The situation is most beautiful |0.0303964

‎expected/orderby.out

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,22 @@ SELECT id, d, d |-> '2016-05-16 14:21:25' FROM tsts WHERE t @@ 'wr&qh' ORDER BY
184184
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
185185
(5 rows)
186186

187-
--to be fixed
188-
--EXPLAIN (costs off)
189-
--SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
190-
--SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
187+
EXPLAIN (costs off)
188+
SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
189+
QUERY PLAN
190+
-----------------------------------------------------------------------------------
191+
Limit
192+
-> Index Scan using tsts_idx on tsts
193+
Order By: (d <-> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
194+
(3 rows)
195+
196+
SELECT id, d, d <-> '2016-05-16 14:21:25' FROM tsts ORDER BY d <-> '2016-05-16 14:21:25' LIMIT 5;
197+
id | d | ?column?
198+
-----+---------------------------------+-------------
199+
355 | Mon May 16 14:21:22.326724 2016 | 2.673276
200+
356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
201+
354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
202+
357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
203+
353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
204+
(5 rows)
205+

‎expected/rum.out

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
9696
ORDER BY a <-> to_tsquery('pg_catalog.english', 'way');
9797
rum_ts_distance | t | a
9898
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
99-
0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
100-
0.0607927 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
101-
0.0607927 | so well that only a fragment, as it were, gave way. It still hangs as if | 'fragment':6 'gave':10 'hang':14 'still':13 'way':11 'well':2
102-
0.0607927 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
99+
16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
100+
16.4493 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
101+
16.4493 | so well that only a fragment, as it were, gave way. It still hangs as if | 'fragment':6 'gave':10 'hang':14 'still':13 'way':11 'well':2
102+
16.4493 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
103103
(4 rows)
104104

105105
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
@@ -108,10 +108,23 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))
108108
ORDER BY a <-> to_tsquery('pg_catalog.english', 'way & (go | half)');
109109
rum_ts_distance | t | a
110110
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
111-
0.103556 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
112-
0.0991032 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
111+
9.65659 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
112+
10.0905 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
113113
(2 rows)
114114

115+
SELECT
116+
a <-> to_tsquery('pg_catalog.english', 'way & (go | half)'),
117+
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
118+
*
119+
FROM test_rum
120+
ORDER BY a <-> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 3;
121+
?column? | rum_ts_distance | t | a
122+
----------+-----------------+-------------------------------------------------------------------------+---------------------------------------------------------
123+
9.65659 | 9.65659 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
124+
10.0905 | 10.0905 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
125+
1e+20 | 1e+20 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
126+
(3 rows)
127+
115128
INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');
116129
INSERT INTO test_rum (t) VALUES ('345 qwerty copyright');
117130
INSERT INTO test_rum (t) VALUES ('345 qwerty');
@@ -146,13 +159,6 @@ SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER
146159
'bar':2,8 'foo':1,3,6 'qq':7
147160
(1 row)
148161

149-
DELETE FROM test_rum;
150-
SELECT count(*) from test_rum;
151-
count
152-
-------
153-
0
154-
(1 row)
155-
156162
CREATE TABLE tst (i int4, t tsvector);
157163
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
158164
CREATE INDEX tstidx ON tst USING rum (t rum_tsvector_ops);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp