Commit 198df900 authored by unknown's avatar unknown

fixes for ft-boolean and range optimizer

parent 1bdd1963
......@@ -339,7 +339,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record)
/* curdoc matched ! */
info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); /* why is this ? */
/* info->lastpos=curdoc; */ /* do I need this ? */
info->lastpos=curdoc;
if (!(*info->read_record)(info,curdoc,record))
{
info->update|= HA_STATE_AKTIV; /* Record is read */
......@@ -348,6 +348,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record)
return my_errno;
}
}
ftb->state=INDEX_DONE;
return my_errno=HA_ERR_END_OF_FILE;
}
......@@ -359,17 +360,33 @@ float ft_boolean_find_relevance(FT_INFO *ftb, my_off_t docid, byte *record)
FTB_EXPR *ftbe;
uint i;
if (ftb->state == READY)
if (ftb->state == READY || ftb->state == INDEX_DONE)
{
for (i=1; i<=ftb->queue.elements; i++)
{
ftbw=(FTB_WORD *)(ftb->queue.root[i]);
ftbw->docid=HA_POS_ERROR;
for (ftbe=ftbw->up; ftbe; ftbe=ftbe->up)
{
if (ftbe->docid != HA_POS_ERROR)
{
ftbe->cur_weight=ftbe->yesses=ftbe->nos=0;
ftbe->docid=HA_POS_ERROR;
}
else
break;
}
}
queue_fix(& ftb->queue);
ftb->state=SCAN;
}
else if (ftb->state != SCAN)
return -1.0;
return -2.0;
bzero(&ptree, sizeof(ptree));
if (_mi_ft_parse(& ptree, ftb->info, ftb->keynr, record))
return -1.0;
return -3.0;
for (i=1; i<=ftb->queue.elements; i++)
{
......
......@@ -11,17 +11,40 @@ SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINS
a MATCH (message) AGAINST ('steve')
4 0.90587323904037
7 0.89568990468979
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
4 1
7 1
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
a MATCH (message) AGAINST ('steve')
4 0.90587323904037
7 0.89568990468979
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
4 1
7 1
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
a MATCH (message) AGAINST ('steve')
4 0.90587323904037
7 0.89568990468979
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
4 1
7 1
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
a MATCH (message) AGAINST ('steve')
7 0.89568990468979
4 0.90587323904037
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC;
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
7 1
4 1
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
a MATCH (message) AGAINST ('steve')
7 0.89568990468979
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1;
a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
7 1
SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel;
a rel
1 0
......@@ -31,4 +54,13 @@ a rel
6 0
7 0.89568990468979
4 0.90587323904037
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
a rel
1 0
2 0
3 0
5 0
6 0
4 1
7 1
drop table t1;
......@@ -9,17 +9,24 @@ INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"),
("steve"),("is"),("cool"),("steve is cool");
# basic MATCH
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve');
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
# MATCH + ORDER BY (with ft-ranges)
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
# MATCH + ORDER BY (with normal ranges) + UNIQUE
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC;
# MATCH + ORDER BY + UNIQUE (const_table)
SELECT a, MATCH (message) AGAINST ('steve') FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1;
# ORDER BY MATCH
SELECT a, MATCH (message) AGAINST ('steve') as rel FROM t1 ORDER BY rel;
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
drop table t1;
......@@ -29,7 +29,7 @@ class FT_SELECT: public QUICK_SELECT {
TABLE_REF *ref;
FT_SELECT(TABLE *table, TABLE_REF *tref) :
QUICK_SELECT (table,tref->key,1), ref(tref) {}
QUICK_SELECT (table,tref->key,1), ref(tref) { init(); }
int init() { return error=file->ft_init(); }
int get_next() { return error=file->ft_read(record); }
......
......@@ -407,11 +407,6 @@ QUICK_SELECT::~QUICK_SELECT()
}
}
int QUICK_SELECT::init()
{
return error=file->index_init(index);
}
QUICK_RANGE::QUICK_RANGE()
:min_key(0),max_key(0),min_length(0),max_length(0),
flag(NO_MIN_RANGE | NO_MAX_RANGE)
......
......@@ -75,7 +75,7 @@ class QUICK_SELECT {
QUICK_SELECT(TABLE *table,uint index_arg,bool no_alloc=0);
virtual ~QUICK_SELECT();
void reset(void) { next=0; it.rewind(); }
virtual int init();
int init() { return error=file->index_init(index); }
virtual int get_next();
int cmp_next(QUICK_RANGE *range);
bool unique_key_range();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment