MySQL  8.0.19
Source Code Documentation
completion_hash.h
Go to the documentation of this file.
1 /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef _HASH_
24 #define _HASH_
25 
26 #define SUCCESS 0
27 #define FAILURE 1
28 
29 #include <sys/types.h>
30 
31 #include "my_alloc.h"
32 #include "my_sys.h"
33 
34 typedef struct _entry {
35  const char *str;
36  struct _entry *pNext;
37 } entry;
38 
39 typedef struct bucket {
40  uint h; /* Used for numeric indexing */
41  const char *arKey;
45  struct bucket *pNext;
46 } Bucket;
47 
48 typedef struct hashtable {
52  uint (*pHashFunction)(const char *arKey, uint nKeyLength);
54 } HashTable;
55 
56 extern int completion_hash_init(HashTable *ht, uint nSize);
57 extern int completion_hash_update(HashTable *ht, const char *arKey,
58  uint nKeyLength, const char *str);
59 extern int hash_exists(HashTable *ht, char *arKey);
60 extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
61  uint *res_length);
62 extern Bucket *find_longest_match(HashTable *ht, char *str, uint length,
63  uint *res_length);
64 extern void add_word(HashTable *ht, const char *str);
65 extern void completion_hash_clean(HashTable *ht);
66 extern int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
67 extern void completion_hash_free(HashTable *ht);
68 
69 #endif /* _HASH_ */
bucket::pNext
struct bucket * pNext
Definition: completion_hash.h:45
completion_hash_clean
void completion_hash_clean(HashTable *ht)
Definition: completion_hash.cc:194
bucket::h
uint h
Definition: completion_hash.h:40
completion_hash_exists
int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
Definition: completion_hash.cc:131
ht
static HashTable ht
Definition: mysql.cc:146
bucket
Definition: completion_hash.h:39
entry
struct _entry entry
hashtable::mem_root
MEM_ROOT mem_root
Definition: completion_hash.h:51
my_alloc.h
hashtable::initialized
uint initialized
Definition: completion_hash.h:50
bucket::pData
entry * pData
Definition: completion_hash.h:44
bucket::nKeyLength
uint nKeyLength
Definition: completion_hash.h:42
completion_hash_free
void completion_hash_free(HashTable *ht)
Definition: completion_hash.cc:199
MEM_ROOT
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
find_longest_match
Bucket * find_longest_match(HashTable *ht, char *str, uint length, uint *res_length)
Definition: completion_hash.cc:164
uint
unsigned int uint
Definition: uca-dump.cc:29
add_word
void add_word(HashTable *ht, const char *str)
Definition: completion_hash.cc:204
hashtable::arBuckets
Bucket ** arBuckets
Definition: completion_hash.h:53
hash_exists
int hash_exists(HashTable *ht, char *arKey)
completion_hash_init
int completion_hash_init(HashTable *ht, uint nSize)
Definition: completion_hash.cc:47
hashtable::pHashFunction
uint(* pHashFunction)(const char *arKey, uint nKeyLength)
Definition: completion_hash.h:52
Bucket
struct bucket Bucket
_entry
Definition: completion_hash.h:34
bucket::arKey
const char * arKey
Definition: completion_hash.h:41
bucket::count
uint count
Definition: completion_hash.h:43
completion_hash_update
int completion_hash_update(HashTable *ht, const char *arKey, uint nKeyLength, const char *str)
Definition: completion_hash.cc:63
gis::length
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
HashTable
struct hashtable HashTable
find_all_matches
Bucket * find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length)
Definition: completion_hash.cc:150
hashtable
Definition: completion_hash.h:48
hashtable::nTableSize
uint nTableSize
Definition: completion_hash.h:49
_entry::str
const char * str
Definition: completion_hash.h:35
_entry::pNext
struct _entry * pNext
Definition: completion_hash.h:36
my_sys.h