MySQL  8.0.17
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_ */
struct _entry entry
int completion_hash_update(HashTable *ht, const char *arKey, uint nKeyLength, const char *str)
Definition: completion_hash.cc:63
uint(* pHashFunction)(const char *arKey, uint nKeyLength)
Definition: completion_hash.h:52
void completion_hash_clean(HashTable *ht)
Definition: completion_hash.cc:194
uint nTableSize
Definition: completion_hash.h:49
void add_word(HashTable *ht, const char *str)
Definition: completion_hash.cc:204
uint h
Definition: completion_hash.h:40
int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
Definition: completion_hash.cc:131
void completion_hash_free(HashTable *ht)
Definition: completion_hash.cc:199
int completion_hash_init(HashTable *ht, uint nSize)
Definition: completion_hash.cc:47
const char * str
Definition: completion_hash.h:35
unsigned int uint
Definition: uca-dump.cc:29
int hash_exists(HashTable *ht, char *arKey)
uint nKeyLength
Definition: completion_hash.h:42
Bucket * find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length)
Definition: completion_hash.cc:150
Common header for many mysys elements.
static HashTable ht
Definition: mysql.cc:144
MEM_ROOT mem_root
Definition: completion_hash.h:51
struct hashtable HashTable
entry * pData
Definition: completion_hash.h:44
Bucket * find_longest_match(HashTable *ht, char *str, uint length, uint *res_length)
Definition: completion_hash.cc:164
uint count
Definition: completion_hash.h:43
const char * arKey
Definition: completion_hash.h:41
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:77
struct bucket * pNext
Definition: completion_hash.h:45
struct _entry * pNext
Definition: completion_hash.h:36
Definition: completion_hash.h:48
Definition: completion_hash.h:34
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
uint initialized
Definition: completion_hash.h:50
Definition: completion_hash.h:39
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Bucket ** arBuckets
Definition: completion_hash.h:53
struct bucket Bucket