Commit 6c9c8d56 authored by Sergei Golubchik's avatar Sergei Golubchik

sphinxse 0.9.9

parents
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
ADD_DEFINITIONS(-DMYSQL_SERVER)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/extra/yassl/include
${CMAKE_SOURCE_DIR}/regex)
SET(SPHINX_SOURCES ha_sphinx.cc)
ADD_LIBRARY(sphinx ha_sphinx.cc)
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#called from the top level Makefile
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
-I$(srcdir)
SUBDIRS = ../../include ../../mysys ../../strings ../../dbug ../../extra
WRAPLIBS=
LDADD =
DEFS= @DEFS@ \
-D_REENTRANT -D_PTHREADS -DENGINE -DSTORAGE_ENGINE -DMYSQL_SERVER
noinst_HEADERS = ha_sphinx.h
EXTRA_LTLIBRARIES = ha_sphinx.la
pkgplugin_LTLIBRARIES = @plugin_sphinx_shared_target@ sphinx.la
ha_sphinx_la_LDFLAGS = -module -rpath $(MYSQLLIBdir)
ha_sphinx_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_sphinx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_sphinx_la_SOURCES = ha_sphinx.cc
sphinx_la_LDFLAGS = -module
sphinx_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
sphinx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
sphinx_la_SOURCES = snippets_udf.cc
EXTRA_LIBRARIES = libsphinx.a
noinst_LIBRARIES = @plugin_sphinx_static_target@
libsphinx_a_CXXFLAGS = $(AM_CFLAGS)
libsphinx_a_CFLAGS = $(AM_CFLAGS)
libsphinx_a_SOURCES= ha_sphinx.cc
EXTRA_DIST = cmakelists.txt
# Don't update the files from bitkeeper
%::SCCS/s.%
<?php
$file_name= $argv[1];
//echo $file_name;
$cont= file_get_contents($file_name);
$words= explode(" ", $cont);
//echo "words: ".(count($words))."\n";
$cw = count($words);
echo "REPLACE INTO test.documents ( id, group_id, date_added, title, content ) VALUES\n";
for ($i=1; $i<=100000; $i++)
{
$count_words= mt_rand(10,30);
$pred = "";
for ($j=0; $j<$count_words; $j++)
{
$pred .= chop($words[mt_rand(1, $cw-1)])." ";
}
$count_words= mt_rand(3,5);
$tit = "";
for ($j=0; $j<$count_words; $j++)
{
$tit .= chop($words[mt_rand(1, $cw-1)])." ";
}
echo "($i,".mt_rand(1,20).",NOW(),'".addslashes($tit)."','".addslashes($pred)."'),\n";
}
echo "(0,1,now(),'end','eND');\n";
?>
This diff is collapsed.
//
// $Id$
//
#ifdef USE_PRAGMA_INTERFACE
#pragma interface // gcc class implementation
#endif
#if MYSQL_VERSION_ID>50100
#define TABLE_ARG st_table_share
#else
#define TABLE_ARG st_table
#endif
#if MYSQL_VERSION_ID>=50120
typedef uchar byte;
#endif
/// forward decls
class THD;
struct CSphReqQuery;
struct CSphSEShare;
struct CSphSEAttr;
struct CSphSEStats;
struct CSphSEThreadData;
/// Sphinx SE handler class
class ha_sphinx : public handler
{
protected:
THR_LOCK_DATA m_tLock; ///< MySQL lock
CSphSEShare * m_pShare; ///< shared lock info
uint m_iMatchesTotal;
uint m_iCurrentPos;
const byte * m_pCurrentKey;
uint m_iCurrentKeyLen;
char * m_pResponse; ///< searchd response storage
char * m_pResponseEnd; ///< searchd response storage end (points to wilderness!)
char * m_pCur; ///< current position into response
bool m_bUnpackError; ///< any errors while unpacking response
public:
#if MYSQL_VERSION_ID<50100
ha_sphinx ( TABLE_ARG * table_arg );
#else
ha_sphinx ( handlerton * hton, TABLE_ARG * table_arg );
#endif
~ha_sphinx () {}
const char * table_type () const { return "SPHINX"; } ///< SE name for display purposes
const char * index_type ( uint ) { return "HASH"; } ///< index type name for display purposes
const char ** bas_ext () const; ///< my file extensions
#if MYSQL_VERSION_ID>50100
ulonglong table_flags () const { return HA_CAN_INDEX_BLOBS; } ///< bitmap of implemented flags (see handler.h for more info)
#else
ulong table_flags () const { return HA_CAN_INDEX_BLOBS; } ///< bitmap of implemented flags (see handler.h for more info)
#endif
ulong index_flags ( uint, uint, bool ) const { return 0; } ///< bitmap of flags that says how SE implements indexes
uint max_supported_record_length () const { return HA_MAX_REC_LENGTH; }
uint max_supported_keys () const { return 1; }
uint max_supported_key_parts () const { return 1; }
uint max_supported_key_length () const { return MAX_KEY_LENGTH; }
uint max_supported_key_part_length () const { return MAX_KEY_LENGTH; }
#if MYSQL_VERSION_ID>50100
virtual double scan_time () { return (double)( stats.records+stats.deleted )/20.0 + 10; } ///< called in test_quick_select to determine if indexes should be used
#else
virtual double scan_time () { return (double)( records+deleted )/20.0 + 10; } ///< called in test_quick_select to determine if indexes should be used
#endif
virtual double read_time ( ha_rows rows ) { return (double)rows/20.0 + 1; } ///< index read time estimate
public:
int open ( const char * name, int mode, uint test_if_locked );
int close ();
int write_row ( uchar * buf );
int update_row ( const uchar * old_data, uchar * new_data );
int delete_row ( const uchar * buf );
int index_init ( uint keynr, bool sorted ); // 5.1.x
int index_init ( uint keynr ) { return index_init ( keynr, false ); } // 5.0.x
int index_end ();
int index_read ( byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag );
int index_read_idx ( byte * buf, uint idx, const byte * key, uint key_len, enum ha_rkey_function find_flag );
int index_next ( byte * buf );
int index_next_same ( byte * buf, const byte * key, uint keylen );
int index_prev ( byte * buf );
int index_first ( byte * buf );
int index_last ( byte * buf );
int get_rec ( byte * buf, const byte * key, uint keylen );
int rnd_init ( bool scan );
int rnd_end ();
int rnd_next ( byte * buf );
int rnd_pos ( byte * buf, byte * pos );
void position ( const byte * record );
#if MYSQL_VERSION_ID>=50030
int info ( uint );
#else
void info ( uint );
#endif
int reset();
int external_lock ( THD * thd, int lock_type );
int delete_all_rows ();
ha_rows records_in_range ( uint inx, key_range * min_key, key_range * max_key );
int delete_table ( const char * from );
int rename_table ( const char * from, const char * to );
int create ( const char * name, TABLE * form, HA_CREATE_INFO * create_info );
THR_LOCK_DATA **store_lock ( THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type );
public:
virtual const COND * cond_push ( const COND *cond );
virtual void cond_pop ();
private:
uint32 m_iFields;
char ** m_dFields;
uint32 m_iAttrs;
CSphSEAttr * m_dAttrs;
int m_bId64;
int * m_dUnboundFields;
private:
int ConnectToSearchd ( const char * sQueryHost, int iQueryPort );
uint32 UnpackDword ();
char * UnpackString ();
bool UnpackSchema ();
bool UnpackStats ( CSphSEStats * pStats );
CSphSEThreadData * GetTls ();
};
#if MYSQL_VERSION_ID < 50100
bool sphinx_show_status ( THD * thd );
#endif
int sphinx_showfunc_total_found ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_total ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_time ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_word_count ( THD *, SHOW_VAR *, char * );
int sphinx_showfunc_words ( THD *, SHOW_VAR *, char * );
//
// $Id$
//
#!/bin/sh
OUT=$1
ORIG=$2
NEW=$3
if [ ! \( "$1" -a "$2" -a "$3" \) ]; then
echo "$0 <patch> <original> <new>"
exit 1
fi
FILES='
/config/ac-macros/ha_sphinx.m4
/configure.in
/libmysqld/Makefile.am
/sql/handler.cc
/sql/handler.h
/sql/Makefile.am
/sql/mysqld.cc
/sql/mysql_priv.h
/sql/set_var.cc
/sql/sql_lex.h
/sql/sql_parse.cc
/sql/sql_yacc.yy
/sql/structs.h
/sql/sql_show.cc
'
rm -f $OUT
if [ -e $OUT ]; then
exit 1
fi
for name in $FILES; do
diff -BNru "$ORIG$name" "$NEW$name" >> $OUT
done
MYSQL_STORAGE_ENGINE(sphinx,, [Sphinx Storage Engine],
[Sphinx Storage Engines], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(sphinx, [storage/sphinx])
MYSQL_PLUGIN_STATIC(sphinx, [libsphinx.a])
MYSQL_PLUGIN_DYNAMIC(sphinx, [ha_sphinx.la])
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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